代码请求
我正在寻找可以用来列出dwg文件中包含的所有图像的代码。建议?**** Hidden Message ***** 建议1
在图中查找“ACAD _图像_字典”(字典),然后对所有图像进行遍历。 你在找什么吗?
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'~ 感谢编码方面的帮助。
我尝试了您的代码,但它卡住了:
Set objDict = ThisDrawing。字典(" ACAD _图像_字典")
它为什么这样做? 尝试下面这样的东西,字典有点时髦,因为它也可以是一个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 感谢所有的投入,但我已经决定只在字段中使用Diesel表达式。简单多了。 嗨,布里科,很好,一如既往,你赢了我,谢谢胖子 问题可能是字典不在绘图中,所以图像在绘图中。我知道这是lisp中的一个问题,我不知道/使用VBA,这就是为什么我没有发布任何代码,只是一个想法。在lisp中,您会捕获错误以查看它是否存在。 我在一个清除子系统中使用它,该子系统列出所有卸载的图像,并选择删除它们。我发现它非常方便,vba做得很好。
页:
[1]
2