Jump to content

Fit image location, rotation and scale to geometry


Recommended Posts

Posted

hi

 

I usually insert a scanned pdf to the drawing, and calculating what is the scale factor so the image will fit as close as possible to the geometry (which are the same),

using the Align command is almost perfect for this but it doesn't scale . is there any lisp anywhere that I can use, make it act exactly like the "align" command but with a scale calculation.

 

meaning

  1. select the image
  2. lunch the command
  3. select first point in the image
  4. select the second point in the image
  5. in the geometry, select a corresponding first point
  6. in the geometry, select a corresponding second  point
  7. calculate location, rotation, scale

thanks

shay

Posted (edited)

Why not combine the align command with scale reference?

 

Here is a simple example with little error checking:

(defun c:foo (/ e p1 p2 p3 p4)
  (cond	((and (setq e (entsel "\nPick object to scale/align/rotate: "))
	      (setq p1 (getpoint "\nPick base point: "))
	      (setq p2 (getpoint "\nPick second point: "))
	      (setq p3 (getpoint "\nPick first reference point: "))
	      (setq p4 (getpoint "\nPick second reference point: "))
	 )
	 (setq e (vlax-ename->vla-object (car e)))
	 (vlax-invoke e 'scaleentity p1 (/ (distance p3 p4) (distance p1 p2)))
	 (vlax-invoke e 'rotate p1 (- (angle p3 p4) (angle p1 p2)))
	 (vlax-invoke e 'move p1 p3)
	)
  )
  (princ)
)
(vl-load-com)

 

Edited by ronjonp
  • Like 2
Posted (edited)
3 hours ago, samifox said:

 

....using the Align command is almost perfect for this but it doesn't scale .......

 

 

When I use the Align command, it always scales when I tell it to. Perhaps you are not using it correctly, or is it only with PDFs that it doesn't?

Edited by eldon
Posted

 

2 hours ago, eldon said:

 

When I use the Align command, it always scales when I tell it to. Perhaps you are not using it correctly, or is it only with PDFs that it doesn't?

 

in the knowledge base, it says that the command move, rotate and tilt, not scaling. how come your command also scaling?

Posted
3 hours ago, ronjonp said:

Why not combine the align command with scale reference?

 

Here is a simple example with little error checking:


(defun c:foo (/ e p1 p2 p3 p4)
  (cond	((and (setq e (entsel "\nPick object to scale/align/rotate: "))
	      (setq p1 (getpoint "\nPick base point: "))
	      (setq p2 (getpoint "\nPick second point: "))
	      (setq p3 (getpoint "\nPick first reference point: "))
	      (setq p4 (getpoint "\nPick second reference point: "))
	 )
	 (setq e (vlax-ename->vla-object (car e)))
	 (vlax-invoke e 'scaleentity p1 (/ (distance p3 p4) (distance p1 p2)))
	 (vlax-invoke e 'rotate p1 (- (angle p3 p4) (angle p1 p2)))
	 (vlax-invoke e 'move p1 p3)
	)
  )
  (princ)
)
(vl-load-com)

 

ill give it a try

thanks

Posted (edited)

It scales and rotates for me!!!

pick first source point

pick first destination point

pick second source point

pick second destination point

....from there you can choose third points or press enter and it then prompts "Scale objects based on alignment points? [Yes/No] <N>:"

choosing yes scales and rotates the PDF (same for images and other geometry)

Edited by steven-g
Posted
14 hours ago, samifox said:

 

 

in the knowledge base, it says that the command move, rotate and tilt, not scaling. how come your command also scaling?

 

I read the command line.

 

Perhaps the knowledge base does not tell everything. The default is for no scaling, but if you choose the Yes option at the appropriate time, it will scale for you.

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...