minejash Posted August 8, 2018 Share Posted August 8, 2018 (edited) hai, i need a small help.i have a working lisp routine which gives perpendicular line distance to main line when clicked on a place perpendicular, only thing i want to try and add is to remove the leader that adds and only add text without leader in position where i can click. pls reply if its possible... thanks:) (defun c:Test ( / s p c a d) (if (and (setq s (car (entsel "\nPick a polyline :"))) (or (= (cdr (assoc 0 (entget s))) "LWPOLYLINE") (alert "Invalid object! Please pick a polyline only.") ) (setq p (getpoint "\nSpecify point perpendicular to polyline :")) (setq c (vlax-curve-getclosestpointto s p)) (setq a (angle p c)) (not (grdraw p c 1 -1)) ;; rubber line in red colour. (setq d (angle '(0. 0. 0.) (vlax-curve-getfirstderiv s (vlax-curve-getparamatpoint s c)))) (or (or (equal (rem (+ d (* pi 0.5)) (+ pi pi)) a 1e-4) (equal (rem (+ d (* pi 1.5)) (+ pi pi)) a 1e-4) ) (alert "Picked point is not a perpendicular to picked polyline. <!>") ) ) (command "_.leader" "_non" p "\\" "" (strcat "CHAINAGE=3+0" (rtos (vlax-curve-getdistatpoint s c) 2 4)) "") ) (princ) ) (vl-load-com) Edited August 8, 2018 by SLW210 Fixed Code Tags Quote Link to comment Share on other sites More sharing options...
satishrajdev Posted August 8, 2018 Share Posted August 8, 2018 Try this :- (defun c:Test (/ s p c a d) (if (and (setq s (car (entsel "\nPick a polyline :"))) (or (= (cdr (assoc 0 (entget s))) "LWPOLYLINE") (alert "Invalid object! Please pick a polyline only.") ) (setq p (getpoint "\nSpecify point perpendicular to polyline :")) (setq c (vlax-curve-getclosestpointto s p)) (setq a (angle p c)) (not (grdraw p c 1 -1)) ;; rubber line in red colour. (setq d (angle '(0. 0. 0.) (vlax-curve-getfirstderiv s (vlax-curve-getparamatpoint s c) ) ) ) (or (or (equal (rem (+ d (* pi 0.5)) (+ pi pi)) a 1e-4) (equal (rem (+ d (* pi 1.5)) (+ pi pi)) a 1e-4) ) (alert "Picked point is not a perpendicular to picked polyline. <!>" ) ) ) (entmakex (list '(0 . "text") '(100 . "AcDbEntity") '(67 . 0) '(370 . 13) '(100 . "AcDbText") (cons 10 p) (cons 40 2.5) [color="red"]; Change text height here[/color] (cons 1 (strcat "chainage=3+0" (rtos (vlax-curve-getdistatpoint s c) 2 4) ) ) (cons 71 0) (cons 72 0) (cons 11 '(0 0 0)) '(100 . "AcDbText") (cons 73 0) ) ) ) (princ) ) (vl-load-com) Quote Link to comment Share on other sites More sharing options...
minejash Posted August 8, 2018 Author Share Posted August 8, 2018 Thank u, it works good but just want to know if its possible to select the text location manually, as this code lets the text at the point where i click for distance. Like the leader starts and then text location except no leader needed, only text. If possible it would be nice. This code really helps a lot, thank you so much.. Quote Link to comment Share on other sites More sharing options...
minejash Posted August 8, 2018 Author Share Posted August 8, 2018 also is it possible to continous the command after i select the polyline, like i select the polyline then after were ever i click it gives the distance to it, (like MULTIPLE command). the current command ask for polyline after every click and length.. thanks:) Quote Link to comment Share on other sites More sharing options...
satishrajdev Posted August 8, 2018 Share Posted August 8, 2018 Command is continuous in this code as per your requirement: (defun c:Test (/ s p c a d tp) (if (and (setq s (car (entsel "\nPick a polyline :"))) (or (= (cdr (assoc 0 (entget s))) "LWPOLYLINE") (alert "Invalid object! Please pick a polyline only.") ) ) (while (and (setq p (getpoint "\nSpecify point perpendicular to polyline :") ) (setq c (vlax-curve-getclosestpointto s p)) (setq a (angle p c)) (not (grdraw p c 1 -1)) ;; rubber line in red colour. (setq d (angle '(0. 0. 0.) (vlax-curve-getfirstderiv s (vlax-curve-getparamatpoint s c) ) ) ) (or (or (equal (rem (+ d (* pi 0.5)) (+ pi pi)) a 1e-4) (equal (rem (+ d (* pi 1.5)) (+ pi pi)) a 1e-4) ) (alert "Picked point is not a perpendicular to picked polyline. <!>" ) ) (setq tp (getpoint "\nSpecify Point for Text : ")) ) (entmakex (list '(0 . "text") '(100 . "AcDbEntity") '(67 . 0) '(370 . 13) '(100 . "AcDbText") (cons 10 tp) (cons 40 2.5) ; Change text height here (cons 1 (strcat "chainage=3+0" (rtos (vlax-curve-getdistatpoint s c) 2 4) ) ) (cons 71 0) (cons 72 0) (cons 11 '(0 0 0)) '(100 . "AcDbText") (cons 73 0) ) ) ) ) (princ) ) (vl-load-com) Quote Link to comment Share on other sites More sharing options...
satishrajdev Posted August 8, 2018 Share Posted August 8, 2018 also is it possible to continous the command after i select the polyline, like i select the polyline then after were ever i click it gives the distance to it, (like MULTIPLE command). the current command ask for polyline after every click and length.. thanks:) I've updated code above for continuous operation, check it Quote Link to comment Share on other sites More sharing options...
minejash Posted August 8, 2018 Author Share Posted August 8, 2018 Thank you so much. It works perfectly... i didn't know how to change the code to simple text sting, thanks so much... Quote Link to comment Share on other sites More sharing options...
satishrajdev Posted August 8, 2018 Share Posted August 8, 2018 You're welcome Quote Link to comment Share on other sites More sharing options...
SLW210 Posted August 8, 2018 Share Posted August 8, 2018 Please read the Code Posting Guidelines and have your Code to be included in Code Tags.[NOPARSE] Your Code Here[/NOPARSE] = Your Code Here 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.