我用C#平时都是针对当前活动文档a.dwg作业,此时如何向一个非活动文档b.dwg中画一个圆
我用C#平时都是针对当前活动文档a.dwg作业,此时如何向一个非活动文档b.dwg中画一个圆帮你顶一下,我也想学会。
谢谢! 同顶呀。有谁知道如何利用DWGDirect或DWGDirectX呀?这两个控件能够做到楼主的功能,可以谁有具体的教程呀 <CommandMethod("ABCD")> _
Public Sub ABCD()
Dim docs As DocumentCollection = Application.DocumentManager
Dim doc As Document = Nothing
For I As Integer = 0 To docs.Count - 1
doc = docs(I)
Dim NameStr As String = doc.Name
NameStr = NameStr.Substring(NameStr.LastIndexOf("\") + 1)
If NameStr = "b.dwg" AndAlso doc.IsActive = False Then
Using objDocLock As DocumentLock = doc.LockDocument
Using objTrans As Transaction = doc.Database.TransactionManager.StartTransaction
Dim BlkTbl As BlockTable = objTrans.GetObject(doc.Database.BlockTableId, Autodesk.AutoCAD.DatabaseServices.OpenMode.ForRead)
Dim BlkTblRec As BlockTableRecord = objTrans.GetObject(BlkTbl(BlockTableRecord.ModelSpace), Autodesk.AutoCAD.DatabaseServices.OpenMode.ForWrite)
Dim acCirc As Circle = New Circle(New Point3d(0, 0, 0), Vector3d.ZAxis.GetNormal, 3)
BlkTblRec.AppendEntity(acCirc)
objTrans.AddNewlyCreatedDBObject(acCirc, True)
objTrans.Commit()
End Using
End Using
End If
Next
End Sub
用VB写了个,已经测试通过,凑合看看吧
页:
[1]