Javascript required
Skip to content Skip to sidebar Skip to footer

Draw Section Line in Autocad 2016


@ah2m67 wrote:

How to drawing a perpendicular line from a point on the line ?


I think most other Replies have misunderstood what you want to do.  Several are about the ordinary PERpendicular Object Snap mode, which is PERpendicular to something.  As I read it [it seems pretty clear from your wording], you want to draw perpendicular from something, and without necessarily anything else around that you can go PERpendicular to.  You can do that without needing to change the UCS as has been suggested, by using the "<angle" format and feeding in the angle perpendicular to the object [in your request, a Line, but any appropriate object] at the specified point.  Try this:

(defun pf ()   (strcat     "<"     (angtos       (+         (angle           '(0 0 0)           (vlax-curve-getFirstDeriv             (setq ent (car (nentselp (getvar 'lastpoint)))); entity             (vlax-curve-getParamAtPoint               ent               (osnap (getvar 'lastpoint) "_nea")             ); ...Param           ); ...FirstDeriv         ); angle         (/ pi 2); [perpendicular]       ); +       (getvar 'aunits) 8     ); rtos   ); strcat ); defun (vl-load-com)

Include that in your acaddoc.lsp file if you have one, or save that to a file with a .lsp filetype ending, named whatever you want [I would call it something like PerFrom.lsp], and APPLOAD it.

It is written to be used after you have given whatever you're drawing a first point.  It's not restricted to drawing a Line, but can be used in drawing a Polyline, or for a Text rotation, or for the second point of a Move or Copy displacement, or for other purposes.  And it doesn't need to be a point on a Line that you start from , but can be on anything with linearity [Line, Polyline, Arc, Circle, Spline, Ellipse] -- anything that qualifies in the "curve" class for (vlax-curve-...) functions.

Usage:  in the case of your request -- drawing a Line perpendicular from another Line -- call up the Line command and give it a starting point at the place you want to draw perpendicular from on the existing Line [whether using NEArest or ENDpoint or MIDpoint Object Snap, or with Snap on if the existing Line was drawn that way, or whatever].  Then, when it's asking for the next point, type in (pf) [with the parentheses], which stands for " p erpendicular f rom".  That will lock in the direction for drawing the new Line to perpendicular [in either direction] from the existing one.

Use it similarly for the other purposes mentioned -- any time it's asking for a next point when the previous point was on some object with linearity.  In drawing a Line or Polyline, it can also be used for the next Line or Polyline segment, and will lock the direction in to perpendicular from the latest segment.

If that works for you, you can put it into a menu item to pick on, if that's easier than typing it in.

[By the way, it isn't written to account for, and I haven't tried it in, other-than-World Coordinate Systems, but could probably be adjusted for that, if necessary.  It also wants the from point to be unambiguous, that is, if you pick at something like an INTersection, I don't think you can control which intersecting object it's going to find the perpendicular direction from.]

Kent Cooper, AIA

Draw Section Line in Autocad 2016

Source: https://forums.autodesk.com/t5/autocad-forum/drawing-a-perpendicular-line-from-a-point-on-the-line/td-p/6670460