Mitch Ellis Posted 23 hours ago Posted 23 hours ago (edited) (defun c:PLD (/ ent obj i p1 p2) (vl-load-com) (if (setq ent (car (entsel "\nSelect Polyline to Dimension: "))) (progn (setq obj (vlax-ename->vla-object ent)) (if (= (vla-get-ObjectName obj) "AcDbPolyline") (progn (setvar "cmdecho" 0) (command "._undo" "_begin") (setq i 0) ;; Loop through vertices (repeat (fix (- (vlax-curve-getEndParam obj) 1)) (setq p1 (vlax-curve-getPointAtParam obj i) p2 (vlax-curve-getPointAtParam obj (1+ i))) ;; Create aligned dimension (command "_.dimaligned" "_none" p1 "_none" p2 "_none" (polar p1 (+ (angle p1 p2) (/ pi 2)) 1.0)) (setq i (1+ i)) ) (command "._undo" "_end") (setvar "cmdecho" 1) ) (princ "\nSelected object is not a LightWeight Polyline.") ) ) ) (princ) ) (princ "\nType 'DimPlineSegments' to run.") Edited 19 hours ago by SLW210 Added Code Tags!! Quote
SLW210 Posted 19 hours ago Posted 19 hours ago In the future please place your code in Code Tags. (<> in the editor toolbar) Quote
BIGAL Posted 15 hours ago Posted 15 hours ago (edited) Another way to approach this ";; Loop through vertices" is to get all the vertices and simply use those XY values of the corresponding two points in a repeat. You can check the readabilty of the answer by looking at the angle of the two points, so place answer above or below. There are plenty of label plines out there do a google, "Kent Cooper" has some good ones. may be faster than debugging what you have. setq plent (entsel "\nPick pline")) (if plent (setq co-ord (mapcar 'cdr (vl-remove-if-not '(lambda (x) (= (car x) 10)) (entget (car plent)))))) (princ co-ord) Edited 15 hours ago by BIGAL Quote
Nikon Posted 1 hour ago Posted 1 hour ago Perhaps it will suit you. Polyline Dimension by marko_ribar (defun c:pdim ( / ListClockwise-p ch plSet pLlst vLst oldOsn cAng cDis cPt ) ;;; Polyline Dimension by marko_ribar ;;;https://www.cadtutor.net/forum/topic/54351-automatic-distance-between-polygon-vertices/#comment-451128 ;;; posted https://forum.dwg.ru/forumdisplay.php?f=13 (vl-load-com) (defun ListClockwise-p ( lst / z vlst ) (vl-catch-all-apply 'minusp (list (if (not (equal 0.0 (setq z (apply '+ (mapcar (function (lambda (u v) (- (* (car u) (cadr v)) (* (car v) (cadr u))) ) ) (setq vlst (mapcar (function (lambda (a b) (mapcar '- b a)) ) (mapcar (function (lambda (x) (car lst))) lst) (cdr (reverse (cons (car lst) (reverse lst)))) ) ) (cdr (reverse (cons (car vlst) (reverse vlst)))) ) ) ) 1e-6 ) ) z (progn (prompt "\n\nChecked vectors are colinear - unable to determine clockwise-p of list") nil ) ) ) ) ) (initget 1 "Outside Inside") (setq ch (getkword "\nChoose on which side to put dimensions [Outside/Inside] : ")) (princ "\n<<< Select LwPolyline(s) for dimensioning >>> ") (if (setq plSet (ssget '((0 . "LWPOLYLINE")))) (progn (setq pLlst (vl-remove-if 'listp (mapcar 'cadr(ssnamex plSet))) oldOsn (getvar "OSMODE") ); end setq (setvar "OSMODE" 0) (setvar "CMDECHO" 0) (command "_.undo" "_be") (foreach pl pLlst (setq vLst (mapcar '(lambda( x ) (trans x 0 1)) (mapcar 'cdr (vl-remove-if-not '(lambda( x ) (= 10 (car x))) (entget pl) ) ) ) ); end setq (if (equal (logand (cdr (assoc 70 (entget pl))) 1) 1) (setq vLst (append vLst (list (car vLst)))) ); end if (if (not (ListClockwise-p vLst)) (setq vLst (reverse vLst))) (while (< 1 (length vLst)) (setq cAng (angle (car vLst) (cadr vLst)) cDis (/ (distance (car vLst) (cadr vLst)) 2.0) ) ;_ (if (>= (caar vLst) (caadr vLst)) ;_ (setq cAng (- cAng pi)) ;_ ); end if (if (eq ch "Inside") (setq cPt (polar (polar (car vLst) cAng cDis) (- cAng (* 0.5 pi)) (* 2.5 (getvar "DIMTXT")))); end setq (setq cPt (polar (polar (car vLst) cAng cDis) (+ cAng (* 0.5 pi)) (* 2.5 (getvar "DIMTXT")))); end setq ); end if (command "_.dimaligned" (car vLst) (cadr vLst) cPt) (setq vLst (cdr vLst)) ); end while ); end foreach (command "_.undo" "_e") (setvar "OSMODE" oldOsn) (setvar "CMDECHO" 1) ); end progn ); end if (princ) ) 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.