0

我正在使用事务类画一条线

    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

我的任务是在不使用事务的情况下创建行,任何人都可以帮助我...

4

2 回答 2

1

您可以使用 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
于 2013-04-26T05:40:20.493 回答
0

使用Autodesk.Autocad.InteropandAutodesk.Autocad.Interop.Common引用和命名空间。

访问所需的文档as AcadDocument

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

根据您使用的 Autocad 版本,您可以访问应用程序as AcadApplication。(并且从您获得的 acadapplication 实例中Documents

于 2013-04-26T19:21:35.873 回答