编辑ZWCAD实体--旋转对象

来源:互联网 发布:java 加载 scala脚本 编辑:程序博客网 时间:2024/05/20 06:38

 Imports ZwSoft.ZwCAD.Runtime
Imports ZwSoft.ZwCAD.ApplicationServices
Imports ZwSoft.ZwCAD.DatabaseServices
Imports ZwSoft.ZwCAD.EditorInput
Imports ZwSoft.ZwCAD.Geometry


Public Class ZwcadApps

    <CommandMethod("RotateObject")> _
    Public Sub RotateObject()
        Dim ZcDoc As Document = Application.DocumentManager.MdiActiveDocument
        Dim ZcDB As Database = ZcDoc.Database
        Dim ZcEd As Editor = ZcDoc.Editor


        Using ZcTran As Transaction = ZcDB.TransactionManager.StartTransaction()


            Dim peo As New PromptEntityOptions(vbLf & "Select object:")
            Dim per As PromptEntityResult = ZcEd.GetEntity(peo)
            If per.Status <> PromptStatus.OK Then
                Return
            End If
            Dim Ent As Entity = ZcTran.GetObject(per.ObjectId, OpenMode.ForWrite)


            Dim pro1 As New PromptPointOptions(vbLf & "Input base point:")
            Dim proR1 As PromptPointResult = ZcEd.GetPoint(pro1)
            If proR1.Status <> PromptStatus.OK Then
                Return
            End If
            Dim basePt As Point3d = proR1.Value


            Dim pro2 As New PromptAngleOptions(vbLf & "Specify rotation angle:")
            Dim proR2 As PromptDoubleResult= ZcEd.GetAngle(pro2)
            If proR2.Status <> PromptStatus.OK Then
                Return
            End If
            Dim ang As Double = proR2.Value


            Dim Mt As Matrix3d = Matrix3d.Rotation(ang, New Vector3d(0, 0, 1), basePt)
            Ent.TransformBy(Mt)


            ZcTran.Commit()
        End Using


    End Sub

End Class

原创粉丝点击