ACAD 2006 - Dynamic Block Properties

Discussion in 'AutoCAD' started by Colin French, Mar 8, 2005.

  1. Colin French

    Colin French Guest

    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
     
    Colin French, Mar 8, 2005
    #1
  2. 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
     
    Ravi Pothineni, Mar 11, 2005
    #2
  3. Colin French

    Colin French Guest

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

    ...Colin French
     
    Colin French, Mar 14, 2005
    #3
  4. Colin French

    JMSchmidt Guest

    Is there a way to get the actions of a DynamicBlockProperty in a dynamic block too?
     
    JMSchmidt, Apr 7, 2005
    #4
  5. 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.
     
    Ravi Pothineni, Apr 8, 2005
    #5
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.