rvalusa22 Posted December 23, 2015 Share Posted December 23, 2015 Hello All, I need to bisect a line and draw a line perpendicular from mid point and with user defined length using AUTO LISP routine? Your help is very much appreciated. Thanks rajesh Quote Link to comment Share on other sites More sharing options...
BKT Posted December 23, 2015 Share Posted December 23, 2015 Rajesh, take a look at the first "Similar Thread" at the bottom of this page. There's a LISP called per.lsp that works very well. Quote Link to comment Share on other sites More sharing options...
Tharwat Posted December 23, 2015 Share Posted December 23, 2015 This? (defun c:Test (/ l s e 1p 2p 3p ang c g) ;; Tharwat 23.Dec.2015 ;; (if (and (setq l (getdist "\nSpecify length of line :")) (setq s (car (entsel "\nSelect Line :"))) (eq (cdr (assoc 0 (setq e (entget s)))) "LINE") (setq 1p (cdr (assoc 10 e)) 2p (cdr (assoc 11 e)) ang (angle 1p 2p) c (mapcar '(lambda (q p) (/ (+ q p) 2.)) 1p 2p) ) (princ "\nSpecify distination :") ) (progn (while (eq 5 (car (setq g (grread t 13 0)))) (redraw) (grdraw c (setq 3p (polar c (apply (if (> 0 (sin (- ang (angle 1p (cadr g))))) '+ '- ) (list ang (* pi 0.5)) ) l ) ) -1 0 ) ) (if (member (car g) '(2 3 25)) (entmake (list '(0 . "LINE") (cons 10 c) (cons 11 3p)) ) ) ) ) (redraw) (princ) ) Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted December 23, 2015 Share Posted December 23, 2015 As suggested by BKT, see the responses in this thread. Quote Link to comment Share on other sites More sharing options...
qhabz Posted October 19, 2016 Share Posted October 19, 2016 is there a way this work for polylines please? i am working mostly with polylines... Quote Link to comment Share on other sites More sharing options...
BKT Posted October 19, 2016 Share Posted October 19, 2016 Read Lee Mac's post just above yours and then go to the thread he indicates and try his first code. I think it will work fine as long as your polylines have only 2 vertices. Quote Link to comment Share on other sites More sharing options...
BIGAL Posted October 20, 2016 Share Posted October 20, 2016 BKT there are ways of picking a section of a pline, so in this case this would give the answer of between 2 points. Lee ? Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted October 24, 2016 Share Posted October 24, 2016 Read Lee Mac's post just above yours and then go to the thread he indicates and try his first code. I think it will work fine as long as your polylines have only 2 vertices. BKT there are ways of picking a section of a pline, so in this case this would give the answer of between 2 points. Lee ? Here is a modified version compatible with both lines & 2D polylines: (defun c:per ( / ent enx par pt1 pt2 sel ) (while (progn (setvar 'errno 0) (setq sel (entsel "\nSelect line or polyline segment: ")) (cond ( (= 7 (getvar 'errno)) (princ "\nMissed, try again.") ) ( (null sel) nil) ( (progn (setq ent (car sel) enx (entget ent) ) (not (wcmatch (cdr (assoc 0 enx)) "LINE,LWPOLYLINE")) ) (princ "\nSelected object is not a line or polyline.") ) ( (if (= "LINE" (cdr (assoc 0 enx))) (setq pt1 (trans (cdr (assoc 10 enx)) 0 1) pt2 (trans (cdr (assoc 11 enx)) 0 1) ) (setq par (fix (+ 1e-8 (vlax-curve-getparamatpoint ent (vlax-curve-getclosestpointto ent (trans (cadr sel) 1 0))))) pt1 (vlax-curve-getpointatparam ent par) pt2 (vlax-curve-getpointatparam ent (1+ par)) ) ) (vl-cmdf "_.line" "_non" (mapcar '(lambda ( a b ) (/ (+ a b) 2.0)) pt1 pt2) (strcat "<" (angtos (+ (angle pt1 pt2) (/ pi 2.0)))) "\\" "" ) ) ) ) ) (princ) ) (vl-load-com) (princ) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.