moving tags to a TextAlignmentPoint

moving tags to a TextAlignmentPoint

Anonymous
Not applicable
463 Views
3 Replies
Message 1 of 4

moving tags to a TextAlignmentPoint

Anonymous
Not applicable

I'm working on a script to autogenerate schematics, and I'm having trouble getting tags from blocks to align properly.  I see that the attributes (from GetAttributes) has a property called "TextAlignementPoint" which is a 3D array.  I've successfully changed other attributes.  But I can't change this particular one.  I've tried both modifying each element of the array, and creating another array and copying that over to the attribute.

 

Other online examples seem to suggest this should.  However, they are all referring to a "textObj".  This may not qualify, though I would think it should.

 

Below is my subroutine.  When the tag is found, it errors out:  "Run-time error '-2145386494 (80200002)'  Not applicable"

 

Anyone have any suggestions?

 

Private Sub alignTag(ByRef myBlock As AcadBlockReference, ByVal tagType As String, ByVal pd_x As Double, ByVal pd_y As Double)
Dim varAttribs As Variant
Dim n As Integer
Dim tagPoint(0 To 2) As Double

varAttribs = myBlock.GetAttributes
For n = LBound(varAttribs) To UBound(varAttribs)
If varAttribs(n).TagString = tagType Then
tagPoint(0) = pd_x
tagPoint(1) = pd_y
varAttribs(n).TextAlignmentPoint = tagPoint  //this is the point that it errors out
End If
Next n
End Sub

0 Likes
Accepted solutions (1)
464 Views
3 Replies
Replies (3)
Message 2 of 4

TheCADnoob
Mentor
Mentor

This question may be better fielded in the section of the board designated for this type of question. 

 

http://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/bd-p/130

CADnoob

EESignature

0 Likes
Message 3 of 4

dbroad
Mentor
Mentor
Accepted solution

I am not that experienced with VBA but there could be a few issues.

 

1)It appears that you are assuming that all blocks have attributes.  It is best IMO to test for hasattributes before using getattributes.

2)You are assuming that the 3rd (z) coordinate is initialized to 0.  It is best IMO to initialize it to 0.

3)You are assuming that the textalignment point is the apropriate way to move an attribute.  It might be if the alignment property is set to anything but acAlignmentLeft but the property is locked at 0,0,0 if the left alignment is active.  An attempt to change it would probably create errors.

 

This is a relevant help file:

Architect, Registered NC, VA, SC, & GA.
Message 4 of 4

Anonymous
Not applicable

Thank you for the tips.  I am of course new at doing this VBA to autocad interface.

 

And your option 2 solved my problem.  I just needed to define the z coordinate.

 

Thanks!

 

0 Likes