lisp program that scale reference with selecting line on the drawing.

lisp program that scale reference with selecting line on the drawing.

MSA3DY
Contributor Contributor
1,049 Views
12 Replies
Message 1 of 13

lisp program that scale reference with selecting line on the drawing.

MSA3DY
Contributor
Contributor

Hi All.

I need quick scale reference the procedure will be

- select objects to scale 

- select a line on a drawing 

- type the length for this line.

 

to save some steps.

can somebody help in this ?

thank for all

0 Likes
Accepted solutions (3)
1,050 Views
12 Replies
Replies (12)
Message 2 of 13

Moshe-A
Mentor
Mentor

@MSA3DY hi,

 

i hope you are reading what you are writing???  it's not clear if you want to scale or write a length along a line?

 

Moshe

 

Message 3 of 13

pendean
Community Legend
Community Legend
The the last two bullet-points, you want LENGTHEN command maybe?

Not sure what you mean by everything else though: explain, with screenshots even.
0 Likes
Message 4 of 13

MSA3DY
Contributor
Contributor

when I write the command for  instance  QRF , will give me select objects, then

- I select all objects I need to scale

- after that it gives me a message , select line so I select the line

- then it gives me write the length , I write 100

- the result to scale all objects with the reference of this line.   did you understand me ?

0 Likes
Message 5 of 13

MSA3DY
Contributor
Contributor

Also I don't need to select base point , the lisp will select one endpoint of the line.

 

0 Likes
Message 6 of 13

Kent1Cooper
Consultant
Consultant

In other words, SCALE with the Reference option, with the length of the selected Line providing the Reference size [without the User needing to spell it out], and the User typing in the new size, so that the selected Line becomes their specified new length, and all the other selected objects are Scaled along with it.  Right?

Kent Cooper, AIA
0 Likes
Message 7 of 13

Moshe-A
Mentor
Mentor

@MSA3DY ,

 

maybe a dwg with an example with before and after?

0 Likes
Message 8 of 13

Kent1Cooper
Consultant
Consultant

Something like this, in simplest terms:

 

(defun C:WHATEVER (/ ss refline rldata)
  (if
    (and
      (setq ss (ssget "_:L"))
      (setq refline (car (entsel "\nLine to serve for Reference length: ")))
      (member '(0 . "LINE") (setq rldata (entget refline)))
    ); and
    (progn
      (ssadd refline ss); in case it wasn't in selection
      (command "_.scale" ss "" (cdr (assoc 10 rldata))
        "_reference" (distance (cdr (assoc 10 rldata)) (cdr (assoc 11 rldata))) pause
      ); command
    ); progn
  ); if
  (prin1)
)

 

You can type in the new Line length as you describe, or pick on-screen.  It assumes you want the selected Line Scaled along with the rest, even if you didn't select it along with the rest, but you can remove line 9 if that's an incorrect assumption.

 

It could use all the usual improvements, could Scale about the downstream end or the midpoint of the Line instead of it upstream end, and could notify you if you didn't pick a Line for the Reference length [instead of just quitting], and so on.

Kent Cooper, AIA
Message 9 of 13

MSA3DY
Contributor
Contributor
Thank you Kent1Cooper , that' great
I used to click about 8 clicks to do this , with selecting endpoint with snap.
Now you saved about 5 clicks without object snap setting.
thank you again.

0 Likes
Message 10 of 13

MSA3DY
Contributor
Contributor

It's great for now , but I hope to save one click

when i select object i need to click "space"  or "Enter" to tell Autocad that I've  finished selection.

I want to save this step , just i select one window from right to left is enough for me. 

Also I need to add dimension on this line to get sure the scale is right. the dimension can be with dimension style called (feet) and the distance between line and dimension line is 5" .

Thank you again

 

0 Likes
Message 11 of 13

Kent1Cooper
Consultant
Consultant
Accepted solution

@MSA3DY wrote:

....

when i select object i need to click "space"  or "Enter" to tell Autocad that I've  finished selection.

I want to save this step , just i select one window from right to left is enough for me. 

....


That seems risky to me -- won't you sometimes have things included in the selection that you don't want, and have no option to remove them before proceeding?  But if that's what you want, simply change this:

(setq ss (ssget "_:L"))

to this:

(setq ss (ssget "_:L:S"))

 

Read about the selection options in the (ssget) entry in the AutoLisp Reference.  [It always takes some trial -- it seems you can't jam together like that just any combination, but it's not clear what combinations work, outside of their examples, without testing.]

Kent Cooper, AIA
Message 12 of 13

Kent1Cooper
Consultant
Consultant
Accepted solution

@MSA3DY wrote:

.... 

Also I need to add dimension on this line to get sure the scale is right. ...


If the only reason for the Dimension is to verify the result of the Scaling, and not to have the Dimension in the drawing ultimately, I would suggest a (prompt) or an (alert) confirming the actual post-Scale length of the reference Line.  Much simpler than setting a Dimension Style that may not be current, calculating the location for the dimension line, caring about Zoom level for readability, etc.

(defun C:WHATEVER (/ ss refline)
  (setq ss (ssget "_:L:S")); one selection, on only unlocked Layer(s)
  (repeat (setq n (sslength ss)) (redraw (ssname ss (setq n (1- n))) 3)); highlight
  (if
    (and
      ss
      (setq refline (car (entsel "\nLine to serve for Reference length: ")))
      (member '(0 . "LINE") (setq rldata (entget refline)))
    ); and
    (progn
      (ssadd refline ss); in case it wasn't in selection
      (command "_.scale" ss "" (cdr (assoc 10 rldata))
        "_reference" (getpropertyvalue refline "Length") pause
      ); command
      (alert
        (strcat
          "Confirming: Reference line\nlength has become "
          (rtos (getpropertyvalue refline "Length")); now, in current mode/precision
          "."
        ); strcat
      ); alert
    ); progn
  ); if
  (prin1)
)

 

Kent Cooper, AIA
Message 13 of 13

MSA3DY
Contributor
Contributor
Accepted solution
Thank you very much.
0 Likes