创建块后无法预览
我在代码里通过选择集创建一个块,创建后在窗体中预览这个块,但是无法预览,而调用cad自带的block命令创建块后就可以预览,why?<br/>下面是我创建块的代码<br/> Public Shared Function CreateBlock1(ByVal blackName As String)<br/> Dim db As Database = HostApplicationServices.WorkingDatabase<br/> Dim ed As Editor = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor<br/> Dim blockImg As Drawing.Bitmap = Nothing '需要返回的Img对象<br/> Dim lock = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.LockDocument()<br/> Using lock<br/> Dim blockId As ObjectId = ObjectId.Null '用于返回所创建的块的对象Id<br/> Dim record As BlockTableRecord = New BlockTableRecord() '创建一个BlockTableRecord类的对象,表示所要创建的块<br/> record.Name = blackName '设置块名 <br/> record.Origin = New Point3d(0, 0, 0) '设置块的基点<br/> Dim trans As Transaction = db.TransactionManager.StartTransaction()<br/> Using trans<br/> Dim bt As BlockTable = trans.GetObject(db.BlockTableId, OpenMode.ForWrite)<br/> If bt.Has(record.Name) = False Then<br/> Dim res As PromptSelectionResult = ed.GetSelection() '选择对象<br/> If res.Status = PromptStatus.OK Then<br/> ' foreach (ObjectId id in res.Value.GetObjectIds())<br/> Dim id As ObjectId = ObjectId.Null<br/> For Each id In res.Value.GetObjectIds()<br/> Dim ent As Entity = trans.GetObject(id, OpenMode.ForWrite)<br/> Dim NewEnt As Entity = ent.Clone()<br/> record.AppendEntity(NewEnt)<br/> Next<br/> bt.Add(record) '在块表中加入块<br/> trans.AddNewlyCreatedDBObject(record, True) '通知事务处理<br/> blockImg = BlockThumbnailHelper.GetBlockThumbanail(record.ObjectId)<br/> End If<br/> End If<br/> trans.Commit()<br/> End Using<br/> End Using<br/> Return Nothing<br/> 是不是你插入的太小了看不到啊。有这个可能
页:
[1]