Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Perpendicular line to a curve with length and point on a curve

6 REPLIES 6
SOLVED
Reply
Message 1 of 7
user_sf
2158 Views, 6 Replies

Perpendicular line to a curve with length and point on a curve

Hi AutoCAD gurus,

 

I am strugling with finding a way to build a perpendicular line to a curve. I have a curve (arc) and a point on it through which I would like to build a perpendicular line. This line has to be a perpedicular to arc. Arc is in XY plane. It seems like CAD wants the second point but I would like to provide only the origin point on an arc and a length.

 

(command "line" "_per" ....)

 

Is this possible in AutoCAD? Thanks

6 REPLIES 6
Message 2 of 7
p_mcknight
in reply to: user_sf

Remember that any line perpendicular to an arc passes through its centerpoint.  If you get the centerpoint of the arc you can use the angle from the cp to the point on the arc to get the perpendicular angle that you are after and then use polar to go to where you want.  Something along the lines of

(command ".line" p1 (polar p1 (angle cp p1) length) "")

I'll leave it up to you to get the centerpoint and whatnot.

 

Message 3 of 7
Kent1Cooper
in reply to: user_sf


@user_sf wrote:

.... 

I am strugling with finding a way to build a perpendicular line to a curve. I have a curve (arc) and a point on it through which I would like to build a perpendicular line. This line has to be a perpedicular to arc. Arc is in XY plane. ....


Here's a way to do it for any object type with linearity [Line/Arc/Circle/Polyline/Ellipse/Spline/Ray/Xline]:

 

(vl-load-com); if not already done

(setq orth (getvar 'orthomode)); current Ortho on/off value

(if (setq esel (entsel "\nSelect object at point to draw Line from: "))

  (progn ; then

    (setq

      ent (car esel)

      pt (osnap (cadr esel) "_nea")

    ); setq

    (setvar 'snapang (angle '(0 0 0) (vlax-curve-getFirstDeriv ent pt))); direction of selected entity at selection point

    (setvar 'orthomode 1)

    (command "_.line" "_none" pt pause "")

    (setvar 'orthomode orth); reset

  ); progn

  (prompt "\nMissed..."); else

); if

 

That's for a single Line.  It could be made to let the User draw more than one at the same angle [and perpendicular to it] before resetting the Snap angle.

 

If you know the length of the Line, it could be done without changing the SNAPANG setting, using (polar), but there's the issue of in which of the two perpendicular directions to go from the selected object.  If you always do it with Arcs/Circles/Ellipses and always either outward or inward, that could easily be built in.  For other entity types or if the direction from those types may be either way, it would probably need to ask the User to select a side.

Kent Cooper, AIA
Message 4 of 7
user_sf
in reply to: Kent1Cooper

Thank you. What would be a good way to learn VLISP? While I can copy the code, decoding and especially writing it is very dificult. I think I've got a good grasp with AutoLisp now. What would be a good resource to start learning VLISP?

Message 5 of 7
user_sf
in reply to: p_mcknight

Good point. Thanks.
Message 6 of 7
p_mcknight
in reply to: user_sf

The best way I found to learn vlisp is to look at other peoples code.  Once you learn the two or three basics, the rest is easy.  There are a couple of good charts out there showing all of the visual lisp commands.  Once I got past the fear factor I found that in many ways visual lisp is easier than just straight vanilla lisp.

Message 7 of 7
user_sf
in reply to: p_mcknight

Got it. I'll try. Thanks.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost