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
Solved! Go to Solution.
Solved by bojko108. Go to Solution.
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.
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.
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.
.