Change Block Attribute Insertion point

Change Block Attribute Insertion point

Anonymous
Not applicable
3,117 Views
7 Replies
Message 1 of 8

Change Block Attribute Insertion point

Anonymous
Not applicable
In need to modify an attributes insertion point in an existing block (ACAD 2002)

(part code)

CurrInsrt = attr.InsertionPoint
insrt(0) = 100 + CurrInsrt(0)
insrt(1) = 100+ CurrInsrt(1)
insrt(2) = 0 + CurrInsrt(2)
attr.InsertionPoint= insrt

dosen't work and I can't figure out why. CurrInsrt is a variant, insrt is a double(0 to 2)


I saw the entry about using TextAlignmentPoint but if the attribute is rotated it is rotated around the insertion point not the TextAlignmentPoint

phill
0 Likes
3,118 Views
7 Replies
Replies (7)
Message 2 of 8

Anonymous
Not applicable
Do it in cad first then code it.
If you are updating the block, you still have to reinsert all the blockreferences to see the new attribute positions, just like doing it in cad.If you are finding each blockreference and moving the att without updating the block, you better read up on matricies
0 Likes
Message 3 of 8

Anonymous
Not applicable
Yes I am updating it with attr.update.

But as far as I cantell I am essentially following the example in the help file

I have tested the other lines and all seems correct.

"attr.InsertionPoint= insrt
attr.update"

is not working and I can't figure out why
0 Likes
Message 4 of 8

Anonymous
Not applicable
Are you modifying the block definition or each individual block reference. If you are modifying the def only then in AutoCAD try the command ATTSYNC.

Regards - Nathan
0 Likes
Message 5 of 8

Anonymous
Not applicable
I am actually just trying to change each block reference attribute individually.

the way I have been doing it is by using the move command to reposition the attribute.

Is the insertionpoint property a global thing ie applies to the block not the block referenece? that would mean i'd have to sync it for the changes to take affect. In which case I won't use it because the changes will be applied to all blocks

Phill
0 Likes
Message 6 of 8

arcticad
Advisor
Advisor
I'm sure there is an easier way but this has worked fine for me.

You just need to set the xyz of the attribute. You do not use move.

since you can't reference the insertionpoint with att.insertionpoint(0) i just run it through a simple convertion

dim pt(2) as double
pt(0) = convertpt(att.insertionpoint,0)
pt(1) = convertpt(att.insertionpoint,1)
pt(2) = convertpt(att.insertionpoint,2)

then you can just add say an x distance to the value or whatever to move the attributes around.

then assign the new point to your att.insertionpoint

[code]

Function convertpt(pt, pos) As Variant
Dim k As Integer
Dim newpt(2) As Double
For Each item In pt
If j = pos Then
k = k + 1
If k = 1 Then
convertpt = item
End If
If k = 2 Then
convertpt = item
End If
If k = 3 Then
convertpt = item
End If
End If
j = j + 1
Next

End Function

[/code]
---------------------------



(defun botsbuildbots() (botsbuildbots))
0 Likes
Message 7 of 8

Anonymous
Not applicable
Hi Poflynn
I am not sure but try to regenerate your drawing at end of your code might be it work.
Thanks
0 Likes
Message 8 of 8

Anonymous
Not applicable
Guess I was wrong about matricies for the 2d stuff

[code]Sub moveatt(B As AcadBlockReference, Dist As Double)

Dim Att As AcadAttributeReference
Dim Atts, Pt
Dim Rot As Double

Set B = EntSel
Atts = B.GetAttributes
Set Att = Atts(0)
' Att.LockPosition check that
Rot = Att.Rotation
Pt = Att.TextAlignmentPoint
Pt(0) = Pt(0) + Cos(Rot) * Dist
Pt(1) = Pt(1) + Sin(Rot) * Dist
Att.TextAlignmentPoint = Pt

End Sub
[/code]
0 Likes