Public Class class1
<CommandMethod("NMGroup")> _
Public Sub NMGroup()
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.ForWrite)
Dim acBlkTblRec As BlockTableRecord
acBlkTblRec = acTrans.GetObject(acBlkTbl(BlockTableRecord.ModelSpace), _
OpenMode.ForWrite)
Dim DBDict As DBDictionary = acTrans.GetObject(acCurDb.GroupDictionaryId, OpenMode.ForWrite)
Dim newGroup As Group = New Group("组的说明", True)
'这里才是组的名称
DBDict.SetAt("*", newGroup)
'向组中添加几个单行文字对象
Dim i As Int16
Dim P As Point3d = New Point3d(0, 0, 0)
For i = 0 To 5
Dim DBT As DBText = New DBText
DBT.TextString = Str(i)
DBT.Height = 300
DBT.SetDatabaseDefaults()
P = New Point3d(P.X, P.Y - 450, 0)
DBT.Position = P
acBlkTblRec.AppendEntity(DBT)
acTrans.AddNewlyCreatedDBObject(DBT, True)
newGroup.Append(DBT.ObjectId)
Next
acTrans.AddNewlyCreatedDBObject(newGroup, True)
acTrans.Commit()
End Using
End Sub
End Class
<CommandMethod("NMGroup")> _
Public Sub NMGroup()
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.ForWrite)
Dim acBlkTblRec As BlockTableRecord
acBlkTblRec = acTrans.GetObject(acBlkTbl(BlockTableRecord.ModelSpace), _
OpenMode.ForWrite)
Dim DBDict As DBDictionary = acTrans.GetObject(acCurDb.GroupDictionaryId, OpenMode.ForWrite)
Dim newGroup As Group = New Group("组的说明", True)
'这里才是组的名称
DBDict.SetAt("*", newGroup)
'向组中添加几个单行文字对象
Dim i As Int16
Dim P As Point3d = New Point3d(0, 0, 0)
For i = 0 To 5
Dim DBT As DBText = New DBText
DBT.TextString = Str(i)
DBT.Height = 300
DBT.SetDatabaseDefaults()
P = New Point3d(P.X, P.Y - 450, 0)
DBT.Position = P
acBlkTblRec.AppendEntity(DBT)
acTrans.AddNewlyCreatedDBObject(DBT, True)
newGroup.Append(DBT.ObjectId)
Next
acTrans.AddNewlyCreatedDBObject(newGroup, True)
acTrans.Commit()
End Using
End Sub
End Class
|
暂时没有评论
发表评论 - 不要忘了输入验证码哦! |