VBA
Discuss AutoCAD ActiveX and VBA (Visual Basic for Applications) questions here.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

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

4 REPLIES 4
SOLVED
Reply
Message 1 of 5
muckmailer
509 Views, 4 Replies

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

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

4 REPLIES 4
Message 2 of 5
AubelecBE
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.

 

 

 

 

Message 3 of 5
bojko108
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.

Message 4 of 5
muckmailer
in reply to: bojko108

Thanks bojko

  

Your code works well, nice job.

 

Muckmail

Message 5 of 5
AubelecBE
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.  

 

.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

”Boost