我只是来这里获取一些ObjectARX信息,我记得没有答案。我这样做了(在Autocad Land Desktop 2007上):
-excel工作表(代码中由EXCSheet引用),其中包含第1列中所有图像的完整路径和名称
-FILEDIA设置为0
- With EXCSheet
- i = 4
- Do
- RetryIns:
- ThisDrawing.SendCommand ("MAPIINSERT" & vbCrLf)
- ThisDrawing.SendCommand ("""" & .Cells(i, 1).Value & """" & vbCrLf)
- DoEvents
- Sleep 2000 ' maybe less
- ThisDrawing.SendCommand ("N" & vbCrLf) ' answer no
- ' this is he only image in the drawing (empty drawing)
- For Each a In ThisDrawing.ModelSpace
- If (TypeOf a Is AcadRasterImage) Then
- Set the_img = a
- insp = the_img.Origin ' insertion may fail to place image
- If (insp(0) = 0) And (insp(1) = 0) Then
- the_img.Delete ' if so, we should retry
- GoTo RetryIns
- End If
-
-
- Call the_img.GetBoundingBox(minp, maxp)
- ' you may save bounding box here
- scl_ty = ThisDrawing.GetVariable("INSUNITS")
- Call ThisDrawing.SetVariable("INSUNITS", 0)
- ' save here the_img.Rotation and the_img.ScaleFactor
- Call ThisDrawing.SetVariable("INSUNITS", scl_ty)
- ' maybe you need maximum/ minimum values... this is the place
- the_img.Delete ' no need for this image any more
- Exit For
- End If
- Next a
-
- i = i + 1
- Loop Until .Cells(i, 1).Value = ""
- End With
-
代码可能看起来很奇怪,因为将值保存到excel表的部分被剥离了,但这只是一般的想法。
顺致敬意,
刻痕 |