按照14.2创建数据表的要求做了一个3DSolid,一个line
碰到的问题是在 3Dsolid 在加入到VBASample.mdb数据库中,从debug.print 得到了3DSolid的ID号是2129993344,但ID号就是不能添加到数据库中.
第339页的程序摘录
For Each obj In ThisDrawing.ModelSpace Debug.Print obj.ObjectName Debug.Print obj.ObjectID Select Case obj.ObjectName Case "AcDbLine": rst.Open "SELECT id FROM line", cn, adOpenForwardOnly, adLockReadOnly, adCmdText pt1 = obj.StartPoint pt2 = obj.EndPoint If Not FindObj(rst, obj.ObjectID) Then ' 新建的直线的处理 cmd.CommandText = "INSERT INTO line(id,X1,Y1,X2,Y2) VALUES(" & _ "'" & obj.ObjectID & "'," & pt1(0) & "," & pt1(1) & "," & pt2(0) & "," & pt2(1) & ");" Else ' 修改的直线的处理 cmd.CommandText = "UPDATE line SET X1=" & pt1(0) & ",Y1=" & pt1(1) & ",X2=" & _ pt2(0) & ",Y2=" & pt2(1) & " WHERE id='" & obj.ObjectID & "';" End If cmd.Execute rst.Close Case "AcDbCircle": rst.Open "SELECT id FROM circle", cn, adOpenForwardOnly, adLockReadOnly, adCmdText pt1 = obj.Center If Not FindObj(rst, obj.ObjectID) Then cmd.CommandText = "INSERT INTO circle(id,CenX,CenY,Rad) VALUES(" & _ "'" & obj.ObjectID & "'," & pt1(0) & "," & pt1(1) & "," & obj.Radius & ");" Else cmd.CommandText = "UPDATE circle SET CenX=" & pt1(0) & ",CenY=" & pt1(1) & _ ",Rad=" & obj.Radius & " WHERE id='" & obj.ObjectID & "';" End If cmd.Execute rst.Close '将原程序的arc改为 Case "AcDb3DSOLID": rst.Open "SELECT id FROM 3DSOLID", cn, adOpenForwardOnly, adLockReadOnly, adCmdText pt1 = obj.Center If Not FindObj(rst, obj.ObjectID) Then cmd.CommandText = "INSERT INTO 3DSOLID(id,CenX,CenY,Rad,StartAng,EndAng) VALUES(" & _ "'" & obj.ObjectID & "'," & pt1(0) & "," & pt1(1) & "," & obj.Radius & "," & _ obj.StartAngle & "," & obj.EndAngle & ");" Else cmd.CommandText = "UPDATE 3DSOLID SET CenX=" & pt1(0) & ",CenY=" & pt1(1) & _ ",Rad=" & obj.Radius & ",StartAng=" & obj.StartAngle & ",EndAng=" & _ obj.EndAngle & " WHERE id='" & obj.ObjectID & "';" End If cmd.Execute rst.Close End Select Next obj
Debug.Print obj.ObjectName Debug.Print obj.ObjectID 打印结果 AcDb3dSolid ----- 3dsolid 2129993344 AcDbLine ---------- line 2129993352
----------------------------- "3DSOLID"的特性表为 ((-1 . <图元名: 7ef51e80>) (0 . "3DSOLID") (330 . <图元名: 7ef51cf8>) (5 . "88") (100 . "AcDbEntity") (67 . 0) (410 . "Model") (8 . "0") (100 . "AcDbModelerGeometry") (70 . 1) (1 . "mogoo kk m o ")
求教
这段程序如何改,理由是什么? 同理,还有插入的块程序如何写,理由是什么? |