- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
So at work we have to dimension the left and right side of these walls, which are depicted by a closed four sided polyline. They are all perfectly up and down on the sides. There are sometimes hundreds of them so this takes awhile...plus we like to have the dim distances and text just so, so that adds additional time.
I have limited ability with Lisp, but i've created a little routine (with a little help from the community, thanks guys!) that makes it a bit faster (see attached). Here are the steps:
- It asks you for a sample template dimension to match properties with.
- It then has you pick the left side of the wall (you have to click a second time to place the dim). Once it is down it adjust the extension line distance and the text for you and then you move on to the right side of the wall.
- Loop back to #2.
It is working ok.....my question is.....is there any way it could be better? I've exhausted my own knowledge on lisps, but maybe one of you brilliant minds sees a simple solution to make it even more awesome. It would be ideal if I could just click on the polyline once and it would automatically dimension the left and right without any further clicks. This is way beyond my abilities and I don't even know where to begin. Any thoughts?
I've attached the file and listed the code below. I really appreciate any help you guys give.....these little routines make the boring parts of work so much easier!
(defun c:dtu (/ )
(setvar "CMDECHO" 0)
(setq Units (getint "\n[1] English (Default) [2] Metric: ")) ;setting units
(if (= Units 2)
(progn
(setq DimDistance 0.4)
(setq TextOffset 0.2))
(progn
(setq DimDistance 18)
(setq TextOffset 6.1)))
(setq TypicalDim (entsel "\nSelect Template Dimension: ")) ;setting dimension to match prop to
(while (= 0 0)
(princ "\nSelect left side: ")
(command "_dimlinear" "" pause pause) ;selecting the left side of the wall and creating the dim
(command "_matchprop" TypicalDim (entlast) "") ;matching properties with the template
;Dim just created, now to move it to the correct position
(setq NewDim (entget (ssname (ssget "l") 0))) ; get newly created dim
(setq 10Position (assoc 10 NewDim))
(setq 11Position (assoc 11 NewDim))
(setq BasePosition (assoc 13 NewDim))
(setq WantedX (- (nth 1 BasePosition) DimDistance))
(setq New10Position (subst WantedX (nth 1 10Position) 10Position))
(setq New11Position (subst WantedX (nth 1 11Position) 11Position))
(setq NewDim (subst New10Position 10Position NewDim))
(setq NewDim (subst New11Position 11Position NewDim))
(entmod NewDim)
(vl-load-com) ;now moving the text over
(setq e (entlast))
(setq obj (vlax-ename->vla-object e))
(setq tp (vlax-get obj 'textposition))
(setq tp (mapcar '- tp (list TextOffset 0 0)))
(vlax-put obj 'textposition tp)
(princ "\nSelect right side: ") ;now doing the same thing to the right side
(command "_dimlinear" "" pause pause)
(command "_matchprop" TypicalDim (entlast) "")
;Dim just created, now to move it to the correct position
(setq NewDim (entget (ssname (ssget "l") 0))) ; get newly created dim
(setq 10Position (assoc 10 NewDim))
(setq 11Position (assoc 11 NewDim))
(setq BasePosition (assoc 13 NewDim))
(setq WantedX (+ (nth 1 BasePosition) DimDistance))
(setq New10Position (subst WantedX (nth 1 10Position) 10Position))
(setq New11Position (subst WantedX (nth 1 11Position) 11Position))
(setq NewDim (subst New10Position 10Position NewDim))
(setq NewDim (subst New11Position 11Position NewDim))
(entmod NewDim)
(vl-load-com)
(setq e (entlast))
(setq obj (vlax-ename->vla-object e))
(setq tp (vlax-get obj 'textposition))
(setq tp (mapcar '+ tp (list TextOffset 0 0)))
(vlax-put obj 'textposition tp)
)
(setvar "CMDECHO" 1)
)
Solved! Go to Solution.