Hi, do you think it is possible now to get and set visibility states for Dynamic Blocks in Dynamo for Civil 3D?
Hi, I found this: How to access and modify a DynamicBlockReference property in ARX and .Net? - AutoCAD DevBlog
Is here anyone who solved this already in Python please?
Hi,
a rapid test with CADPythonShell
import clr
import System
clr.AddReference('acmgd')
clr.AddReference('acdbmgd')
clr.AddReference('accoremgd')
# Import references from AutoCAD
from Autodesk.AutoCAD.Runtime import *
from Autodesk.AutoCAD.ApplicationServices import *
from Autodesk.AutoCAD.EditorInput import *
from Autodesk.AutoCAD.DatabaseServices import *
from Autodesk.AutoCAD.Geometry import *
doc = Application.DocumentManager.MdiActiveDocument
ed = doc.Editor
db = doc.Database
# Write Code Below
# name and value property to set dynamic block
namePropVisu = 'Visibilité1'
valuePropVisu = 'Type D'
with doc.LockDocument():
with doc.Database as db:
with db.TransactionManager.StartTransaction() as t:
bt = t.GetObject(db.BlockTableId,OpenMode.ForRead)
btr = t.GetObject(bt[BlockTableRecord.ModelSpace],OpenMode.ForRead)
for objectid in btr:
blkRef = t.GetObject(objectid, OpenMode.ForRead)
if isinstance(blkRef, BlockReference):
if blkRef.IsDynamicBlock:
block = t.GetObject(blkRef.DynamicBlockTableRecord, OpenMode.ForRead)
blkName = block.Name
props = blkRef.DynamicBlockReferencePropertyCollection
for prop in props:
values = prop.GetAllowedValues()
print(("values", values))
print("PropertyName", prop.PropertyName)
if prop.PropertyName == namePropVisu and not prop.ReadOnly:
idx = System.Array.IndexOf(values, valuePropVisu)
print("Value", prop.Value)
print("idx", idx)
prop.Value = values[idx]
t.Commit()
Hi, at this moment I have the goal to get solid from visibility state which is currently set in model space and create solid geometry in Dynamo. I tried to edit your code but I have some errors and I do not know how to continue. Could you give me any hint please?
Hi @Drbohlav
I admit that I have no idea how to get the geometry of a dynamic block
@Drbohlav
Try node block.objects or you need changing python code
Can you attached example drawing for testing
Hi @hosneyalaa,
here is example. I’m looking for solution how to get geometry for current visibility. Is here anyne who can help with solution?
Block.dwg (518.6 KB)
D4C3D_block.dyn (18.9 KB)