插入块
大家好Autodesk。' eNotInDatabase
这是主题的一部分;在表格中插入符号
当我第一次编写应用程序时,块插入到我想要的位置。ok
当我第二次运行我的应用程序时,出现了问题,我收到了以下消息。AutoCAD . runtime . exception:' eNotInDatabase
如何修复
谢谢
下面的代码
DrawRect(acBlkTblRec, acTrans, 0, 0, 5, 5)
Public Sub DrawRect(ByRef acBlkTblRec As BlockTableRecord, ByRef actrans As Transaction,
ByVal origPtx As Double, ByVal origPty As Double, ByVal Base As Double, ByVal Haut As Double)
Dim acDoc As Document = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument
Dim acCurDb As Database = acDoc.Database
Dim acLyrTbl As LayerTable
acLyrTbl = actrans.GetObject(acCurDb.LayerTableId,
OpenMode.ForRead)
Dim LCadre As String = "Armat"
Dim bt As BlockTable = DirectCast(actrans.GetObject(acCurDb.BlockTableId, OpenMode.ForRead), BlockTable)
Dim btr As BlockTableRecord = New BlockTableRecord()
If Not bt.Has("Ceramic") Then
bt.UpgradeOpen()
btr.Name = "Ceramic"
bt.Add(btr)
actrans.AddNewlyCreatedDBObject(btr, True)
End If
Dim acPoly As Polyline = New Polyline()
acPoly.AddVertexAt(0, New Point2d(origPtx + 0.15, origPty + Haut - 0.1), 0, 0.005, 0.005)
acPoly.AddVertexAt(0, New Point2d(origPtx + 0.12, origPty + Haut + 0.05), 0, 0.005, 0.005)
acPoly.AddVertexAt(0, New Point2d(origPtx + Base + 0.1, origPty + Haut - 0.05), 0, 0.005, 0.005)
acPoly.AddVertexAt(0, New Point2d(origPtx + Base, origPty), 0, 0.005, 0.005)
acPoly.AddVertexAt(0, New Point2d(origPtx, origPty), 0, 0.005, 0.005)
acPoly.AddVertexAt(0, New Point2d(origPtx, origPty + Haut), 0, 0.005, 0.005)
acPoly.AddVertexAt(0, New Point2d(origPtx + 0.1, origPty + Haut - 0.1), 0, 0.005, 0.005)
acPoly.Layer = LCadre
'acBlkTblRec.AppendEntity(acPoly)
'actrans.AddNewlyCreatedDBObject(acPoly, True)
btr.AppendEntity(acPoly)
actrans.AddNewlyCreatedDBObject(acPoly, True)' problem is here!
End Sub
**** Hidden Message ***** 嗨,您在if语句之外将多段线添加到块定义中,因此如果块表已经包含块定义,则“btr”尚未添加到数据库中。只有在块表尚未包含if语句中的块定义IOW时,您才应该创建BlockTableRecord的新实例并将id追加到多段线。 DrawRect(acBlkTblRec,acTrans,0,0,5,5)。
。
Public Sub DrawRect(ByRef acBlkTblRec As block table record,ByRef actrans As Transaction,。
ByVal origPtx为Double,ByVal origPty为Double,ByVal Base为Double,ByVal Haut为Double)。
。
Dim acDoc As Document = Autodesk,AutoCAD . application services . application . document manager . mdiactivedocument 。
Dim acCurDb As Database = acDoc,数据库。
将acryrtbl Dim作为图层表。
acLyrTbl = actrans,GetObject(acCurDb,LayerTableId,。
打开模式,ForRead)。
。
Dim LCA dre As String = " Armat " 。
。
Dim Bt As block table = direct cast(actrans,GetObject(acCurDb,BlockTableId,OpenMode。ForRead)、块表)。
。
如果不是bt,Has(“陶瓷”)Then。
bt,UpgradeOpen()。
Dim btr As block table record = New block table record()。
。
btr,Name = "Ceramic"。
bt,添加(btr)。
actrans,AddNewlyCreatedDBObject(btr,True)。
。
Dim AC poly As Polyline = New Polyline()。
。
acPoly,AddVertexAt(0,新点2d(origPtx + 0.15,origPty + Haut - 0.1),0,0.005,0.005)。
acPoly,AddVertexAt(0,新点2d(origPtx + 0.12,origPty + Haut + 0.05),0,0.005,0.005)。
acPoly,AddVertexAt(0,New Point2d(origPtx + Base + 0.1,origPty + Haut - 0.05),0,0.005,0.005)。
acPoly,AddVertexAt(0,新点2d(origPtx + Base,origPty),0,0.005,0.005)。
acPoly,AddVertexAt(0,新点2d(origPtx,origPty),0,0.005,0.005)。
acPoly,AddVertexAt(0,新点2d(origPtx,origPty + Haut),0,0.005,0.005)。
acPoly,AddVertexAt(0,新点2d(origPtx + 0.1,origPty + Haut - 0.1),0,0.005,0.005)。
。
acPoly,Layer = LCadre。
btr,AppendEntity(acPoly)。
actrans,AddNewlyCreatedDBObject(acPoly,True)。
结束If。
结束Sub。
。
。
是的它在目标
谢谢吉尔
这个话题
页:
[1]