- 积分
- 130
- 明经币
- 个
- 注册时间
- 2010-9-1
- 在线时间
- 小时
- 威望
-
- 金钱
- 个
- 贡献
-
- 激情
-
|
我在代码里通过选择集创建一个块,创建后在窗体中预览这个块,但是无法预览,而调用cad自带的block命令创建块后就可以预览,why? 下面是我创建块的代码  ublic Shared Function CreateBlock1(ByVal blackName As String) Dim db As Database = HostApplicationServices.WorkingDatabase Dim ed As Editor = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor Dim blockImg As Drawing.Bitmap = Nothing '需要返回的Img对象 Dim lock = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.LockDocument() Using lock Dim blockId As ObjectId = ObjectId.Null '用于返回所创建的块的对象Id Dim record As BlockTableRecord = New BlockTableRecord() '创建一个BlockTableRecord类的对象,表示所要创建的块 record.Name = blackName '设置块名 record.Origin = New Point3d(0, 0, 0) '设置块的基点 Dim trans As Transaction = db.TransactionManager.StartTransaction() Using trans Dim bt As BlockTable = trans.GetObject(db.BlockTableId, OpenMode.ForWrite) If bt.Has(record.Name) = False Then Dim res As PromptSelectionResult = ed.GetSelection() '选择对象 If res.Status = PromptStatus.OK Then ' foreach (ObjectId id in res.Value.GetObjectIds()) Dim id As ObjectId = ObjectId.Null For Each id In res.Value.GetObjectIds() Dim ent As Entity = trans.GetObject(id, OpenMode.ForWrite) Dim NewEnt As Entity = ent.Clone() record.AppendEntity(NewEnt) Next bt.Add(record) '在块表中加入块 trans.AddNewlyCreatedDBObject(record, True) '通知事务处理 blockImg = BlockThumbnailHelper.GetBlockThumbanail(record.ObjectId) End If End If trans.Commit() End Using End Using Return Nothing
|
|