Jump to content

text alignment point question rephrased


TroutKing

Recommended Posts

Visual Basic question

Using AutoCAD 2009

 

Hi again,

 

Maybe I should try to rephrase my earlier question(s) since I didn’t get any response. I suppose my question was a bit convoluted. Here is a simplified version of what I would like help understanding.

 

As I loop through attributes placed in a title block:

 

1. How do I identify the text alignment point of an attribute that is already placed within a drawing? (“attObj.TextAlignmentPoint” doesn’t return a value that I can compare)

2. How do I identify the insertion point of an attribute that is already placed within a drawing? (“attObj. InsertionPoint” doesn’t return a value that I can compare)

 

Can someone help me?

 

Thank you,

Mike

Link to comment
Share on other sites

I haven't used vb in autocad, only lisp, but maybe I can guess that when you say it doesn't return a value you can compare you mean it comes out as a variant?? If not, then I'm stuck, otherwise you'll need to find a function that converts from a variant->list or similar. Alternatively if you don't need to know the point you can just use the variant in further code. Sorry if that's no help to you. Does vb have some sort of apropos you can use that describes functions?

Link to comment
Share on other sites

Visual Basic question

Using AutoCAD 2009

 

Hi again,

 

Maybe I should try to rephrase my earlier question(s) since I didn’t get any response. I suppose my question was a bit convoluted. Here is a simplified version of what I would like help understanding.

 

As I loop through attributes placed in a title block:

 

1. How do I identify the text alignment point of an attribute that is already placed within a drawing? (“attObj.TextAlignmentPoint” doesn’t return a value that I can compare)

2. How do I identify the insertion point of an attribute that is already placed within a drawing? (“attObj. InsertionPoint” doesn’t return a value that I can compare)

 

Can someone help me?

 

Thank you,

Mike

Hi, Mike!

 

Take a look at this simple example

Hope it will make a sense

 

Sub getAttProps()
   Dim BlockRef As AcadBlockReference
   Dim varPt As Variant
   Dim subEnt As Object
   Dim oAttRef As AcadAttributeReference
   Dim insPt As Variant
   Dim algnPt As Variant
   Dim align As Integer
   Dim tmax, cxdata
   ThisDrawing.Utility.GetSubEntity subEnt, varPt, tmax, cxdata, vbLf & "Select a block subentity"

   If TypeOf subEnt Is AcadAttributeReference Then
       Set oAttRef = subEnt
       insPt = oAttRef.InsertionPoint
       algnPt = oAttRef.TextAlignmentPoint
       align = oAttRef.Alignment
       MsgBox "Alignment: " & align & vbCr & _
              "Insertion Point: " & CStr(Round(insPt(0), 2)) & "," & CStr(Round(insPt(1), 2)) & "," & CStr(Round(insPt(2), 2)) & vbCr & _
              "TextAlignmentPoint Point: " & CStr(Round(algnPt(0), 2)) & "," & CStr(Round(algnPt(1), 2)) & "," & CStr(Round(algnPt(2), 2))
   End If
End Sub

 

~'J'~

Link to comment
Share on other sites

Hi guys,

 

Thank you very much for the help. I scratched my head and beat it on the keyboard last night for a couple hours after the office was dark and came up with something that worked for me (see below).

 

I think I can study the code you provided Fixo and hopefully clean up the work that I have so far.

 

This is what I came up with:

 
For Each oLayout In adoc.Layouts
   For Each oEnt In oLayout.Block
       If TypeOf oEnt Is AcadBlockReference Then
       Set blkRefObj = oEnt
           If StrComp(blkRefObj.Name, OriginalTitleblock, vbTextCompare) = 0 Then
           attArr = blkRefObj.GetAttributes
               For k = 0 To UBound(attArr)
               Set attObj = attArr(k)

               ka = Left(attObj.TextAlignmentPoint(0), 11)
               kb = Left(attObj.TextAlignmentPoint(1), 10)
               kc = attObj.TextAlignmentPoint(2)
               kx = Left(attObj.InsertionPoint(0), 11)
               ky = Left(attObj.InsertionPoint(1), 10)
               kz = attObj.InsertionPoint(2)
               k_TextAlignmentPoint = ka & "," & kb & "," & kc
               k_InsertionPoint = kx & "," & ky & "," & kz

                   If StrComp(k_TextAlignmentPoint, OriginalTextAlignmentPoint_1, vbTextCompare) = 0 Then
                       a1 = attObj.TextString

 

Thank you again very much for your help!

Mike

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...