finding lookup parameters for dynamic blocks

finding lookup parameters for dynamic blocks

Anonymous
Not applicable
1,022 Views
3 Replies
Message 1 of 4

finding lookup parameters for dynamic blocks

Anonymous
Not applicable

Does anybody know if it is possible from VBA to find the values entered in a lookup parameter when standing in the block editor ?

0 Likes
1,023 Views
3 Replies
Replies (3)
Message 2 of 4

norman.yuan
Mentor
Mentor

You can use AcadBlockreference.GetDynamicBlockProperties() method to get an array of dynamic properties of a dynamic block reference. Then you loop through the properties to find your target property (by its PropertyName, usually). If it is an lookup parameter, you can then get the lookup list from the dynamic property's AllowedValues.

 

Here is sample code working against a dynamic block, which has a lookup parameter called "MyLookup", which has a few values defined in the lookup list:

 

Option Explicit

Public Sub SetBlock()

    Dim ent As AcadEntity
    Dim pt As Variant
    Dim blk As AcadBlockReference
    Dim props As Variant
    Dim i As Integer
    Dim j As Integer
    Dim prop As AcadDynamicBlockReferenceProperty
    
    ThisDrawing.Utility.GetEntity ent, pt, vbCr & "Select a dynamic block:"
    If ent Is Nothing Then Exit Sub
    
    If TypeOf ent Is AcadBlockReference Then
    
        Set blk = ent
        If blk.IsDynamicBlock Then
        
            props = blk.GetDynamicBlockProperties
            
            For i = 0 To UBound(props)
                Set prop = props(i)
                ''MsgBox prop.PropertyName
                If UCase(prop.PropertyName) = "MYLOOKUP" Then
                    For j = 0 To UBound(prop.AllowedValues)
                        MsgBox "Lookup Value " & (j + 1) & " = " & CStr(prop.AllowedValues(j))
                    Next
                End If
            Next
        
        End If
    
    End If
    
End Sub

 

Norman Yuan

Drive CAD With Code

EESignature

0 Likes
Message 3 of 4

Anonymous
Not applicable

Hi thanks for the reply, but I probably did not explain myself well enough.
 
What I seek is a way - through vba - to find the data that is entered in the lookup element under the definition of the dynamic block, and to be able to correct them.

 

In other words while I stand in the block editor and has 3 lookup current objects.

 

The method you show I use in a different context.

 

My goal is to help the user who creates the dynamic blocks so that he can enter the lookup data which are quite difficult to calculate.

0 Likes
Message 4 of 4

norman.yuan
Mentor
Mentor

If you want is API exposed for creating/defining dynamic block (its dynamic properties), then no, no such API available. Being AutoCAD user/customer, one can only create/define dynamic block MANUALLY inside AutoCAD's Block Editor.

Norman Yuan

Drive CAD With Code

EESignature

0 Likes