yangqingchao
发表于 2018-5-7 16:28:37
本帖最后由 yangqingchao 于 2018-5-7 16:34 编辑
本人也经常用到这个功能,一直都没找到合适的,只能单张插入,今天看到@Atsai提供的文件,使用起感觉非常方便,于是就将两个文件稍加整合,基本能实现楼主所说的功能,由于我不懂编程,所以难免有很多错误,但我自己测试基本功能可以使用,大神们不要喷我。
(vl-load-com)
(if (null degrad)
(defun degrad(ang)
(* pi (/ ang 180.0))
)
)
(if (null raddeg)
(defun raddeg(ang)
(* 180.0 (/ ang pi))
)
)
(defun c:iimg()
(initget "1 2")
(princ "\n选择插入影像方式:")
(setq key (getkword "\n1单张\\2批量\\<1>:"))
(cond ((not key) (dz)) ;
((= key "1") (dz));
((= key "2") (pl));
);cond
)
(defun dz()
(findfile (setq im (getfiled "Select Image File"
(getvar "dwgprefix")
"tif;jpg;png;ecw"
16
)
)
)
(tfw im)
)
(defun pl()
(setq dir (LM:getfiles "选择文件" "" "tif;jpg;png;ecw"))
(repeat (setq n (length dir))
(setq n (1- n))
(setq e (nth n dir))
(tfw e)
)
(princ (strcat "\n成功插入 " (itoa (length dir)) "个影像!"))
(princ)
)
(defun tfw ( im / img file res ptxres yres xrot yrot left top minpt maxpt)
;define the function name and variables
(if (= (type im) 'str)
(progn
(setqimg
(vla-addraster
(vla-get-block
(vla-get-activelayout
(vla-get-activedocument (vlax-get-acad-object))
)
)
im
(vlax-make-variant
(vlax-safearray-fill
(vlax-make-safearray vlax-vbdouble (cons 0 2))
'(0.0 0.0 0.0)
)
)
1.0
0.0
)
)
(if (snvalid (vl-filename-base im))
(vla-put-name img (vl-filename-base im))
)
(setq im (vlax-vla-object->ename img))
)
(setq imG (vlax-ename->vla-object (ssname im 0)))
)
(if (findfile (vl-string-subst
".ers"
(vl-filename-extension (vla-get-imagefile img))
(vla-get-imagefile img)
)
)
(setq file (vl-string-subst
".ers"
(vl-filename-extension (vla-get-imagefile img))
(vla-get-imagefile img)
)
)
(if (findfile (vl-string-subst
".tfw"
(vl-filename-extension (vla-get-imagefile img))
(vla-get-imagefile img)
)
)
(setqfile (vl-string-subst
".tfw"
(vl-filename-extension (vla-get-imagefile img))
(vla-get-imagefile img)
)
)
(if (findfile(vl-string-subst
".jgw"
(vl-filename-extension (vla-get-imagefile img))
(vla-get-imagefile img)
)
)
(setq file (vl-string-subst
".jgw"
(vl-filename-extension (vla-get-imagefile img))
(vla-get-imagefile img)
)
)
(if(findfile (vl-string-subst
".pgw"
(vl-filename-extension (vla-get-imagefile img))
(vla-get-imagefile img)
)
)
(setq file (vl-string-subst
".pgw"
(vl-filename-extension (vla-get-imagefile img))
(vla-get-imagefile img)
)
)
)
)
)
)
(if (or file
(setq file (getfiled "Select World File"
(vl-string-subst
""
(vl-filename-extension (vla-get-imagefile img))
(vla-get-imagefile img)
)
"tfw;jgw;pgw;ers"
0
)
)
)
(if (= (vl-filename-extension file) ".ers")
(progn
(setq file (open file "r"))
(repeat 19 (read-line file))
(setq left (atof (last (split (read-line file) " ")))
top(atof (last (split (read-line file) " ")))
)
(close file)
(vla-put-origin
img
(vlax-make-variant
(vlax-safearray-fill
(vlax-make-safearray 5 (cons 0 2))
(list left (- top (vla-get-height img)) 0.0)
)
)
)
(vla-put-imagewidth img (vla-get-width img))
(vla-put-imageheight img (vla-get-height img))
(vla-getboundingbox img 'minpt 'maxpt)
(vla-zoomwindow (vlax-get-acad-object) minpt maxpt)
)
(progn
(setq file (open file "r")
xres (atof (read-line file))
xrot (atof (read-line file))
yrot (atof (read-line file))
yres (atof (read-line file))
ins(list (atof (read-line file)) (atof (read-line file)) 0.0)
ins(polar ins
(* (/ (+ xrot 90.0) 180.0) pi)
(* (vla-get-height img) yres)
)
)
(close file)
(vla-put-rotation img (degrad xrot))
(vla-put-origin
img
(vlax-make-variant
(vlax-safearray-fill (vlax-make-safearray 5 (cons 0 2)) ins)
)
)
(vla-put-imageheight
img
(* (vla-get-height img) (abs yres))
)
(vla-put-imagewidth img (* (vla-get-width img) (abs xres)))
(vla-getboundingbox img 'minpt 'maxpt)
(vla-zoomwindow (vlax-get-acad-object) minpt maxpt)
)
)
)
;)
;)
(princ) ;exit quietly
)
tonglesky
发表于 2018-5-7 20:29:29
dfg df gdf gdf
yangqingchao
发表于 2018-5-8 07:51:38
JHX948954875 发表于 2018-4-25 10:49
你好,这个怎么运行?
请看21楼的帖子
ypl522532167
发表于 2018-6-13 15:11:45
我也遇到需要批量插入TIFF文件
依然小小鸟
发表于 2018-6-13 19:03:10
yangqingchao 发表于 2018-5-7 16:28
本人也经常用到这个功能,一直都没找到合适的,只能单张插入,今天看到@Atsai提供的文件,使用起感觉非常方 ...
命令是哪个 怎么用不了呢
yangqingchao
发表于 2018-6-14 14:52:23
依然小小鸟 发表于 2018-6-13 19:03
命令是哪个 怎么用不了呢
命令就是iimg,运行不了的话,看看是什么提示呢,我这可以呢
依然小小鸟
发表于 2018-6-14 22:32:06
yangqingchao 发表于 2018-6-14 14:52
命令就是iimg,运行不了的话,看看是什么提示呢,我这可以呢
如何单纯的批量插入tiff呢不需要定位 就是批量插入tiff就行我的tiff是A3 PDF转换过来的 每次自己手动一张一张的插入tiff太慢而且插入完tiff 发现比例不对(不是正常的A3大小)大神你可以帮忙实现吗批量插入tiff或者更直接的 批量插入PDF而且大小正好是原始大小我不需要定位
yangqingchao
发表于 2018-6-15 08:55:30
依然小小鸟 发表于 2018-6-14 22:32
如何单纯的批量插入tiff呢不需要定位 就是批量插入tiff就行我的tiff是A3 PDF转换过来的 每次自己手动 ...
http://bbs.xdcad.net/thread-711226-1-1.html这里有
依然小小鸟
发表于 2018-6-15 11:52:07
yangqingchao 发表于 2018-6-15 08:55
http://bbs.xdcad.net/thread-711226-1-1.html这里有
没装晓东的任何东西 用不了貌似
公输
发表于 2018-8-13 23:06:51
xyp1964 发表于 2017-10-13 08:43
;; tt(批量插入图像)
(defun c:tt ()
(setq pt'(0 0)
哥们,此插件可否分享一下呢,谢谢了。