- 积分
- 10755
- 明经币
- 个
- 注册时间
- 2005-6-8
- 在线时间
- 小时
- 威望
-
- 金钱
- 个
- 贡献
-
- 激情
-
|
发表于 2012-4-6 08:52:08
|
显示全部楼层
<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写了个,已经测试通过,凑合看看吧 |
|