Andresig Posted July 10, 2009 Share Posted July 10, 2009 I started a routine to add dimensions to polyline... The problem is that is created over the line and I want to create it separated from the line, If some one can help me with this will be awesome... thanks, Sub add_dim_polyline() 'to add Panel Dimensions Dim ThePolyline As AcadLWPolyline Dim polyCoords As Variant Dim getPoint As Variant Dim a As Integer Dim polyCoordBound As Integer Dim stPoint(2) As Double Dim ePoint(2) As Double Dim sectionAngle As Double Dim textCoords As Variant Dim polyDist As Double Dim x1, x2, y1, y2 As Double Dim objDimAligned As AcadDimAligned ThisDrawing.Utility.GetEntity ThePolyline, getPoint, "Select an object" polyCoords = ThePolyline.Coordinates polyCoordBound = UBound(polyCoords) For a = 0 To polyCoordBound - 1 Step 2 If a = polyCoordBound - 1 Then stPoint(0) = polyCoords(a) stPoint(1) = polyCoords(a + 1) stPoint(2) = 0 ePoint(0) = polyCoords(0) ePoint(1) = polyCoords(1) ePoint(2) = 0 Else stPoint(0) = polyCoords(a) stPoint(1) = polyCoords(a + 1) stPoint(2) = 0 ePoint(0) = polyCoords(a + 2) ePoint(1) = polyCoords(a + 3) ePoint(2) = 0 End If x1 = stPoint(0): x2 = ePoint(0) y1 = stPoint(1): y2 = ePoint(1) polyDist = Sqr(((x1 - x2) ^ 2) + ((y1 - y2) ^ 2)) sectionAngle = ThisDrawing.Utility.AngleFromXAxis(stPoint, ePoint) textCoords = ThisDrawing.Utility.PolarPoint(stPoint, sectionAngle, polyDist / 2) Set objDimAligned = ThisDrawing.ModelSpace.AddDimAligned(stPoint, ePoint, textCoords) Next a End Sub Quote Link to comment Share on other sites More sharing options...
SEANT Posted July 10, 2009 Share Posted July 10, 2009 Perhaps something like the addition shown here. sectionAngle = ThisDrawing.Utility.AngleFromXAxis(stPoint, ePoint) textCoords = ThisDrawing.Utility.PolarPoint(stPoint, sectionAngle, polyDist / 2) textCoords = ThisDrawing.Utility.PolarPoint(textCoords, sectionAngle + 1.57, 1#) 'Rotate PI/2 Set objDimAligned = ThisDrawing.ModelSpace.AddDimAligned(stPoint, ePoint, textCoords) Quote Link to comment Share on other sites More sharing options...
Andresig Posted July 10, 2009 Author Share Posted July 10, 2009 Sub add_dim_polyline() 'to add Panel Dimensions Dim ThePolyline As AcadLWPolyline Dim polyCoords As Variant Dim getPoint As Variant Dim a As Integer Dim polyCoordBound As Integer Dim stPoint(2) As Double Dim ePoint(2) As Double Dim sectionAngle As Double Dim textCoords As Variant Dim polyDist As Double Dim x1, x2, y1, y2 As Double Dim objDimAligned As AcadDimAligned Dim textAngle As Double ThisDrawing.Utility.GetEntity ThePolyline, getPoint, "Select an object" polyCoords = ThePolyline.Coordinates polyCoordBound = UBound(polyCoords) For a = 0 To polyCoordBound - 2 Step 2 stPoint(0) = polyCoords(a) stPoint(1) = polyCoords(a + 1) stPoint(2) = 0 ePoint(0) = polyCoords(a + 2) ePoint(1) = polyCoords(a + 3) ePoint(2) = 0 x1 = stPoint(0): x2 = ePoint(0) y1 = stPoint(1): y2 = ePoint(1) polyDist = Sqr(((x1 - x2) ^ 2) + ((y1 - y2) ^ 2)) sectionAngle = ThisDrawing.Utility.AngleFromXAxis(stPoint, ePoint) textAngle = sectionAngle + 1.57 textCoords = ThisDrawing.Utility.PolarPoint(stPoint, sectionAngle + 1.57, 1#) Set objDimAligned = ThisDrawing.ModelSpace.AddDimAligned(stPoint, ePoint, textCoords) Next a End Sub Quote Link to comment Share on other sites More sharing options...
goldy2000 Posted July 13, 2009 Share Posted July 13, 2009 Heyy, I just saw this post, can someone of you tell me what is this VBA about?? When drawing polyline it shows and writes distance up to line or..?? Quote Link to comment Share on other sites More sharing options...
SEANT Posted July 13, 2009 Share Posted July 13, 2009 Actually, the structure of the routine is to select a polyline and automatically add dimensions to it. Quote Link to comment Share on other sites More sharing options...
goldy2000 Posted July 13, 2009 Share Posted July 13, 2009 Sounds good, I have something similiar lisp, you select polyline and it puts dimension on it (between two dots on pline, and so on along line), how you use VBA?? never done that so I'm curious...in few words if you have time to write how to start it.. Quote Link to comment Share on other sites More sharing options...
Andresig Posted July 13, 2009 Author Share Posted July 13, 2009 Sounds good, I have something similiar lisp, you select polyline and it puts dimension on it (between two dots on pline, and so on along line), how you use VBA?? never done that so I'm curious...in few words if you have time to write how to start it.. I'm still not permitted to stamp addresses but google "autocad vba" and will appear some hyperpics dot com page with an introduction of vba Quote Link to comment Share on other sites More sharing options...
goldy2000 Posted July 14, 2009 Share Posted July 14, 2009 I'm still not permitted to stamp addresses but google "autocad vba" and will appear some hyperpics dot com page with an introduction of vba Ok, understand...Thx man!!! Quote Link to comment Share on other sites More sharing options...
iyant Posted January 29, 2014 Share Posted January 29, 2014 I started a routine to add dimensions to polyline... The problem is that is created over the line and I want to create it separated from the line, If some one can help me with this will be awesome... thanks, Sub add_dim_polyline() 'to add Panel Dimensions Dim ThePolyline As AcadLWPolyline Dim polyCoords As Variant Dim getPoint As Variant Dim a As Integer Dim polyCoordBound As Integer Dim stPoint(2) As Double Dim ePoint(2) As Double Dim sectionAngle As Double Dim textCoords As Variant Dim polyDist As Double Dim x1, x2, y1, y2 As Double Dim objDimAligned As AcadDimAligned ThisDrawing.Utility.GetEntity ThePolyline, getPoint, "Select an object" <--??? polyCoords = ThePolyline.Coordinates polyCoordBound = UBound(polyCoords) For a = 0 To polyCoordBound - 1 Step 2 If a = polyCoordBound - 1 Then stPoint(0) = polyCoords(a) stPoint(1) = polyCoords(a + 1) stPoint(2) = 0 ePoint(0) = polyCoords(0) ePoint(1) = polyCoords(1) ePoint(2) = 0 Else stPoint(0) = polyCoords(a) stPoint(1) = polyCoords(a + 1) stPoint(2) = 0 ePoint(0) = polyCoords(a + 2) ePoint(1) = polyCoords(a + 3) ePoint(2) = 0 End If x1 = stPoint(0): x2 = ePoint(0) y1 = stPoint(1): y2 = ePoint(1) polyDist = Sqr(((x1 - x2) ^ 2) + ((y1 - y2) ^ 2)) sectionAngle = ThisDrawing.Utility.AngleFromXAxis(stPoint, ePoint) textCoords = ThisDrawing.Utility.PolarPoint(stPoint, sectionAngle, polyDist / 2) Set objDimAligned = ThisDrawing.ModelSpace.AddDimAligned(stPoint, ePoint, textCoords) Next a End Sub this code can''t work, Quote Link to comment Share on other sites More sharing options...
MSasu Posted January 29, 2014 Share Posted January 29, 2014 Welcome to the Forum, Iyant! Can you be more specific, please? How you loaded/called the code? Did you got any error message? And last, but not least, in which version did you attempted to test it? Quote Link to comment Share on other sites More sharing options...
iyant Posted February 18, 2014 Share Posted February 18, 2014 MSasu, i made polyline from data excel and need to show angular dimension, but always got error message Quote Link to comment Share on other sites More sharing options...
MSasu Posted February 19, 2014 Share Posted February 19, 2014 It would be useful to post the error you got to allow someone to provide you with an answer. 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.