mhy3sx Posted October 30, 2023 Posted October 30, 2023 Hi I am trying to convert this georefimage lisp I am using grads and my template units settings is : (mapcar 'setvar (list 'aunits 'auprec 'angdir 'angbase 'lunits 'luprec 'insunits ) (list 2 4 1 (/ pi 2) 2 3 6)) This code work with deg and the results is wrong (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:georefimg (/ img file res pt xres yres xrot yrot left top minpt maxpt im) ;define the function name and variables (princ "\nSelect Image or return to select image file to insert") (if (or (setq im (ssget ":s" '((0 . "IMAGE")))) (findfile (setq im (getfiled "Select Image File" (getvar "dwgprefix") "png;tif;jpg;ecw" 16)))) ;select the image to scale (progn (if (= (type im) 'str) (progn (setq img (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))) (setq file (vl-string-subst ".tfw" (vl-filename-extension (vla-get-imagefile img)) (vla-get-imagefile img))) (if (findfile (vl-string-subst ".jpw" (vl-filename-extension (vla-get-imagefile img)) (vla-get-imagefile img))) (setq file (vl-string-subst ".jpw" (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 ) can any one help Thanks Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.