Matersammichman 发表于 2006-10-10 11:46:24

代码请求

我正在寻找可以用来列出dwg文件中包含的所有图像的代码。建议?
**** Hidden Message *****

Maverick® 发表于 2006-10-10 11:55:45

建议1

T.Willey 发表于 2006-10-10 12:03:49

在图中查找“ACAD _图像_字典”(字典),然后对所有图像进行遍历。

Fatty 发表于 2006-10-11 04:19:12

你在找什么吗?
Option Explicit
Sub GetImages()
Dim objDict As AcadDictionary
Set objDict = ThisDrawing.Dictionaries("ACAD_IMAGE_DICT")
If objDict.Count0 Then
Dim oEntity As AcadEntity
Dim objImage As AcadRasterImage
Dim tmpArr(1) As Variant
Dim imageColl As New Collection
For Each oEntity In oSset
Set objImage = oEntity
tmpArr(0) = objImage.Name
Debug.Print tmpArr(0)
tmpArr(1) = objImage.ImageFile
Debug.Print tmpArr(1)
imageColl.Add tmpArr
Erase tmpArr
Next
Else
MsgBox "No images inserted."
End If
End If
oSset.Delete
Set oSset = Nothing
End Sub
脂肪
~'J'~

Matersammichman 发表于 2006-10-11 08:40:59

感谢编码方面的帮助。
我尝试了您的代码,但它卡住了:
Set objDict = ThisDrawing。字典(" ACAD _图像_字典")
它为什么这样做?

Bryco 发表于 2006-10-11 10:15:50

尝试下面这样的东西,字典有点时髦,因为它也可以是一个xrecord,所以typeof是一个很好的方法,可以直接得到它
Dim oDics 作为
AcadDictionary Dim oDic As AcadDictionary
Dim oD

Set oDics = ThisDrawing.Dictionaryaries
For Each oD In oDics
如果 TypeOf oD 是 AcadDictionary 那么
如果 oD.Name = “ACAD_IMAGE_DICT” 则
Set oDic = oD

Matersammichman 发表于 2006-10-11 10:43:14

感谢所有的投入,但我已经决定只在字段中使用Diesel表达式。简单多了。

Fatty 发表于 2006-10-11 12:55:25

嗨,布里科,很好,一如既往,你赢了我,谢谢胖子

T.Willey 发表于 2006-10-11 13:08:45

问题可能是字典不在绘图中,所以图像在绘图中。我知道这是lisp中的一个问题,我不知道/使用VBA,这就是为什么我没有发布任何代码,只是一个想法。在lisp中,您会捕获错误以查看它是否存在。

Bryco 发表于 2006-10-11 23:16:26

我在一个清除子系统中使用它,该子系统列出所有卸载的图像,并选择删除它们。我发现它非常方便,vba做得很好。
页: [1] 2
查看完整版本: 代码请求