简体   繁体   English

在VB中绘制一条线而不使用Autocad的事务类

[英]Drawing a line in VB without using Transaction Class for Autocad

I am Drawing a line using transaction class 我正在使用事务类画一条线

    Public Sub CreateLine()
    Dim acDoc As Document = Application.DocumentManager.MdiActiveDocument
    Dim acCurDb As Database = acDoc.Database
    Using acTrans As Transaction = acCurDb.TransactionManager.StartTransaction()
        Dim acBlkTbl As BlockTable
        acBlkTbl = acTrans.GetObject(acCurDb.BlockTableId, OpenMode.ForRead)
        Dim acBlkTblRec As BlockTableRecord
        acBlkTblRec = acTrans.GetObject(acBlkTbl(BlockTableRecord.ModelSpace), _
                                        OpenMode.ForWrite)
       procedure(acTrans, acBlkTblRec, 11, 3, 0, 5, 5, 0)
       acTrans.Commit()
    End Using
  End Sub
Private Sub procedure(ByVal var1 As Transaction, ByVal var2 As BlockTableRecord, ByVal                       x As Double, ByVal y As Double, ByVal z As Double, ByVal x1 As Double, ByVal y1 As Double, ByVal z1 As Double)
    Dim ac As Line = New Line(New Point3d(x, y, z), _
                                      New Point3d(x1, y1, z1))
    var2.AppendEntity(ac)
    var1.AddNewlyCreatedDBObject(ac, True)

End Sub

My task is to create line without using transaction can any one help me... 我的任务是在不使用事务的情况下创建行,任何人都可以帮助我...

You can use the ActiveX API: 您可以使用ActiveX API:

<CommandMethod("DRAWLINE")> _
Public Sub DrawLine()
    Dim acadApp As Object
    acadApp = Application.AcadApplication
    Dim startPoint(0 To 2) As Double
    Dim endPoint(0 To 2) As Double
    startPoint(0) = 1.0 : startPoint(1) = 1.0 : startPoint(2) = 0.0
    endPoint(0) = 5.0 : endPoint(1) = 5.0 : endPoint(2) = 0.0
    acadApp.ActiveDocument.ModelSpace.AddLine(startPoint, endPoint)
End Sub

Use the Autodesk.Autocad.Interop and Autodesk.Autocad.Interop.Common references and namespaces. 使用Autodesk.Autocad.InteropAutodesk.Autocad.Interop.Common引用和名称空间。

Access the desired document as AcadDocument . as AcadDocument访问所需的文档。

Dim Doc as AcadDocument 'and set it to the document you want
Doc.ModelSpace.AddLine(...parameters...)

Depending on what version of Autocad you're using, you can access the Application as AcadApplication . 根据所使用的Autocad版本,可以将应用程序as AcadApplication进行访问。 (And from the acadapplication instance you get Documents ) (并且从acadapplication实例中获得Documents

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM