Drawing a certain arc with AutoLISP

Drawing a certain arc with AutoLISP

Anonymous
Not applicable
1,833 Views
5 Replies
Message 1 of 6

Drawing a certain arc with AutoLISP

Anonymous
Not applicable

I need to draw an arc with beggining coordinates (x=0 y=0), end coordinates (x=20 y=-20), change it's direction and have an  angle of 135 degrees.

I tried the following in AutoLISP:

(defun C: arrows()
(setq t1 (getpoint))
(setq t2 (list(+ 20 (car t1)) (+ -20 (cadr t1))))
(command "arc" t1 "end" t2 "direction" 135))

Where's the problem?

0 Likes
Accepted solutions (1)
1,834 Views
5 Replies
Replies (5)
Message 2 of 6

hak_vz
Advisor
Advisor
Accepted solution
(defun c:arrows( / t1 t2) 
    (setq 
        t1 (getpoint "\n select first point > ") 
        t2 (list (+ 20 (car t1)) (+ -20 (cadr t1)))
    ) 
    (command "arc" t1 "e" t2 "d" -135 "")
    (princ)
)

 

Watch for space in your "c:  arrows " , command is rewritten and tangent direction set. At the end (princ) is added for silent exit , anf variables t1 and t2 are set to be local (in function).

Miljenko Hatlak

EESignature

Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
Message 3 of 6

cadffm
Consultant
Consultant

Please try to write a working way "by hand",
then you can start typing with a (command ....) to automate).

Your input does not work for the ARC command, so that did not have anything to do with Lisp in the first step.
Set dynmode off

and start

 

command: ARC<enter>

send your coordinates.. for example 60,40

send your option (i am pretty sure that END will not work the way you want, END starts the objects-snap-mode  ENDpoint 😉 )

so you have to send E or EN instead of END, right?

test it..

 

If you solve this part, there is the next problem with your direction.

Acad asks for coordinates and you send just 135, "135" isn't valid, or is it with your settings?

Perhaps you want  something like 1<135

but i am not sure what your thoughts are for "135".

135 degree in UCS from 0° ? Or 135degree from Start to endpoint?

EDIT> Or -135 ?

(and there is a mistake in your first line too: There shouldn't be a SPACE between C: and the function name!)

 

Sebastian

0 Likes
Message 4 of 6

cadffm
Consultant
Consultant

Someone gives the fish, someone try to teach for more understanding to find the solution for the current case and all the next 🙂

Kudo4u

Sebastian

0 Likes
Message 5 of 6

hak_vz
Advisor
Advisor

It would be great to have a section for beginners as sub-forum. I mostly like solving problems that I may encounter in my own practice and through conversation to learn something new.

I don't mind answering those simple questions as long as one doesn't misuse our willingness to help , without greasing elbows and showing effort to code. I remember how grasping autolisp wasn't so easy some 15 years ago, without forums, blogs ....

Miljenko Hatlak

EESignature

Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
0 Likes
Message 6 of 6

Kent1Cooper
Consultant
Consultant

[Whoops -- answered an early Message before noticing the others, but....]

 

Yes, no space after C: .

And the localizing of variables and the (princ) at the end are good ideas but optional [whether you do them will not affect whether the command works, if it's otherwise correctly defined].

 

But another thing that @hak_vz changed but didn't comment on deserves attention:  the use of just "e" [or "_e"] to get the End option in the Arc command.  In a command-line Arc command like this, if you spell out  "end", it will be taken as an Object-Snap ENDpoint call!  So the next prompt will be  'of'  awaiting Osnapping to something, rather than the location prompt you really need there.

Kent Cooper, AIA
0 Likes