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
Solved! Go to Solution.
Solved by Kent1Cooper. Go to Solution.
Solved by p_mcknight. Go to Solution.
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.
@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.
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?
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.