Getpoint on another end of a line after scale

Getpoint on another end of a line after scale

aliff_ahtenk
Enthusiast Enthusiast
898 Views
6 Replies
Message 1 of 7

Getpoint on another end of a line after scale

aliff_ahtenk
Enthusiast
Enthusiast

Hai all,

how do i getpoint on another end of a line after scale that line for my next or new reference point?

 

my goal is to set second reference point on my lisp.

 

here i simplified my code on that part for testing:

 

(defun c:test (/)
(setq P0 (getpoint "\nSelect Point: "))
(setq SF (getdist "\nInsert Size: "))
(setq SET1 (ssadd)) ; first selection set

(command "_line" '(0.0 0.0) '(0.99 0.0) "") ; the last line in the set -> suppose i will need to set the new getpoint right?

(ssadd (entlast) SET1)

(command "_move" SET1 "" '(0 0) P0)
(command "_scale" SET1"" p0 sf)

(command "_group" "c" "*" "" SET1 "")

(command "_rotate" SET1 "" p0 pause)
(initget "Y N _Yes No")
(setq option (getkword "\nDo you want to continue Draw Spline? (Yes/No): "))
(if (= option "Yes")
(progn
(setq SET2 (ssadd)) ; second selection set
(command "_spline" ) ; draw spline -> suppose here to change
(while (> (getvar 'cmdactive) 0)
(command pause)
)

(command "_change" "_l" "" "_p" "_lt" "CENTER" "_c" 8 "")
(ssadd (entlast) SET2)

(c:lisp2) ; i call in another lisp
)
(princ)
)

 

This existing code that i already simplified, i want to apply my new getpoint when it start draw the spline.

meaning first point of spline is set on new getpoint, and user will input others point to continue.

 

-> (command "_line" '(0.0 0.0) '(0.99 0.0) "")

0.99 0.0 is the point before it scale up and rotate.

 

i dont know if you can understand what am i explaining..

thank you in advance..

 

 

0 Likes
Accepted solutions (1)
899 Views
6 Replies
Replies (6)
Message 2 of 7

Sea-Haven
Mentor
Mentor

I would like at pt then scale then angle use polar to draw the line from pt to pt2 (setq pt2 (polar pt ang (* sf 0.99)))

 

You can (getvar 'lastpoint) this should be the end point add that as start pt to your selection set if required.

 

Use (getangle can use 2 points or enter a value. (setq ang (getangle pt1))

0 Likes
Message 3 of 7

Kent1Cooper
Consultant
Consultant
Accepted solution

If I understand what's going on, you should be able to just feed in the endpoint of the last object as the start of the Spline:

....

  (command "_spline" (vlax-curve-getEndPoint (entlast)))

....

 

There are other simplifications I could suggest, but first see whether that does what you want.

 

If the (vl...) functions are not already loaded, you will need to add

  (vl-load-com)

to the file.  It can be before or after the (defun) [or even inside it, but if inside, it will unnecessarily run every time you use the command].

Kent Cooper, AIA
0 Likes
Message 4 of 7

Sea-Haven
Mentor
Mentor

No need for VL if line was last object created.

 

(command "spline" (getvar 'lastpoint))

 

0 Likes
Message 5 of 7

Kent1Cooper
Consultant
Consultant

@Sea-Haven wrote:

No need for VL if line was last object created.

(command "spline" (getvar 'lastpoint))

It was, but it's been Moved and Scaled and Rotated since then,so the last point specified is no longer the end of the Line.

Kent Cooper, AIA
0 Likes
Message 6 of 7

Sea-Haven
Mentor
Mentor

Yeah that will screw it up, I took the approach of drawing the line at correct start point, angle and distance = scale * 0.99 so not moved. Not sure why the OP was making it, moving and scaling.

0 Likes
Message 7 of 7

aliff_ahtenk
Enthusiast
Enthusiast

@Sea-Haven i not try it yet. coz i need to put the item on exact point, if i change it, it will be the same coz i will need to find the others end too..

 

@Kent1Cooper i use your code and it does what i needed for.

 

thanks to both of you, and other people that help me on my lisp. i also use others lisp and do some changes on it to work like what i want. If anybody want to upgrade and adjust, you all may use it and adjust..

 

the things that need to upgrade is, when i finish the spline, it auto draw the next lisp. which mean it skip the process of inserting the size and select the spline. so as it so far can work well, i just use it.. now easy to draw n do not need to make a template anymore. so i can use drop or flex both in the same lisp.

0 Likes