a934990825 发表于 2016-5-10 17:45:51

加载影像图插件,求大神给加一条批量打开的代码。

(defun c:insg()

(VL-LOAD-COM)

(setq AcadObject(vlax-get-acad-object)

      AcadDocument(vla-get-ActiveDocument Acadobject)

      mSpace(vla-get-ModelSpace Acaddocument)
)

(setq imageName (getfiled "指定政区数据文件" "*.*" "jpg;tif" 2))

;;; 读取并计算tfw文件参数

(setq tfwname (strcat (substr imageName 1 (- (strlen imageName) 3)) "tfw"))
   
(setq fp (open tfwname "r"))
(setq reco (read-line fp) ii 1)
(setq chat nil)                  
(while reco
   (setq chat (append (list reco) chat))             
   (setq reco (read-line fp) ii (1+ ii))                     
   );end while
(close fp)

(setq pt (list (atof (nth 1 chat)) (atof (nth 0 chat)) 0))
(setq bl (atof (nth 5 chat)))

(setq insertionPnt(vlax-make-safearray vlax-vbDouble '(0 . 2)))

(vlax-safearray-fill insertionPnt pt )

;;; 在模型空间中建立一个光栅图像

(setq RasterObj(vla-AddRaster mSpace imageName insertionPnt 1 0))

(setq width (vla-get-Width RasterObj))
(setq height (vla-get-height RasterObj))

(vla-put-ImageWidth RasterObj (* width bl))
(vla-put-Imageheight RasterObj (* height bl))
(command "move" (entlast) "" (list 0 (* height bl)) (list 0 0))

(command "zoom" "e" "zoom" "0.8x")

)

   
            

yhly555 发表于 2016-9-24 23:36:18

不建议批量加载,因为影像文件一般都很大,如果批量加载可能会导致CAD崩溃。

004 发表于 2019-4-23 01:20:43

qq群114378090有fas的批量插入影像的插件.
页: [1]
查看完整版本: 加载影像图插件,求大神给加一条批量打开的代码。