Visual Basic Customization

Reply
Distinguished Contributor
Posts: 117
Registered: ‎05-10-2009
Message 1 of 5 (212 Views)
Accepted Solution

Using varAttribs(intI).LockPosition = False to make block attributes movable

212 Views, 4 Replies
03-13-2011 09:50 AM

I have been using varAttribs(intI).LockPosition = False in the follow code to  try to make attributes movable in a block

referece without any luck. Is there any way to use vba to make attributes movable in a block?

Thank you,

 

public Sub TestGetAttributes()
Dim varPick As Variant
Dim objEnt As AcadEntity
Dim objBRef As AcadBlockReference
Dim varAttribs As Variant
Dim strAttribs As String
Dim intI As Integer
On Error Resume Next
With ThisDrawing.Utility
'' get an entity from user
.GetEntity objEnt, varPick, vbCr & "Pick a block with attributes: "
If Err Then Exit Sub
'' cast it to a blockref
Set objBRef = objEnt
'' exit if not a block
If objBRef Is Nothing Then
.Prompt vbCr & "That wasn't a block."
Exit Sub
End If
'' exit if it has no attributes
If Not objBRef.HasAttributes Then
.Prompt vbCr & "That block doesn't have attributes."
Exit Sub
End If
'' get the attributerefs
varAttribs = objBRef.GetAttributes
'' show some information about each
strAttribs = "Block Name: " & objBRef.Name & vbCrLf
For intI = LBound(varAttribs) To UBound(varAttribs)

strAttribs = strAttribs & " Tag(" & intI & "): " & _
varAttribs(intI).TagString & vbTab & " Value(" & intI & "): " & _
varAttribs(intI).TextString & vbCrLf
Debug.Print varAttribs(intI).LockPosition
'Does not work

varAttribs(intI).LockPosition = False
Debug.Print varAttribs(intI).LockPosition
'MsgBox varAttribs(intI).LockPosition
Next
End With
MsgBox strAttribs
End Sub

Valued Mentor
Posts: 354
Registered: ‎01-27-2010
Message 2 of 5 (191 Views)

Re: Using varAttribs(intI).LockPosition = False to make block attributes movable

03-14-2011 04:39 AM in reply to: muckmailer

hi.

 

so i checked in the base of acad . (F2 in vba) and try to look for lockposition in then acadattributreference --> it is read only.

 

so you cant change if you use a attributreférence of block

 

you need tou use with AcadAttribut if you want modify.

 

 

 

 

Valued Contributor
bojko108
Posts: 61
Registered: ‎01-23-2011
Message 3 of 5 (182 Views)

Re: Using varAttribs(intI).LockPosition = False to make block attributes movable

03-14-2011 07:18 AM in reply to: muckmailer

 AubelecBE is right you can't edit this property in place. I attach one solution. Procedure change LockPosition propertie and then update each block, inserted in drawing.

Distinguished Contributor
Posts: 117
Registered: ‎05-10-2009
Message 4 of 5 (173 Views)

Re: Using varAttribs(intI).LockPosition = False to make block attributes movable

03-14-2011 12:22 PM in reply to: bojko108

Thanks bojko

  

Your code works well, nice job.

 

Muckmail

Valued Mentor
Posts: 354
Registered: ‎01-27-2010
Message 5 of 5 (149 Views)

Re: Using varAttribs(intI).LockPosition = False to make block attributes movable

03-16-2011 04:24 AM in reply to: bojko108

in this prog. you have to add the proc for check if the bloc is not a Xref and if the attribut can modif.

 

and one more thing : you can't use it for the bloc dynamic.  

 

.

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Announcements
Are you interested in helping shape the Autodesk Community?
We’re looking at a few different ways to improve the “All Forums” landing page and need your feedback! If interested, please take a few minutes to fill out the following Usability Study. Thank you for your time!

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community