ACAD 2006 - Dynamic Block Properties

  • Thread starter Thread starter Colin French
  • Start date Start date
C

Colin French

For those using the ACAD 2006 Beta, and have been allowed to post some sneak preview info - can you programatically access properties of Dynamic Blocks? E.g. if the user streches that boardroom table block from 8 feet to 12 feet, can I access a property that tells me the current length? Or the number of chairs it now has around it? (So our automated take-offs which form the basis of an order to the furniture supplier will come out right.)

Inquiring minds want to start musing over the possibilites... <grin>

...Colin French
 
Yes, you can. Here is some code to get you started.



Sub test()

'Documents.Open "C:\Program Files\AutoCAD 2006\Sample\Blocks and
Tables - Imperial.dwg"

Dim ent As AcadEntity

For Each ent In ThisDrawing.ModelSpace

If ent.ObjectName = "AcDbBlockReference" Then

Dim oBkRef As IAcadBlockReference2

Set oBkRef = ent

If oBkRef.IsDynamicBlock = True Then

Dim v As Variant

v = oBkRef.GetDynamicBlockProperties

Dim i As Long

For i = LBound(v) To UBound(v)

Dim oDynProp As AcadDynamicBlockReferenceProperty

Set oDynProp = v(i)

Debug.Print oDynProp.PropertyName

If IsArray(oDynProp.Value) Then

Dim j As Long

For j = LBound(oDynProp.Value) To
UBound(oDynProp.Value)

Debug.Print oDynProp.Value(j)

Next j

Else

Debug.Print oDynProp.Value

End If

Next

End If

End If

Next ent

End Sub
 
Excellent! Thanks very much for the sample code, Ravi. Now I can start scheming about how to use them in our group.

...Colin French
 
Is there a way to get the actions of a DynamicBlockProperty in a dynamic block too?
 
What do you mean by "get the actions of a DynamicBlockProperty"? If you want
to modify the block definition then you are out of luck.

You can only set/get per instance property values of dynamic blocks.
 
Back
Top