Message 1 of 3
Change from single selection to multiple selection issue
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
This routine created by Lee Mak and slightly modified in order to set arrow head and dimension text size according to drawing scale can manage one object per routine invoking step
;; Dimension Along Curve ;; Created by Lee Mac 2012 ;; Saved from: https://forums.autodesk.com/t5/civil-3d-forum/dimension-along-polyline/td-p/6259008 ;; Slightly modified by Igal Averbuh 2018 (added option to set arrow head and dimension text size) (defun c:dac ( / _line _arrow a b cm el en p q pt ) (setvar 'DIMASZ (cond ((getdist (strcat "\nSpecify Arrow Head Size <" (rtos (getvar 'DIMASZ)) ">: "))) ((getvar 'DIMASZ)) ) ) (setvar 'dimtxt (cond ((getdist (strcat "\nSpecify Dimension Text Size <" (rtos (getvar 'dimtxt)) ">: "))) ((getvar 'dimtxt)) ) ) (defun _line ( a b ) (entmake (list '(0 . "LINE") (cons 10 a) (cons 11 b))) ) (defun _arrow ( a b ) (entmake (list '(0 . "LWPOLYLINE") '(100 . "AcDbEntity") '(100 . "AcDbPolyline") '(90 . 2) '(70 . 0) (cons 10 a) '(40 . 0.0) (cons 41 (/ (distance a b) 3.0)) (cons 10 b) ) ) ) (while (progn (setvar 'errno 0) (setq en (car (entsel))) (cond ( (= 7 (getvar 'errno)) (princ "\nMissed, try again.") ) ( (eq 'ename (type en)) (if (not (wcmatch (cdr (assoc 0 (entget en))) "ARC,CIRCLE,ELLIPSE,LINE,LWPOLYLINE,SPLINE")) (princ "\nInvalid Object Selected.") ) ) ) ) ) (if (and en (setq pt (getpoint "\nSpecify Dimension Offset: " (trans (vlax-curve-getpointatparam en (/ (+ (vlax-curve-getendparam en) (vlax-curve-getstartparam en)) 2.0) ) 0 1 ) ) ) ) (progn (setq el (entlast) cm (getvar 'cmdecho) ) (setvar 'cmdecho 0) (command "_.offset" "_T" en "_non" pt "") (setvar 'cmdecho cm) (if (equal el (setq el (entlast))) (princ "\nUnable to Create Dimension Line.") (progn (setq a (vlax-curve-getstartpoint en) b (vlax-curve-getstartpoint el) ) (_line (polar a (angle a b) (/ (distance a b) 6.0)) (polar b (angle a b) (/ (distance a b) 6.0)) ) (setq a (vlax-curve-getendpoint en) b (vlax-curve-getendpoint el) ) (_line (polar a (angle a b) (/ (distance a b) 6.0)) (polar b (angle a b) (/ (distance a b) 6.0)) ) (_arrow (vlax-curve-getstartpoint el) (polar (vlax-curve-getstartpoint el) (angle '(0.0 0.0 0.0) (vlax-curve-getfirstderiv el (vlax-curve-getstartparam el))) (getvar 'dimasz) ) ) (_arrow (vlax-curve-getendpoint el) (polar (vlax-curve-getendpoint el) (+ pi (angle '(0.0 0.0 0.0) (vlax-curve-getfirstderiv el (vlax-curve-getendparam el)))) (getvar 'dimasz) ) ) (setq a (vlax-curve-getpointatdist el (/ (vlax-curve-getdistatparam el (vlax-curve-getendparam el)) 2.0)) b (angle '(0.0 0.0) (vlax-curve-getfirstderiv el (vlax-curve-getparamatpoint el a))) p (polar a (+ b (/ pi 2.0)) (getvar 'dimtxt)) q (polar a (- b (/ pi 2.0)) (getvar 'dimtxt)) ) (if (< (distance p (vlax-curve-getclosestpointto en p)) (distance q (vlax-curve-getclosestpointto en q)) ) (setq p q) ) (entmake (list '(000 . "TEXT") (cons 10 p) (cons 11 p) (cons 40 (getvar 'dimtxt)) (cons 01 (rtos (vlax-curve-getdistatparam en (vlax-curve-getendparam en)))) (cons 50 (LM:readable b)) '(072 . 1) '(073 . 2) ) ) ) ) ) ) (princ) ) ;; Readable - Lee Mac ;; Returns an angle corrected for text readability. (defun LM:readable ( a ) ( (lambda ( a ) (if (< a 0.0) (LM:readable a) (if (and (< (* pi 0.5) a) (<= a (* pi 1.5))) (LM:readable (+ a pi)) a ) ) ) (rem (+ a pi pi) (+ pi pi)) ) ) (vl-load-com) (princ) (c:dac)
Program working properly but I think will be better if it can take multiple selection and make needful dimensioning for all selected objects at once.. something like this
(if(setq plSet(ssget '((0 . "ARC,CIRCLE,ELLIPSE,LINE,LWPOLYLINE,SPLINE")))) (progn (setq pLlst(vl-remove-if 'listp (mapcar 'cadr(ssnamex plSet)))) (foreach pl pLlst ...
like in example (see attached lisp)
Can somebody help me to do this?
Any help will be very appretiated