Is anyone still here ?
Trying to delete selected layers from blocks in PY
rs.DeleteObject(Guid)
Won’t work
DeleteLayerFromBlock_notworking.py (2.3 KB)
Is anyone still here ?
Trying to delete selected layers from blocks in PY
rs.DeleteObject(Guid)
Won’t work
DeleteLayerFromBlock_notworking.py (2.3 KB)
Moved to a new topic…
Dear Dale
I Can’t manage to find this new topic
@Karim_tabbara - you should see this link jist above:
Add Object to Block Python (bypass block edit)
Not sure this is what you’re after, but I’ve attached a simple “merge layer” sample for you to review.
MergeLayers.py (2.7 KB)
– Dale
Dear Dale
Yes I have used [quote=“Dale Fugier, post:4, topic:173505, username:dale”]
MergeLayers.py (2.7 KB)
Even modified it so it can handle merging layers in blocks
MergeLayersAndBlockLayers_v01.py (2.4 KB)
But found no way to delete objects from blocks, even re-using code in following scripts
Not good enough in PY
My code doesn’t work
rs.DeleteObject does nothing
I guess (kind of understood) I have to rebuild the block with it’s elements removing the elements to be deleted…
if V_BlockNames :
for V_BlockName in V_BlockNames :
# Get Ids in block
V_Ids = rs.BlockObjects(V_BlockName)
# Parse Ids in block
for V_Id in V_Ids :
# Get Object
V_Object = doc.Objects.Find(V_Id)
# Get object attributes
V_attributes = V_Object.Attributes
# Get object layer Index
V_Layer_index = V_attributes.LayerIndex
# Check entitie layer has to be changed
if V_Layer_index in sources:
# Delete Object
rs.DeleteObject(V_Object)
pass
Hi @Karim_tabbara,
The proper way to delete (or redefine) an existing instance definition is to use one of the InstanceDefinitionTable.ModifyGeometry methods.
– Dale
Thanks Dale
I’ll “compute” all that in my little brain.