Dimensioning Multiple Segments of a Polyline

Dimensioning Multiple Segments of a Polyline

PFHeller
Enthusiast Enthusiast
6,505 Views
4 Replies
Message 1 of 5

Dimensioning Multiple Segments of a Polyline

PFHeller
Enthusiast
Enthusiast

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:

 

  1. It asks you for a sample template dimension to match properties with.
  2. 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.
  3. 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)
)

0 Likes
Accepted solutions (1)
6,506 Views
4 Replies
Replies (4)
Message 2 of 5

Kent1Cooper
Consultant
Consultant
Accepted solution

You could get some direction from DimPoly.lsp, available here.  If you use its DPO [= Dimension Polyline Outside] command, it will do aspects of what you're looking for, with one pick [instead of four] on each Polyline or even one selection of as many of them as you want, although there are differences:

 

A)  it will include the [I assume] short ends, too, but modifications could be made to evaluate the segment lengths and do only the long ones, if that's always what you're after;

 

B)  it works with the current Dimension Style, whatever that is, but could be made to get that from a selected Dimension.

 

But with alterations like those, it could work for you.  It uses the current Style's text height as the basis for calculating the dimension line distance from the segment, so you can set that ratio to whatever you want.

 

It sounds like its handling of arc segments could be eliminated for your purposes, which would shorten it considerably.

Kent Cooper, AIA
Message 3 of 5

PFHeller
Enthusiast
Enthusiast

Well it took me quite a while as your coding is far beyond mine........but I was able to modify your program and have it do exactly what I needed....and even more! The fact that I can select them all in one huge selection box......this takes something that would take 20-30 minutes and does it in 10 seconds. Bless you!

0 Likes
Message 4 of 5

braudpat
Mentor
Mentor

 

Hello Kent

 

1) First: THANKS for all your LSP routines !

 

I like your DPI-DPO routine !

 

2) Please I have a small wish for your DPI/DPO routine

 

3) Why you are not using "standard" angular Dims on arcs - On arcs you are using a replacement text for the Dim text !

So the text doesn't follow the standard rules of the current Dim style: number of decimals for example !

 

4) Is it possible to use "normal" angular Dims on arcs ?

 

Regards, Patrice

 

Patrice ( Supporting Troops ) - Autodesk Expert Elite
If you are happy with my answer please mark "Accept as Solution" and if very happy please give me a Kudos (Felicitations) - Thanks

Patrice BRAUD

EESignature


0 Likes
Message 5 of 5

Kent1Cooper
Consultant
Consultant

braudpat wrote:

.... 

3) Why you are not using "standard" angular Dims on arcs - On arcs you are using a replacement text for the Dim text !

.... 


Because when I wrote that, I had only an older version of AutoCAD that did not have length-of-arc Dimensioning -- all you could get was the angle.  I imagine it could be modified easily enough to do it that way, which would have the advantage of updating if you Stretch something, or the like.

Kent Cooper, AIA
0 Likes