Jump to content

image: pixel to mm


fuccaro

Recommended Posts

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!

Link to comment
Share on other sites

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 by Stefan BMR
Link to comment
Share on other sites

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) :o . 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!

Link to comment
Share on other sites

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"
_$ 

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...