Jump to content

is it possible, through a code, to obtain the 4 coordinates of an image inserted in a drawing within Autocad?


duke

Recommended Posts

Hello friends,
1) is it possible, through a code, to obtain the 4 coordinates of an image inserted in a drawing within Autocad?
______________
2) If it were not possible to obtain the coordinates, perhaps the dimensions of the image could be obtained once inserted?
Even if it is without scale, the scale does not matter, just obtain the dimensions of both height and width
______________

3) If it is not possible, maybe you can tell me how to insert a JPG image, and have it inserted with the real dimensions of the file
I can extract the dimensions of an image in the following way:
====================================================================================

  (setq IMAGEN (car (entsel "\nSelecciona la imagen: ")))
  (setq IMAGEN-PROP-VLAX (vlax-ename->vla-object IMAGEN))
  (setq ANCHO-IMAGEN (vla-get-Width IMAGEN-PROP-VLAX)) ; Obtener ancho en unidades de dibujo
  (setq ALTURA-IMAGEN (vla-get-Height IMAGEN-PROP-VLAX)) ; Obtener alto en unidades de dibujo


====================================================================================
Those REAL dimensions of the image file, is how a solution could be, to be able to insert the image at that scale of the real dimensions.
This in order to be able to have a parameter to be able to know the height and width, and from those known dimensions and having the real dimensions captured in variables, from there, to be able to scale the image with some other Lisp code .
Since if we know the point with coordinates, where the image was inserted, (assoc 10) from there, we can know the coordinates of the other 3 corners, based on those distances from the real dimensions of the image.
I hope I haven't messed up too much, ha ha ha
Thanks in advance !!!

Link to comment
Share on other sites

I think this will help you:

(defun c:pp()
  (setq ed (entget (car (entsel "select image "))))
  (strcat " X= " (rtos (cadr (assoc 10 ed)))
	  " Y= " (rtos (caddr (assoc 10 ed)))
	  "  dX= " (rtos (* (cadr (assoc 11 ed)) (cadr (assoc 13 ed))))
	  " dY= " (rtos (* (caddr (assoc 12 ed)) (caddr (assoc 13 ed)))))
  )

 

  • Agree 1
Link to comment
Share on other sites

Brooooo, you got it right!!!! That is the solution !!
Is there a way to send you a small donation? I'm not wealthy, but I want to acknowledge your help!!
You are great bro!!!

Link to comment
Share on other sites

Another lots of stuff inside if you know how to look, use dumpit.lsp

 

; IOdaRasterImage 8c6f5960 : TeighaX Interface for an additional Raster Image funtionality
;
; Property values :
;
;
;   Height (RO) = 126.0

;   ImageHeight = 963.549313507815

;   ImageWidth = 3273.00877921702

;   Origin = (893.310512581778 -1166.27484437749 0.0)

;   ScaleFactor = 36125.4520397692

;   Width (RO) = 428.0

 

Link to comment
Share on other sites

31 minutes ago, BIGAL said:

Another lots of stuff inside if you know how to look, use dumpit.lsp

 

; IOdaRasterImage 8c6f5960 : TeighaX Interface for an additional Raster Image funtionality
;
; Property values :
;
;
;   Height (RO) = 126.0

;   ImageHeight = 963.549313507815

;   ImageWidth = 3273.00877921702

;   Origin = (893.310512581778 -1166.27484437749 0.0)

;   ScaleFactor = 36125.4520397692

;   Width (RO) = 428.0

 

Hello Bro, thanks for responding, I have no idea how to see that image data.
I'm a real newbie.
I also don't know where the dumpit.lsp file is located.
Do you think you could explain it to me please?
Thank you !!

Link to comment
Share on other sites

Using VL lisp you can get properties.

 

(setq obj (vlax-ename->vla-object (car (entsel "\nSelect a object "))))

(setq pt (vlax-get obj 'Origin))

 

DumpIt.LSP

Link to comment
Share on other sites

Posted (edited)

greatttttt !!!
and all the options will be used ?
;   Brightness = 50
;   ClippingEnabled = -1
;   Contrast = 50
etc

like
(setq pt (vlax-get obj 'Origin))
???
'Brightness
'ClippingEnabled
'Contrast
????
i am going to try before your reponse
sorry my bad english !! xDDD

Edited by duke
Link to comment
Share on other sites

The opposite to get is PUT

 

(vlax-put obj 'origin (list 0 0 0))

 

Be aware though you should not change width or height for an image rather its scale.

Link to comment
Share on other sites

44 minutes ago, BIGAL said:

The opposite to get is PUT

 

(vlax-put obj 'origin (list 0 0 0))

 

Be aware though you should not change width or height for an image rather its scale.

Excellent advice, I get the impression that it even works like a "MOVE" command, when changing the coordinates with 'ORIGIN??

Link to comment
Share on other sites

On 4/26/2024 at 5:48 PM, duke said:

Brooooo, you got it right!!!! That is the solution !!
Is there a way to send you a small donation? I'm not wealthy, but I want to acknowledge your help!!
You are great bro!!!

Thanks for the generous offer... but:

I glad to help, Duke!

That's the reason we are here: to get and to offer help.

If you like our forum, hang on here, get yourself involved in discussions, offer your advice to novice users.

 

I wish you a nice day!

 

  • Like 1
Link to comment
Share on other sites

Have a look at sites like Afralisp, Lee-mac.com, they have lots of great programs, and learning experiences.

 

Your welcome to have  a look at the attached, majority are free, a few I charge for normally Beer money. The reason I charge for some is that have to customize the code to suit client needs, an example 1 client doing manual task of editing a dwg made by external software could take up to 3 hours, it now takes 2 minutes. When you compare drafters hourly rate to 2 minutes cost saving is massive. Another charged for is 1150 lines of code, written from scratch. At the size yes charge.

 

So like fuccaro keep asking for help, the more you learn the more help is normally offered.Lisp files Apr 2024.docx

 

 

  • Like 1
Link to comment
Share on other sites

6 hours ago, BIGAL said:

So like fuccaro keep asking for help, ...

Ah! That's what I am doing here... I am keeping asking for help!

Relax, BIGALL, I am joking!

On the other hand, your post sounds like advertising. But we can turn a blind eye to an old valuable member, thirsty for beer.

I wish you a nice day, happy CADding!

 

Link to comment
Share on other sites

Thank you fuccaro for comment, as you know some people just keep asking as they can not be bothered to learn and want it all for free, despite the 8 hours of coding required. Thats why in the doc file there are a couple of programs that I have spent hours on getting them to work compared to the like 2-3 seconds for a result. 

 

Duke has been in touch with me and happy to provide him with support at no cost as he embarks on the learning curve. Always good to see people wanting to learn. 

 

What is interesting is my clients have chased me and they are all over the world, only a couple local.

  • Like 1
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...