robierzo Posted February 23, 2013 Posted February 23, 2013 Hello. I have a routine to insert images. (setq fich (GETFILED "Selecciona imagen" "c:\\" "jpg;tif;bmp;*" 0));ruta completa con nombre y extensión del fichero seleccionado (setq dimensiones (assoc 10 (entget (entmakex (list '(0 . "IMAGEDEF") '(100 . "AcDbRasterImageDef") (cons 1 fich) ) ) ) ) ) (setq anchura_imagen (cadr dimensiones);anchura en pixeles altura_imagen (caddr dimensiones);altura en pixeles ) (setq p3 (polar '(500 500) (/ PI 4) (* 0.15 altura_imagen))) (setq X_insercion (car p3) Y_insercion (cadr p3)) (command "_-image" "_A" fich (list X_insercion Y_insercion) 1 0) ) But, in the new drawings does not work. If I include these two lines, it works: (command "_-image" "_A" fich '(-1000 -1000) 1 0) (entdel(entlast)) Result: (defun c:insert_image () (setq fich (GETFILED "Selecciona imagen" "c:\\" "jpg;tif;bmp;*" 0)) ;;;;;If I include these two lines, it works. (command "_-image" "_A" fich '(-1000 -1000) 1 0) (entdel(entlast)) ;;;;; (setq dimensiones (assoc 10 (entget (entmakex (list '(0 . "IMAGEDEF") '(100 . "AcDbRasterImageDef") (cons 1 fich) ) ) ) ) ) (setq anchura_imagen (cadr dimensiones);anchura en pixeles altura_imagen (caddr dimensiones);altura en pixeles ) (setq p3 (polar '(500 500) (/ PI 4) (* 0.15 altura_imagen))) (setq X_insercion (car p3) Y_insercion (cadr p3)) (command "_-image" "_A" fich (list X_insercion Y_insercion) 1 0) ) Why this routine works. Greetings. Quote
BIGAL Posted February 23, 2013 Posted February 23, 2013 Not sure if 2006 has Imageattach no need for entmake etc over complicating it the code below inserts multi images automatically using a block each image is different its our staff phone list printed with pictures. ; routine to insert images based on a block position ; block is called phnum and has 1 attribute the staff ph No (vl-load-com) (defun *error* ( msg ) (princ "\nerror: ") (alert (strcat "\n Missing phone number image" name)) (princ) ) (setq mspace (vla-get-modelspace (vla-get-activedocument (vlax-get-acad-object)))) (setvar "clayer" "staffimages") (setq ss1 (ssget "x" (list (cons 0 "INSERT") (cons 2 "phnum")))) ;block name is phnum (setq len (sslength ss1)) (setq x 0) ; then insert block value at x,y ; need to pull out block find x,y and value (repeat len (foreach att (vlax-invoke (vlax-ename->vla-object (ssname SS1 x )) 'getattributes) (if (= "PHNUM" (strcase (vla-get-tagstring att))) ; tagname is phnum (progn (setq blknum (vla-get-textstring att)) (setq inspt (vla-get-insertionpoint att)) ) ) ) ;(setq blkval (rtos blknum 2 0)) (setq name (strcat "P:\\staff Offices\\" blknum ".jpg" )) (princ (strcat "\n" name)) (vla-AddRaster mspace name inspt 1.5 0.0) ;(command "-image" "attach" name (vlax-3d-point inspt) 1.0 0.0) (setq x (+ x 1)) ) ;repeatlen (setq ss1 nil) (princ "all done" (princ)[code] [/code] Quote
robierzo Posted February 24, 2013 Author Posted February 24, 2013 Hi Bigal. Thanks for answering. The problem is that I need to know the height of pixels, before inserting the image. So use the code: (setq dimensiones (assoc 10 (entget (entmakex (list '(0 . "IMAGEDEF") '(100 . "AcDbRasterImageDef") (cons 1 fich) ) ) ) ) ) (setq anchura_imagen (cadr dimensiones);width of pixeles altura_imagen (caddr dimensiones);heith of pixels ) With variable "altura_imagen" calculation the insertion point of the image. ¿¿How I can know the pixels of the image before inserting it.?? That is the question. The funny thing is that the code works from the first insertion. 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.