aleair Posted November 25, 2010 Posted November 25, 2010 (edited) Hi everybody, I'm new with autocad. Actually it's my first time I need to write a VBA procedure for autocad. That's the reason why I'm posting this thread. I have blocks with attribute. In one of this attribute I want to insert an expression that calculates a polyline area. Doing it manually works. the expression is: "%%).Area>%" where 2130001176 is the ObjectID of the specific poly. I tried to insert the expression via vba with this code: attArr = oBlkRef.GetAttributes attArr(3).TextString = "%%).Area>%" It doesn't work and the value (corresponding to the poly area) is not calculated. Only "####" is shown as value. Any idea how to insert the expression via VBA? Edited November 25, 2010 by aleair error Quote
BIGAL Posted December 1, 2010 Posted December 1, 2010 I think you need 2 extra line area ="%%).Area>%" attArr(3).TextString = area attarr(3).update found this Sub Example_Area() ' This example creates a polyline object and ' then uses the area property to find the ' area of that polyline. Dim plineObj As AcadLWPolyline Dim points(0 To 5) As Double Dim plineArea As Double ' Establish the points for the Polyline points(0) = 3: points(1) = 7 points(2) = 9: points(3) = 2 points(4) = 3: points(5) = 5 ' Create the polyline in modelspace Set plineObj = ThisDrawing.ModelSpace.AddLightWeightPolyline(points) ' Close the polyline and update display of it plineObj.Closed = True plineObj.Update ZoomAll ' Get the area of the polyline plineArea = plineObj.Area MsgBox "The area of the new Polyline is: " & plineArea, vbInformation, "Area Example" End Sub Quote
aleair Posted December 1, 2010 Author Posted December 1, 2010 found solution, thanks. Attrib.TextString = "%%).Area \f " & Chr(34) & "%lu2" & Chr(34) & ">%" where Cstr(id) is poly objectID Quote
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.