jhonnying Posted November 14, 2011 Posted November 14, 2011 Hello to everyone! Can you please help me with a lsp program that automaticaly generate linear dimensions from the points of a polyline to a reference line, because with the classic comand (dimlinear) i can draw the dimension line each point at a time. I attached an dwg for you to understand better. Excuse my english please! Thanks! distance from polyline points to a reference line.dwg Quote
pBe Posted November 14, 2011 Posted November 14, 2011 Try this: (defun c:DimTwo(/ aDoc Space pl ReFL pt pt2 ss) (vl-load-com) (setq aDoc (vla-get-ActiveDocument (vlax-get-acad-object))) (setq Space (if (= 1 (getvar "CVPORT")) (vla-get-PaperSpace aDoc) (vla-get-ModelSpace aDoc) ) ) (prompt "\nSelect Polyline:") (if (and (setq Pl (ssget ":E:S:L" '((0 . "LWPOLYLINE")))) (progn (prompt "\nSelect Reference Line:") (setq RefL (ssget ":E:S:L" '((0 . "*LINE")))) ) ) (progn (setq RefL (vlax-ename->vla-object (ssname RefL 0))) (foreach pt (mapcar 'cdr (vl-remove-if-not '(lambda (x) (= (car x) 10)) (entget (ssname pl 0)) ) ) (vla-addDimRotated space (vlax-3d-point (append pt '(0.0))) (vlax-3d-point (setq pt2 (vlax-curve-getclosestpointto RefL pt)) ) (vlax-3d-point (mapcar (function (lambda (a b) (/ (+ a b) 2.))) pt pt2) ) 1.57079633 ) ) ) )(princ) ) Hope this helps Quote
jhonnying Posted November 14, 2011 Author Posted November 14, 2011 It work well! Thank you very much! Quote
pBe Posted November 14, 2011 Posted November 14, 2011 It work well! Thank you very much! You're welcome jhonnying Glad it worked for you. Cheers Quote
martinle Posted November 18, 2011 Posted November 18, 2011 Try this: (defun c:DimTwo(/ aDoc Space pl ReFL pt pt2 ss) (vl-load-com) (setq aDoc (vla-get-ActiveDocument (vlax-get-acad-object))) (setq Space (if (= 1 (getvar "CVPORT")) (vla-get-PaperSpace aDoc) (vla-get-ModelSpace aDoc) ) ) (prompt "\nSelect Polyline:") (if (and (setq Pl (ssget ":E:S:L" '((0 . "LWPOLYLINE")))) (progn (prompt "\nSelect Reference Line:") (setq RefL (ssget ":E:S:L" '((0 . "*LINE")))) ) ) (progn (setq RefL (vlax-ename->vla-object (ssname RefL 0))) (foreach pt (mapcar 'cdr (vl-remove-if-not '(lambda (x) (= (car x) 10)) (entget (ssname pl 0)) ) ) (vla-addDimRotated space (vlax-3d-point (append pt '(0.0))) (vlax-3d-point (setq pt2 (vlax-curve-getclosestpointto RefL pt)) ) (vlax-3d-point (mapcar (function (lambda (a b) (/ (+ a b) 2.))) pt pt2) ) 1.57079633 ) ) ) )(princ) ) Hope this helps Hello! Can someone help me? In Lisp, this brings me the following error message: "Incorrect string ssget mode" Thank you for your help! Martin Quote
pBe Posted November 19, 2011 Posted November 19, 2011 (ssget "_:E:S:L" '((0 . "LWPOLYLINE")))); Not sure though Quote
alanjt Posted November 19, 2011 Posted November 19, 2011 (ssget "_:E:S:L" '((0 . "LWPOLYLINE")))); Not sure though That would be my guess, since the OP's location is Austria. Quote
martinle Posted November 21, 2011 Posted November 21, 2011 Unfortunately, no. The error persists. Error message: Select Reference Line: with error: Incorrect string ssget mode Best regards Martin Quote
BlackBox Posted November 21, 2011 Posted November 21, 2011 I'd be interested to read the available SSGET modes for the Austrian acad*dev.chm Quote
Least Posted November 21, 2011 Posted November 21, 2011 Could this be modified to also work with horizontal distances? Ie the reference line is vertical. Cheers Quote
GP_ Posted November 21, 2011 Posted November 21, 2011 Could this be modified to also work with horizontal distances? Ie the reference line is vertical.Cheers Replace 0 to 1.57079633 ............................. ............................. ............................. (vlax-3d-point (mapcar (function (lambda (a b) (/ (+ a b) 2.))) pt pt2) ) [b]0[/b] ) ) ) )(princ) ) Quote
pBe Posted November 21, 2011 Posted November 21, 2011 Unfortunately, no. The error persists.Error message: Select Reference Line: with error: Incorrect string ssget mode Best regards Martin You "think" you may have to do the same for (setq RefL (ssget "_:E:S:L" '((0 . "*LINE")))); Since the error this time comes after the Polyline is selected Quote
pBe Posted November 21, 2011 Posted November 21, 2011 Could this be modified to also work with horizontal distances? Ie the reference line is vertical.Cheers uhhmmm Yes? | | | \/ Replace 0 to 1.57079633 Quote
martinle Posted November 21, 2011 Posted November 21, 2011 That would be my guess, since the OP's location is Austria. It works! Thank you! Best regards Martin Quote
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.