TroutKing Posted November 30, 2009 Share Posted November 30, 2009 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 Quote Link to comment Share on other sites More sharing options...
SteveK Posted December 1, 2009 Share Posted December 1, 2009 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? Quote Link to comment Share on other sites More sharing options...
fixo Posted December 1, 2009 Share Posted December 1, 2009 Visual Basic questionUsing 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'~ Quote Link to comment Share on other sites More sharing options...
SteveK Posted December 1, 2009 Share Posted December 1, 2009 **phew** I was hoping the heavy artillery would arrive soon. :wink: Quote Link to comment Share on other sites More sharing options...
fixo Posted December 1, 2009 Share Posted December 1, 2009 **phew** I was hoping the heavy artillery would arrive soon. :wink: C'mon You make me laugh Ta ~'J'~ Quote Link to comment Share on other sites More sharing options...
TroutKing Posted December 1, 2009 Author Share Posted December 1, 2009 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 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.