Visual Basic Customization

Visual Basic Customization

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

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

231 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

 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.

Valued Mentor
AubelecBE
Posts: 394
Registered: ‎01-27-2010
Message 2 of 5 (210 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 (201 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
muckmailer
Posts: 128
Registered: ‎05-10-2009
Message 4 of 5 (192 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
AubelecBE
Posts: 394
Registered: ‎01-27-2010
Message 5 of 5 (168 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.  

 

.

Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.