Jump to content

Recommended Posts

Posted

I'm sure there is a way to do this. i am using the command "arc" in my lisp file. and my mid point and my end point i need to store as a variable. at the moment it looks like this. but i would like it to work like the normal arc command showing the arc.

 

(command "arc" cent (setq mid (getpoint cent)) (setq pnt (getpoint mid)))

As Always thanks.

 

What i really need is the end point of the arc. i know there is a visal lisp way of doing this but i know nothing about that.

Posted

??

 

(defun _arc (centerpoint / ent)
 (setq ent (entlast))
 (command "_.arc" "_c" "_non" centerpoint)
 (while (eq (logand 1 (getvar 'CMDACTIVE)) 1) (command PAUSE))
 (if (not (equal ent (setq ent (entlast))))
   ent
 )
)

(defun c:Test (/ point arc)
 (vl-load-com)
 (if (and (setq point "\nSpecify center point: ")
          (setq arc (_arc point))
     )
   (vlax-curve-getEndPoint arc)
 )
)

 

Also/or, look at the LASPOINT variable. (getvar 'LASTPOINT)

Posted

Or, to use just Vanilla:

 

(defun c:Test ( / point arc )
   (if (and (setq point (getpoint "\nSpecify center point: "))
            (setq arc (_arc point))
            (setq arc (entget arc))
       )
       (polar
           (cdr (assoc 10 arc))
           (cdr (assoc 51 arc))
           (cdr (assoc 40 arc))
       )
   )
)

 

(using the '_arc' function as posted by Alan)

Posted
Or, to use just Vanilla:

 

(defun c:Test ( / point arc )
   (if (and (setq point (getpoint "\nSpecify center point: "))
            (setq arc (_arc point))
            (setq arc (entget arc))
       )
       (polar
           (cdr (assoc 10 arc))
           (cdr (assoc 51 arc))
           (cdr (assoc 40 arc))
       )
   )
)

 

(using the '_arc' function as posted by Alan)

LoL, I knew you were going to come along and post the vanilla way. I guess I shouldn't be so lazy. :P

Posted

Thanks the (getvar 'lastpoint) worked great also didnt make me change a lot of my code.

 

again Thanks.

Posted
Thanks the (getvar 'lastpoint) worked great also didnt make me change a lot of my code.

 

again Thanks.

I'd use the _arc command I posted and Lee's extraction method (no VLA required) - it's a lot more stable/reliable.

Posted
LoL, I knew you were going to come along and post the vanilla way. I guess I shouldn't be so lazy. :P

 

We are spoilt with the curve* functions :P

Posted
We are spoilt with the curve* functions :P

I couldn't agree more. I know how to get it the other way, but the vlax-curve* function just let's me be far too lazy. :P

Posted

well it doesnt work like i need it to. which is my fault i didnt explain how i needed it to work.

 

Select startpoint. (which is already defined as the insertion point of the object selected.

 

Then select midpoint.

 

Then select endpoint.

Posted
well it doesnt work like i need it to. which is my fault i didnt explain how i needed it to work.

 

Select startpoint. (which is already defined as the insertion point of the object selected.

 

Then select midpoint.

 

Then select endpoint.

Well, your original code has 'cent', so I assumed you were wanting to begin with the CENTER of the curve. The more information you provide, the better results you receive and the less time spent by others, trying to help.

 

(defun _arc (startpoint / ent)
 (setq ent (entlast))
 (command "_.arc" "_non" startpoint)
 (while (eq (logand 1 (getvar 'CMDACTIVE)) 1) (command PAUSE))
 (if (not (equal ent (setq ent (entlast))))
   ent
 )
)

Posted

Sorry about that. its actually the center point/Insertion point of the object that's selected. Forgive me.

 

thanks for the updated code. will check it out.

Posted
Sorry about that. its actually the center point/Insertion point of the object that's selected. Forgive me.

 

thanks for the updated code. will check it out.

No worries.
  • 5 years later...
Posted

Hi everyone,

 

I just do not understand a simple thing (Sorry for resurrecting the topic btw).

 

I just need to draw two arcs, connect with two lines and subtract (extruded cut) the generated shape from a 3D solid I already drew. Here is my solid.

 

I don't know how to write arc command.

 

(command "arc" ........

 

What should I write for the rest? Variables? Center point? Start point?

 

Is there any reference book you can suggest that shows how to use AutoCAD commands by AutoLISP?

 

I always have trouble AutoCAD commands like (command "something" ......)

 

Thanks for bearing with my dumb questions.

Posted
Hi everyone,

 

I just do not understand a simple thing (Sorry for resurrecting the topic btw).

 

I just need to draw two arcs, connect with two lines and subtract (extruded cut) the generated shape from a 3D solid I already drew. Here is my solid.

 

I don't know how to write arc command.

 

(command "arc" ........

 

What should I write for the rest? Variables? Center point? Start point?

 

Is there any reference book you can suggest that shows how to use AutoCAD commands by AutoLISP?

 

I always have trouble AutoCAD commands like (command "something" ......)

 

Thanks for bearing with my dumb questions.

 

When trying to replicate a native command, the easiest thing is to step through the command and fill in appropriate data, based on prompts.

 

eg.

Command: a ARC

Specify start point of arc or

:

Specify second point of arc or [Center/End]: e

 

Specify end point of arc:

Specify center point of arc (hold Ctrl to switch direction) or [Angle/Direction/Radius]: r

 

Specify radius of arc (hold Ctrl to switch direction): 50

 

would translate to

 

(if (and (setq p1 (getpoint "\nSpecify first point: "))
        (setq p2 (getpoint "\nSpecify end point: "))
        (setq rad (getreal "\nSpecify radius: "))
   )
 (command "_.arc" "_non" p1 "_e" "_non" p2 "_radius" rad)
)

 

The "_non" should always precede a point call so as to ignore any running osnaps.

Posted
When trying to replicate a native command, the easiest thing is to step through the command and fill in appropriate data, based on prompts.

 

eg.

 

 

would translate to

 

(if (and (setq p1 (getpoint "\nSpecify first point: "))
        (setq p2 (getpoint "\nSpecify end point: "))
        (setq rad (getreal "\nSpecify radius: "))
   )
 (command "_.arc" "_non" p1 "_e" "_non" p2 "_radius" rad)
)

 

The "_non" should always precede a point call so as to ignore any running osnaps.

 

Thanks a lot for your kind help!

 

In my code there are also lots of "line" commands. Should I write "_non" for line commands as well?

 

Thanks,

Posted
Thanks a lot for your kind help!

 

In my code there are also lots of "line" commands. Should I write "_non" for line commands as well?

 

Thanks,

 

ANYTIME a point would be specified, precede with "_non".

Posted
ANYTIME a point would be specified, precede with "_non".

 

Thank you sir, your suggestions helped me a lot.

 

But, I don't know how to change the direction of the arc. Please see the picture. I need the arc in other direction.

 

attachment.php?attachmentid=61284&cid=1&stc=1

Capture11.jpg

Posted
ANYTIME a point would be specified, precede with "_non".

 

Thank you again,

 

Last question I hope: How can I reverse the direction of the arc?

 

attachment.php?attachmentid=61285&cid=1&stc=1

JajyQW.jpg

Posted
ANYTIME a point would be specified, precede with "_non".

 

Thanks @alanjt

 

I tried to post one more question here but somehow I couldn't succeed.

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