Using Curve.Extend



Imports Autodesk.AutoCAD.Runtime
Imports Autodesk.AutoCAD.ApplicationServices
Imports Autodesk.AutoCAD.EditorInput
Imports Autodesk.AutoCAD.DatabaseServices
Imports Autodesk.AutoCAD.Geometry

Public Class Class1
    <CommandMethod("xt")> _
    Public Sub XtendMethod()
        Dim doc As Document = Application.DocumentManager.MdiActiveDocument
        Dim ed As Editor = doc.Editor
        Dim db As Database = doc.Database
        Try
            Dim peo As New PromptEntityOptions(vbLf & "Select a Curve")
            peo.SetRejectMessage(vbLf & "Selected entity must be a Curve.")
            peo.AddAllowedClass(GetType(Curve), False)
            Dim per As PromptEntityResult = ed.GetEntity(peo)
            If per.Status <> PromptStatus.OK Then
                Return
            End If
            Using tr As Transaction = db.TransactionManager.StartTransaction()
                Dim curve As Curve = TryCast(tr.GetObject(per.ObjectId, OpenMode.ForWrite), Curve)
                Dim line As Line = TryCast(curve, Line)
                If line IsNot Nothing Then
                    Dim dist As Double = line.Length * 0.1
                    Dim dir As Vector3d = (line.EndPoint - line.StartPoint).GetNormal()
                    line.EndPoint += dir * dist
                Else
                    Dim ep As Double = curve.EndParam
                    ep = ep * 1.1
                    curve.Extend(ep)
                End If
                tr.Commit()
            End Using
        Catch ex As System.Exception
            ed.WriteMessage(ex.Message)
        End Try
    End Sub
End Class

http://adndevblog.typepad.com/auto ... ing-curveextend.html



楼梯栏杆及扶手.JG/T562-2018.PDF



欢迎关注微信公众账号ByCAD