fuccaro Posted April 13, 2015 Share Posted April 13, 2015 Hello there! I try to write a lisp to deal with images I attach to a drawing. The program clips them with a polygonal contour. Next it rotates the images and it should move them to match –like a puzzle. My problem is that the dimensions are in pixels (dxf 13) and to move the images in the right position I need them in drawing units. So, can someone help me to transform pixels in drawing units? Thanks! Quote Link to comment Share on other sites More sharing options...
Stefan BMR Posted April 13, 2015 Share Posted April 13, 2015 (edited) Hi fuccaro Long time no see!! You are looking for 11 and 12 dxf codes: _$ e <Entity name: 7ffffb05d10> _$ (cadr (assoc 11 (entget e))) 0.859725 _$ (caddr (assoc 12 (entget e))) 0.859725 Or, if you prefer Visual Lisp: _$ (setq e (vlax-ename->vla-object e)) #<VLA-OBJECT IAcadRasterImage 00000000410998e8> _$ (/ (vla-get-imagewidth e) (vla-get-width e)) 0.859725 _$ (/ (vla-get-imageheight e) (vla-get-height e)) 0.859725 The value represent the length of 1 pixel in drawing units. Edit: Hmm.. about the rotated images: (distance '(0 0 0) (cdr (assoc 11 (entget e)))) (distance '(0 0 0) (cdr (assoc 12 (entget e)))) Edited April 13, 2015 by Stefan BMR Quote Link to comment Share on other sites More sharing options...
fuccaro Posted April 13, 2015 Author Share Posted April 13, 2015 Hello Fane! Many thanks for answering me! I try to return to the Lisp world, after some years. I inserted an image, and entget returned this: ((-1 . <Entity name: 7ef91098>) (0 . "IMAGE").... (90 . 0) (10 0.0 0.0 0.0) (11 0.264583 0.0 0.0) (12 1.62011e-017 0.264583 0.0) (13 966.0 657.0 0.0) (340 . <Entity name: 7ef91088>) …) As you can see, the assoc of 12 returns a two component vector -but it should be something like (12 0 y 0) . The image is just inserted, not rotated/moved at all. Do you have any idea of what is going on? I try to write a generic program, not just for a specific image. Thanks again for your time! Quote Link to comment Share on other sites More sharing options...
Stefan BMR Posted April 13, 2015 Share Posted April 13, 2015 It is just a rounding matter and it shouldn't bother too much. _$ (setq u (cdr (assoc 11 (entget e)))) (0.859725 7.27232e-017 0.0) _$ (rtos (distance '(0 0 0) u) 2 16) "0.8597246778161206" _$ (rtos (distance '(0 0 0) (list (car u) 0.0 0.0)) 2 16) "0.8597246778161206" _$ (rtos (car u) 2 16) "0.8597246778161206" _$ Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted April 13, 2015 Share Posted April 13, 2015 Nice to see you again fuccaro! Since IMAGE entities are stored in the same way as WIPEOUT entities (or rather, the other way around), this post may help with the conversion between the pixel & drawing unit coordinate systems. Lee Quote Link to comment Share on other sites More sharing options...
fuccaro Posted April 15, 2015 Author Share Posted April 15, 2015 It seems that it works. Thanks for all the kind inputs! Quote Link to comment Share on other sites More sharing options...
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.