明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 2890|回复: 12

请问VBA中怎样在R14中插入dwg文件?

  [复制链接]
发表于 2003-11-5 19:37:00 | 显示全部楼层 |阅读模式
以下代码错在何处?


  Dim InsetPoint(0 To 2) As Double  
  Dim ImporFile As String
  InsetPoint(0) = 0: InsetPoint(1) = 0: InsetPoint(2) = 0
  ImporFile = "文件名.dwg"
  ThisDrawing.Import ImporFile, InsetPoint, 1#
发表于 2003-11-5 19:41:00 | 显示全部楼层
文件名必须带路径,不然就必须在当前目录存在,但当前目录有时会有不同,所以还是加上路径为好。
 楼主| 发表于 2003-11-5 19:51:00 | 显示全部楼层

带上路径仍然不行!

该文件名已是带上路径的全文件名,但是执行代码后什么也没有,既没见到
欲插入的图形文件,也没有提示错误,不知何故?
发表于 2003-11-5 20:07:00 | 显示全部楼层
ThisDrawing.ModelSpace.InsertBlock InsetPoint, ImporFile, 1, 1, 0
发表于 2003-11-5 20:22:00 | 显示全部楼层
RetVal = object.Import(FileName, InsertionPoint, ScaleFactor)

Object

Document
The object or objects this method applies to.

FileName

String; input-only
The name of the file to be imported.

InsertionPoint

Variant (three-element array of doubles); input-only
The 3D WCS coordinates location in the current drawing where the imported file is placed.

ScaleFactor

Double; input-only
The scale used to place the imported file.

RetVal

Object
In the case of importing a WMF file, a BlockReference object is returned. In all other cases, the return value is NULL.

最后一个的返回值介绍:

返回

导入WMF文件,返回块引用对象。其它情况,返回NULL值。
 楼主| 发表于 2003-11-5 21:01:00 | 显示全部楼层
改成以下代码仍不行:

  Dim InsetPoint(0 To 2) As Double
  Dim ImporFile As String
  Dim ScaleFactor As Double
  Dim AnObj As Object
  InsetPoint(0) = 0: InsetPoint(1) = 0: InsetPoint(2) = 0
  ImporFile = "D:\123.dwg"   
  ScaleFactor = 1#
  Set AnObj = ThisDrawing.Import(ImporFile, InsetPoint, ScaleFactor)

查了一下,是否 import 方法不支持 .dwg 文件?然则 .dwg 文件怎样插入?
发表于 2003-11-5 21:04:00 | 显示全部楼层
Impor只支持WMF文件的导入,对于DWG文件,就要使用插入块或者外部引用的方式。
 楼主| 发表于 2003-11-6 16:01:00 | 显示全部楼层
再请问一下,将DWG文件作为块插入或者外部引用在VBA中如何实现之?麻烦编一小段代码将“D:\123.dwg"文件插入当前图形,不甚感谢!最好能在R14中通过。


                    <新手上路,请多指教>  :)
 楼主| 发表于 2003-11-7 12:24:00 | 显示全部楼层
请各位大侠指点!谢谢!
 楼主| 发表于 2003-11-11 09:22:00 | 显示全部楼层
我知道我提的问题太过简陋,不值一哂,但是新手上路。还望海涵:
      麻烦哪位编一小段代码将“D:\123.dwg"文件插入当前图形,不甚感谢!最好能在R14中通过。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2025-2-22 16:44 , Processed in 0.181970 second(s), 24 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表