DetailViewObject => Commit changed to detail

Hello dear colleagues,

can someone describe difference between the two methods:

DetailViewObject.CommitChanges()
RhinoObject.CommitChanges method

and

DetailViewObject.CommitViewportChanges()
DetailViewObject.CommitViewportChanges method

If I run ‘CommitChanges’ after ‘CommitViewportChanges()’ it erases all changed to the viewport.
If i run it in reversed order it works correctly.

Thanks for your reply

Ondřej

Hi @janotaondrej91,

I can see how this can be confusing.

If you want to modify properties of a detail object’s viewport, then you’d use DetailViewObject.CommitViewportChanges.

For example:

SetDetaiDisplayMode.py (2.3 KB)

If you wanted to modify the detail object itself, perhaps the layer on which it reside, then you’d use the former.

– Dale

Thanks @dale for reply. It’s little bit confusing.

When I run CommitChanges after CommitViewportChanges it somehow negates all changes done in with the CommitViewportChanges. Also some changes are not implemented when I run these methods and changes must be made separately. For example locking of the detail.

Ondřej

Hi @janotaondrej91,

The DetailView.IsProjectionLocked property is not a property on the detail view object’s viewport. Thus, calling DetailViewObject.CommitViewportChanges is not required.

import Rhino
import scriptcontext as sc

def test_lock_detail():
    filter = Rhino.DocObjects.ObjectType.Detail
    rc, objref = Rhino.Input.RhinoGet.GetOneObject("Select detail to lock", False, filter)
    if not objref or rc != Rhino.Commands.Result.Success:
        return
    
    detail_obj = objref.Object()
    if isinstance(detail_obj, Rhino.DocObjects.DetailViewObject):
        detail = detail_obj.DetailGeometry
        if detail and not detail.IsProjectionLocked:
            detail.IsProjectionLocked = True
            detail_obj.CommitChanges()
            sc.doc.Views.Redraw()
    
if __name__=="__main__":    
    test_lock_detail()

– Dale