DWG文件插入到DWG文件中的VBA问题
<p>请问我如何在CAD中通过VBA将一个个文件插入到一个已经打开的文件中并另存呢??我用INSERTBLOCK方法好像不行。比如下面代码:</p><p>Sub insertmoban()<br/>Dim pathname As String<br/>Dim pointbase(0 To 2) As Double</p><p><br/>pointbase(0) = 0<br/>pointbase(1) = 0<br/>pointbase(2) = 0<br/>pathname = "C:\Program Files\AutoCAD 2002\Support\塔基模板.dwg"</p><p>Dim insertedBlock As AcadBlockReference<br/>ThisDrawing.Application.Documents.Open pathname<br/>Set insertedBlock = ThisDrawing.ModelSpace.InsertBlock(pointbase, "C:\Documents and Settings\Administrator\桌面\试验\1.dwg", 1#, 1#, 1#, 0)<br/> End Sub<br/></p><p></p><p></p> 我也很想学习一下,<br/>顶上去<br/> <p>我的也是这样的情况,运行后什么都看不见,我有点怀疑是不是插入图形中有些字体需要代替的原因所以导致动作中断,。x</p><p>希望有高手可以帮帮忙</p> <p>兄弟,把你的代码改成以下看看,我的成功了,一个小错误。!</p><p>Dim inPoint(0 To 2) As Double <br/> Dim sca As Double <br/> Dim ro As Double <br/> Dim bName As String <br/> Dim blockObj As AcadBlockReference<br/> bName = "文件路径"<br/> inPoint(0) = 0#<br/> inPoint(1) = 0#<br/> inPoint(2) = 0#<br/> sca = 1#<br/> ro = 0<br/> <br/> On Error Resume Next<br/> <br/> Set blockObj = ThisDrawing.ModelSpace.InsertBlock(inPoint, bName, sca, sca, sca, ro)<br/> <br/>Unload Me<br/><br/>End Sub</p><p>这是插入一个外部图形到已打开的图形中...</p> <p>我试了还是不行,命令行总是出现:块 1 参照本身,不知何故望高手赐教!谢谢。</p><p>Public Sub HH()<br/> Dim inPoint(0 To 2) As Double<br/> Dim sca As Double<br/> Dim ro As Double<br/> Dim bName As String<br/> Dim blockObj As AcadBlockReference<br/> bName = "C:\Documents and Settings\Administrator\桌面\试验\1.DWG"<br/> inPoint(0) = 0#<br/> inPoint(1) = 0#<br/> inPoint(2) = 0#<br/> sca = 1#<br/> ro = 0<br/> <br/> On Error Resume Next<br/> <br/> Set blockObj = ThisDrawing.ModelSpace.InsertBlock(inPoint, bName, sca, sca, sca, ro)<br/>End Sub</p><p><br/></p> 我试了,4楼的代码可以啊。inPoint(0) = 0#
inPoint(1) = 0#
inPoint(2) = 0#
sca = 1#
这其中的“#”我删除了,
页:
[1]