' CamBam VBScript dh42 03/2015 ' polyline segments info '***************************************************************** ' 'CamBam.CAD.Polyline 'CamBam.CAD.Entity 'System.Object 'CamBam.Geom.Arc2F 'CamBam.Geom.Line2F ' '***************************************************************** Sub main() Dim ent As Entity Dim pli As Polyline For Each ent In CamBamUI.MainUI.ActiveView.SelectedEntities If TypeOf ent Is Polyline Then pli = CType(ent, Polyline) SegmentInfo(pli) '------------------------------------------------------------- End If Next ent End Sub Sub SegmentInfo(p As Polyline) Dim nbseg As Integer Dim seg As Object Dim objtype As String Dim a As Arc2F Dim l As Line2F nbseg = p.NumSegments 'number of segments/arcs in the polyline ThisApplication.AddLogMessage(" Nb. of segments: " & nbseg) For ct As Integer = 0 To nbseg - 1 'scan all segment in the polyline seg = p.GetSegment(ct) 'get an Object from the current segment objtype = seg.GetType.Name 'get the type name (Line2F or Arc2F) ThisApplication.AddLogMessage("Type: " & objtype) 'get info about segments Select Case objtype Case "Arc2F" a = CType(seg, Arc2F) 'cast a pointer from Object to Arc2F 'get infos about the arc ThisApplication.AddLogMessage("P1 XY: " & a.P1.X _ & " " & a.P1.Y) ThisApplication.AddLogMessage("P2 XY: " & a.P2.X _ & " " & a.P2.Y) ThisApplication.AddLogMessage("Center XY: " & a.Center.X _ & " " & a.Center.Y) ThisApplication.AddLogMessage("Radius: " & a.Radius) ThisApplication.AddLogMessage("Direction: " & a.Direction & vbNewLine) Case "Line2F" l = CType(seg, Line2F) 'cast a pointer from Object to Line2F ThisApplication.AddLogMessage("P1 XY: " & l.p1.X _ & " " & l.p1.Y) ThisApplication.AddLogMessage("P2 XY: " & l.p2.X _ & " " & l.p2.Y) ThisApplication.AddLogMessage("Length: " & l.Length & vbNewLine) End Select Next ct End Sub