View Full Version : Dimension multiple lines automatically
cormac.mcgavigan516711
2011-12-06, 06:49 AM
I have an underground ductwork drawing with over 1500 individual ducts (each drawn as a line). I need to dimension the length of each one. Is there a routine that could do this for me automagically?
I'm as yet only a beginner at lisp, and cant wait the few months needed to learn to do it myself!!
Tharwat
2011-12-06, 07:41 AM
This routine would help you but not automagically ;) .
(defun c:TesT (/ spc acdoc Textheight CurrentTextstyle selectionset)
;;; Tharwat 06. Dec. 2011 ;;;
(vl-load-com)
(setq spc (if (> (vla-get-activespace (setq acdoc (vla-get-activedocument (vlax-get-acad-object)))) 0)
(vla-get-modelspace acdoc)
(vla-get-paperspace acdoc)
)
)
(setq Textheight
(if (eq (cdr (assoc 40 (setq CurrentTextstyle (entget (tblobjname "style" (getvar 'Textstyle)))))) 0.)
(cdr (assoc 42 CurrentTextstyle))
(cdr (assoc 40 CurrentTextstyle))
)
)
(if (setq selectionset (ssget '((0 . "LINE"))))
(progn (vla-StartUndoMark acdoc)
((lambda (intger / selectionsetname entgetlist dimension p1 p2)
(while (setq selectionsetname (ssname selectionset (setq intger (1+ intger))))
(setq entgetlist (entget selectionsetname))
(setq dimension (vla-adddimaligned
spc
(vlax-3d-point (setq p1 (cdr (assoc 10 entgetlist))))
(vlax-3d-point (setq p2 (cdr (assoc 11 entgetlist))))
(vlax-3d-point (polar p1 (+ (angle p1 p2) (/ pi 2.)) (+ (* Textheight 0.4) Textheight)))
)
)
(vla-put-textrotation dimension (angle p1 p2))
)
)
-1
)
(vla-EndUndoMark acdoc)
)
(princ "\n < *** No lines selected *** >")
)
(princ)
)
marko_ribar
2011-12-06, 11:17 AM
Although Tharwat already answered to your specific request, you may find this also useful... I've included here (http://forums.augi.com/showthread.php?t=134324&page=3&p=1149955) also LINE objects...
Regards, M.R.
8-)
Tharwat
2011-12-06, 12:58 PM
This routine is a little bit better for the rotation of dimension texts .
(defun c:TesT (/ spc Textheight CurrentTextstyle selectionset)
;;; Tharwat 06. Dec. 2011 ;;;
(vl-load-com)
(cond ((not acdoc) (setq acdoc (vla-get-activedocument (vlax-get-acad-object)))))
(setq spc (if (> (vla-get-activespace acdoc) 0)
(vla-get-modelspace acdoc)
(vla-get-paperspace acdoc)
)
)
(setq Textheight
(if (eq (cdr (assoc 40 (setq CurrentTextstyle (entget (tblobjname "style" (getvar 'Textstyle)))))) 0.)
(cdr (assoc 42 CurrentTextstyle))
(cdr (assoc 40 CurrentTextstyle))
)
)
(if (setq selectionset (ssget '((0 . "LINE"))))
(progn (vla-StartUndoMark acdoc)
((lambda (intger / selectionsetname entgetlist dimension p1 p2)
(while (setq selectionsetname (ssname selectionset (setq intger (1+ intger))))
(setq entgetlist (entget selectionsetname))
(setq dimension (vla-adddimaligned
spc
(vlax-3d-point (setq p1 (cdr (assoc 10 entgetlist))))
(vlax-3d-point (setq p2 (cdr (assoc 11 entgetlist))))
(vlax-3d-point (polar p1 (+ (angle p1 p2) (/ pi 2.)) (+ (* Textheight 0.4) Textheight)))
)
)
(vla-put-textrotation
dimension
(if (and (> (angle p1 p2) (/ pi 2.)) (< (angle p1 p2) (* pi 1.5)))
(+ (angle p1 p2) pi)
(angle p1 p2)
)
)
)
)
-1
)
(vla-EndUndoMark acdoc)
)
(princ "\n < *** No lines selected *** >")
)
(princ)
)
Powered by vBulletin® Version 4.2.5 Copyright © 2025 vBulletin Solutions Inc. All rights reserved.