Message 1 of 10
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello,
I have a problem with AcadLWPolyline and AcDbPolyline.
I create a lightweight polyline in model space, then i want to work with this polyline.
It's work if i work dirrectly with this polyline but it doesn't work if i recovers this polyline.
This following code work but not if i change 'plineObj = oEntite in plineObj = oEntite
I have the impression that AcadLWPolyline and AcDbPolyline is not the same thing for autocad but it is the same polyline !
What to do ?
Thanks for your help.
Regards,
Quentin
Sub Example_GetBulge() ' This example creates a lightweight polyline in model space. ' It then finds and changes the bulge for a given segment. Dim plineObj As AcadLWPolyline Dim points(0 To 11) As Double Dim i As Integer ' Define the 2D polyline points points(0) = 0: points(1) = 1 points(2) = 1: points(3) = 2 points(4) = 2: points(5) = 1 points(6) = 3: points(7) = 2 points(8) = 4: points(9) = 3 points(10) = 2: points(11) = 6 ' Create a lightweight Polyline object in model space Set plineObj = ThisDrawing.ModelSpace.AddLightWeightPolyline(points) ZoomAll ' Change the bulge of the third segment plineObj.SetBulge 3, 0.5 plineObj.Update For Each oEntite In ThisDrawing.ModelSpace 'on parcourt tous les éléments dans le dessin (hors xref) If oEntite.ObjectName = "AcDbPolyline" And oEntite.Layer = "0" Then 'plineObj = oEntite longeur_poly = Round(UBound(plineObj.Coordinates) / 2, 0) - 1 i = 0 P1 = plineObj.Coordinate(0) While i < longeur_poly rayon = Sqr((CenterPt(plineObj, i)(0) - plineObj.Coordinate(i)(0)) ^ 2 + (CenterPt(plineObj, i)(1) - plineObj.Coordinate(i)(1)) ^ 2) MsgBox (rayon) i = i + 1 Wend End If Next End Sub Public Function CenterPt(PolyLin As AcadLWPolyline, Optional Vertex As Integer) As Variant Dim PolyPts As Variant Dim PolySp(0 To 2) As Double Dim PolyEp(0 To 2) As Double Dim Lin1 As AcadLine Dim Ang As Double Dim IsoAng As Double Dim Radius As Double Dim ClockWise As Boolean Dim RadAng As Double Dim Bulg As Double If Vertex = Empty Then Vertex = 0 Bulg = PolyLin.GetBulge(Vertex) PolyPts = PolyLin.Coordinates PolySp(0) = PolyPts(Vertex * 2 + 0): PolySp(1) = PolyPts(Vertex * 2 + 1) PolyEp(0) = PolyPts(Vertex * 2 + 2): PolyEp(1) = PolyPts(Vertex * 2 + 3) Set Lin1 = ThisDrawing.ModelSpace.AddLine(PolySp, PolyEp) Ang = Atn(Bulg) * 4 IsoAng = Ang / 3.141592654 * 180 If IsoAng < 0 Then IsoAng = (IsoAng + 180) / 2 ClockWise = True Else IsoAng = (180 - IsoAng) / 2 End If IsoAng = IsoAng / 180 * 3.141592654 If ClockWise Then RadAng = Lin1.Angle + IsoAng + 3.141592654 Else RadAng = Lin1.Angle - IsoAng + 3.141592654 End If Radius = (Lin1.Length / 2) / Cos(IsoAng) CenterPt = ThisDrawing.Utility.PolarPoint(PolyEp, RadAng, Radius) Lin1.Delete End Function
Solved! Go to Solution.