【问题标题】:How to Draw Horizontal Ellipse (AutoCAD 2014)如何绘制水平椭圆 (AutoCAD 2014)
【发布时间】:2014-04-08 12:39:01
【问题描述】:

目标

在 AutoCAD 2014 中创建一个可以水平旋转的椭圆(如下图红色矩形所示)。


尝试

我能够创建椭圆,但我似乎找不到如何水平旋转它。

CreateEllipse(AcadDoc)

Public Function CreateEllipse(ByRef AcadDoc As Document) As ObjectId
    Dim returnId As ObjectId
    Dim db As Database = AcadDoc.Database
    Dim x As Vector3d = db.Ucsxdir
    Dim y As Vector3d = db.Ucsydir
    Dim normalVec As Vector3d = x.CrossProduct(y)
    Dim axisvec As Vector3d = normalVec.GetNormal()
    Dim CenterPoint As New Point3d(Me.StartPoint.X + 50, Me.StartPoint.Y + 40, 0)
    Dim aEllipse As New Ellipse(CenterPoint, axisvec, New Vector3d(0, 20, 0), 0.5, 0, Math.PI * 2)

    returnId = Utils.CreateAcadObject(AcadDoc, aEllipse)
    aEllipse.Dispose()
    Utils.regenLayers()

    Return returnId
End Function

Utils.CreateAcadObject(AcadDoc, aEllipse)

Public Function CreateAcadObject(ByRef acDoc As Document, ByRef acObj As Object) As ObjectId
    Dim objId As ObjectId
    Dim acCurDb As Database = acDoc.Database 'Get the current database
    Dim acBlkTbl As BlockTable
    Dim acBlkTblRec As BlockTableRecord

    Using lock As DocumentLock = acDoc.LockDocument
        'Start a transaction
        Using acTrans As Transaction = acCurDb.TransactionManager.StartTransaction()
            'Open Model space for write
            acBlkTbl = acTrans.GetObject(acCurDb.BlockTableId, OpenMode.ForRead)
            acBlkTblRec = acTrans.GetObject(acBlkTbl(BlockTableRecord.ModelSpace), OpenMode.ForWrite)
            acObj.SetDatabaseDefaults()

            'Add the object to the drawing
            objId = acBlkTblRec.AppendEntity(acObj)
            acTrans.AddNewlyCreatedDBObject(acObj, True)

            'Commit the changes and dispose of the transaction
            acTrans.Commit()
        End Using
    End Using

    Return objId
End Function

这是我得到的结果:


我会继续努力弄清楚,当我最终这样做时,我会发布我的答案。

【问题讨论】:

    标签: vb.net winforms autocad


    【解决方案1】:

    在你创建椭圆的那一行:

    Dim aEllipse As New Ellipse(CenterPoint, axisvec, New Vector3d(0, 20, 0), 0.5, 0, Math.PI * 2)
    

    你需要像这样改变主轴的坐标:

    Dim aEllipse As New Ellipse(CenterPoint, axisvec, New Vector3d(20, 0, 0), 0.5, 0, Math.PI * 2)
    

    【讨论】:

    • 太棒了。工作完美。好久没看到矢量图了! :)
    猜你喜欢
    • 2014-05-21
    • 1970-01-01
    • 2016-02-05
    • 2015-11-18
    • 1970-01-01
    • 1970-01-01
    • 2013-01-05
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多