woojsung
(Woojae Sung)
September 13, 2023, 3:53am
1
Hi,
I am trying to delete an instance definition (not the block instance in the rhino doc, but the definition itself) in c#. I tried RhinoDoc.ActiveDoc.InstanceDefinitions.Clear(), which successfully purged all instance definitions. However, this clears everything in the document. How can I selectively clear an instance definition?
Thanks,
W
djordje
September 13, 2023, 6:04am
2
Hi @woojsung ,
There is InstanceDefinitionTable.Delete method overload which has parameter enabling deletion of all its instances and definition itself.
Let me know if I need to attach python example.
woojsung
(Woojae Sung)
September 13, 2023, 7:02am
3
Hi @djordje ,
Thanks for the comment. If you can share the example, that would be much appreciated. Thanks,
W
djordje
September 13, 2023, 7:09am
4
Yes, of course:
blName = 'test block 2'
# a) get block definition obj
ignoreDeletedInstancDef = False
blDef = Rhino.RhinoDoc.ActiveDoc.InstanceDefinitions.Find(blName, ignoreDeletedInstancDef)
# b) delete all block instances and then block definition itself
blDef_inx = blDef.Index
deleteReferences = True # this deletes all instances first
quiet = False
succ = Rhino.RhinoDoc.ActiveDoc.InstanceDefinitions.Delete(blDef_inx, deleteReferences, quiet)
1 Like
woojsung
(Woojae Sung)
September 13, 2023, 7:14am
5
@djordje ,
Thank you for the script! One more question: What is the difference between Delete and Clear?
Thanks much,
W
djordje
September 13, 2023, 7:17am
6
Hi @woojsung ,
I’ve never used InstanceDefinitions.Clear. Maybe someone else knows.
woojsung
(Woojae Sung)
September 13, 2023, 7:29am
7
Hi @djordje ,
I see. Thank you for the tip, really appreciate it!
W
1 Like