vb.net - 如何绘制水平椭圆 (AutoCAD 2014)

标签 vb.net winforms autocad

目标

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

Horizontal Ellipse


尝试

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

创建椭圆(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

这是我得到的结果:

Vertical Ellipse


我会继续尝试解决这个问题,当我最终这样做时,我会发布我的答案。

最佳答案

在创建椭圆的线上:

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)

关于vb.net - 如何绘制水平椭圆 (AutoCAD 2014),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22937285/

相关文章:

asp.net - VB.NET aspx 页面在 If 语句中使用代码隐藏变量

asp.net - 分页GridView

html - IMAGE 标签中的样式属性不适用于所有浏览器

c# - 如何仅在用户停止输入时处理 TextChanged 事件?

php - 操纵 map

vb.net - 反序列化时XML文档有错误

c++ - 在托管 C++ GUI 中通过另一个事件结束/中断/切换一个事件

c# - 如何将数据从 WebBrowser 控件中的 JavaScript 返回到 C#?

c# - 是否可以使用 Autodesk.AutoCAD.Interop 在 AutoCAD 中编辑 block 属性?

c#, Autocad, 显示填充的属性