Quantcast
Channel: Scripting - McNeel Forum
Viewing all articles
Browse latest Browse all 5938

How check wether block content did change at InstanceDefinitionTableEvent

$
0
0

Hi There,

I am looking for an efficient way to determine whether the contents of a block have actually changed, after a InstanceDefinitionTableEvent has been triggered.

It seems to doubleclick a blockinstance and close the block edit dialog, even when geometry was not changed, always triggers an event with event.EventType = Rhino.RhinoDoc.Tables.InstanceDefinitionTableEventType.Modified

Is there a method that tells me wether the actual geometry has changed, without having to check each rhino object inside OldState and NewState for equality? (see the code snippet below for the methods I tried)

I hope you can help me out.

Best regards,
Tim


def AutoUpdateEvent(sender, e):


    # only trigger at 'Modified' event type. Not at 'Added' event"
    if str(e.EventType) == 'Modified':

        old_def_geometry = e.OldState
        new_def = e.NewState

        # this method always returns "False", also when content did NOT change
        print 'equals', new_def.Equals(old_def_geometry)

        # This method always returns "True", also when content did change
        json_old = old_def_geometry.ToJSON(Rhino.FileIO.SerializationOptions())
        json_new = old_def_geometry.ToJSON(Rhino.FileIO.SerializationOptions())
        print 'equal json', json_old == json_new

        # this method always returns "False", 
        # appearently the object ids are always updated after "BeginEdit+EndEdit"
        equal = True
        objs_new = new_def.GetObjectIds()
        objs_old = old_def_geometry.GetObjectIds()
        if not set(objs_new) == set(objs_old):
            equal = False
        print 'ids equal', equal
        

1 post - 1 participant

Read full topic


Viewing all articles
Browse latest Browse all 5938

Trending Articles