Get Visibility States of Visibility Parameter of Dynamic Block

Get Visibility States of Visibility Parameter of Dynamic Block

tim11_manhhieu
Advocate Advocate
291 Views
1 Reply
Message 1 of 2

Get Visibility States of Visibility Parameter of Dynamic Block

tim11_manhhieu
Advocate
Advocate

Hi all, i am trying to get all Visibility States (1 and 2) of parameter "Visibility1" of dynamic block. 

Show message box for example.

Any one have example code?

 

tim11_manhhieu_0-1736388059175.png

 

 

0 Likes
Accepted solutions (1)
292 Views
1 Reply
Reply (1)
Message 2 of 2

tim11_manhhieu
Advocate
Advocate
Accepted solution

i found it. vba code for who need.

 

Option Explicit

Sub ListVisibilityStates()

    Dim blockRef As AcadBlockReference
    Dim visProp As AcadDynamicBlockReferenceProperty
    Dim visProps() As AcadDynamicBlockReferenceProperty
    Dim entity As acadEntity
    Dim basePoint As Variant
    Dim state As Variant
    Dim i As Integer

    On Error Resume Next
    ThisDrawing.Utility.GetEntity entity, basePoint, "Pick dynamic block: "
    On Error GoTo 0

        If TypeOf entity Is AcadBlockReference Then
        
            Set blockRef = entity

            If blockRef.IsDynamicBlock Then
            
                visProps = blockRef.GetDynamicBlockProperties
                
                    For i = 0 To UBound(visProps)
                    
                        Set visProp = visProps(i)
                        
                        If visProp.PropertyName = "Visibility1" Then
                        
                            For Each state In visProp.AllowedValues()
                                MsgBox state
                            Next state
                            Exit For
                        
                        End If
                        
                    Next i
                    
            End If

        End If

End Sub