Jump to content

Dynamic Block attribute Visibility with VBA


Recommended Posts

Posted

AutoCAD 2010

 

I have created a Dynamic Block with various visibility states.

The block has attributes in that are not displayed depending on which

visibility state that is selected.

Is there a way for VBA to look at attributes in my dynamic block and

tell which attributes are visible? Does anyone have any code demonstrating this?

Thank you,

  • 4 weeks later...
Posted

Have you tried testing the attribute's non-dynamic property?

 

AcadAttributeReference object, Visible property?

 

Something like......

Private Function IsAttVis(objID As Long, attName As String) As Boolean
'You'll want to get the object ID and Attribute name to pass it to this function
Dim objEnt As AcadEntity
Dim objRef As AcadBlockReference
Dim objAttRef As AcadAttributeReference
Set objEnt = ThisDrawing.ObjectIdToObject(objID)
   If TypeOf objEnt Is AcadBlockReference Then
       Set objRef = objEnt
       Set objEnt = Nothing
           For Each objEnt In objRef
               If TypeOf objEnt Is objAttRef Then
                   Set objAttRef = objEnt
                   
                       If objAttRef.ObjectName = attName Then
                       
                           If objAttRef.Visible = True Then
                               IsAttVis = True
                           Else
                               IsAttVis = False
                           End If
                           
                       End If
                       
                   Set objAttRef = Nothing
               End If
               
           Next
           
       Set objRef = Nothing
   End If
   
Set objEnt = Nothing
End Function

 

The above is untested so the objEnt heirarchy may fail--I can't remember if it will work this way.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...