Jump to content

Help change the size of the rectangle by command scale with reference


Recommended Posts

Posted

I am creating a lisp to scale a rectangle by the preset length size. It is currently crashing when I try to set values for variables S1, S2 (Ex: S1=200, S2=500,...)

 

(defun C:scc ( / ss pt1 pt2 dist size mat)
  (setq ss (ssget))
  (setq pt1 (getpoint "Point 1 :" ))
  (setq pt2 (getpoint "Point 2 :" pt1))
  (setq dist (distance pt1 pt2)) 
(cond 
((eq "S1" mat) 200)
((eq "S2" mat) 400)
(T nil)
)

(progn
(initget "S1 S2")  
(setq size (getdist "\nSize scale: [S1/S2]" )) 
(command "scale"  ss ""  pt1 "R" dist size)
)

Posted (edited)
(defun c:scc (/ ss pt1 pt2 dist size mat)
  (setq ss (ssget))
  (setq pt1 (getpoint "Point 1 :"))
  (setq pt2 (getpoint "Point 2 :" pt1))
  (setq dist (distance pt1 pt2))
  ;; Where is "mat' set ??
  (cond	((eq "S1" mat) 200)
	((eq "S2" mat) 400)
	(t nil)
  )
  (progn (initget "S1 S2")
	 (setq size (getdist "\nSize scale: [S1/S2]"))
	 (command "scale" ss "" pt1 "R" dist size)
  )
)					; <- you were missing this ??

(defun c:scc_fix (/ dist pt1 pt2 size ss)
  (if
    ;; Check that selection AND pt1 AND pt2 are valid
    (and (setq ss (ssget)) (setq pt1 (getpoint "Point 1 :")) (setq pt2 (getpoint "Point 2 :" pt1)))
     (progn (setq dist (distance pt1 pt2))
	    (initget "S1 S2")
	    (setq size (getdist "\nSize scale: [S1/S2]"))
	    (command "scale"
		     ss
		     ""
		     pt1
		     "R"
		     dist
		     (if (= "S1" size)
		       200
		       400
		     )
	    )
     )
  )
  (princ)
)

 

Edited by ronjonp
  • Like 2
Posted

The other alternative is to rework out the 4 pts and redraw. If you use the rectang command its always drawn in a certain order. Using VL you can put-coordinates for a Pline.

 

So my take the existing size is shown just enter new values.

 

image.png.d5d42c08b46045b901dcf04cdede0ddb.png

  • Like 1
Posted

thanks ronjonp!

I tried your method and it worked great.

💯

Posted (edited)

"I use it to resize an A3 drawing frame with different scales." Are you doing all your A3 title as multiples in modelspace if so then I and soooo many others will say start using layouts, title block is fixed true size, just set the mview scale to suit so much easier. That is why layouts were created.

Edited by BIGAL
  • Like 1

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