Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Lisp to create aligned dimension between selected blocks

19 REPLIES 19
SOLVED
Reply
Message 1 of 20
subinsasidharan
5570 Views, 19 Replies

Lisp to create aligned dimension between selected blocks

Is there any lisp program to place dimensions automatically between selected blocks?
I have an external street lighting layout, in which i have to dimension the distance between each lighting poles (blocks). Please help me.
19 REPLIES 19
Message 2 of 20
ВeekeeCZ
in reply to: subinsasidharan

Try this lisp which i did lately...

See code inside, there are the notes about current dimstyle, current layer and text height settings.

 

Message 3 of 20

Welcome to these Forums!

Something could probably be made to do that.  But more information would be helpful, in particular, a sample drawing or image that shows how you want the Dimensions to relate to the Blocks [with extension lines, or straight from middle to middle? if with extension lines, how far from the middle-to-middle line? where the insertion points are in the Blocks, and whether they are in fact what you want to Dimension between, etc.].

 

I assume the idea is to select multiple Blocks all at once, and have a routine put in all the Dimensions, since ordinary DIMALIGNED would do if you want to pick each pair separately from others.  One challenge would be to tell a routine how to decide which pairs of Blocks to draw Dimensions between, though that could be made easier if you're willing to pick them one at a time in the right order, rather than selecting by something like a window.

Kent Cooper, AIA
Message 4 of 20

Thanks for the reply. What Kent assuming is correct. I need to dimension multiple blocks (from block center point to next block center point) in current dimension style with extension lines. By center point, what i mean is the base point of the blocks. The drawing contains 3 different blocks, total count is around 500 blocks. Please help
Message 5 of 20


@subinsasidharan wrote:
.... I need to dimension multiple blocks (from block center point to next block center point) in current dimension style with extension lines. By center point, what i mean is the base point of the blocks. The drawing contains 3 different blocks, total count is around 500 blocks. ....

Selecting the Blocks all at once is not difficult, if they're not dynamic Blocks and can simply be filtered by name.  The hard part is determining, for a given Block, which other Blocks are the adjacent ones that you need to Dimension to from any given Block, and how many.  Are they strung along one side of a highway so that each one has only two other adjacent ones to dimension to?  Are they on alternating sides of streets with dimensions needed along each side but not across the street, so that the ones to be dimensioned to from a given Block may not necessarily always be the closest ones?  Do nearby streets ever lie close enough together that a given Block may be closer to one on another street than it is to adjacent ones on the same street?  Do you ever need to do the same with something like a parking lot, where they might be in a grid and need to be dimensioned to up to four others in different directions?  Etc., etc.  A drawing or image showing a typical configuration would help narrow down the possibilities.

Kent Cooper, AIA
Message 6 of 20

The blocks are along one side of highway. Each block has only 2 adjacent blocks to dimension. l need to select blocks of one particular highway together and dimension it. Similarly 5 highways are there. Thanks in advance.
Message 7 of 20

Any lisp?
Message 8 of 20


@subinsasidharan wrote:
Any lisp?

Not yet.  Everyone here is just a fellow user, contributing time when we can.  Also consider time-zone differences -- your latest post was in the middle of the night here [eastern United States].

 

For the third time, an example drawing or image, including typical configuration of Blocks and at least some Dimensions as you want them to be drawn, would be very helpful.  For example, BeekeeCZ's routine, in its Aligned-Dimensions option, seems to decide where to put Dimensions by sorting the Block insertions by X coordinates only, so in either of the two configurations in this image, it gives undesired results, with many Dimensions going between non-adjacent pairs of Blocks:

 

BlockDim.png

 

The left one could be done easily enough by sorting by Y coordinates instead, and it wouldn't be too hard to get a routine to determine that Y coordinates are what it should look at.  But something like the right configuration would require more than a simple sort, since the order of neither the Blocks' X coordinates nor their Y coordinates would establish which pairs to dimension between.  I think it would require some kind of comparison of the distance from every Block to every other one, and some way of figuring out from lists of those distances which pairs should be dimensioned.  But if you would never have any configuration like that, in which sorting by a single direction wouldn't be enough, it wouldn't be necessary to figure out how to do that.  Or if such a layout would always be drawn by Inserting the Blocks in sequence along the highway, the order of the Blocks in the drawing database could be used, but I would be hesitant to count on that always being the case.

 

Also, if you want Dimensions with extension lines, how far from the Block-to-Block line should they go?  BeekeeCZ's routine varies them in a way that can have strange results in some circumstances, but maybe you want them all at the same offset.  Another helpful piece of information would be whether there are minimum and/or [especially] maximum spacings between them, which would make it easier to eliminate certain pairings from consideration.

Kent Cooper, AIA
Message 9 of 20

Thanks all.
Message 10 of 20
ВeekeeCZ
in reply to: subinsasidharan

Oh, I didn't see this coming. Thanks Kent for noticing, I have almost been overlooked. 🙂

 

This was a blind shooting... expected some comments for what to change. The routine was originally written for this request (orthogonal system of blocks for vertical and horizontal dimensions), aligned dim option I added just for fun... I guess I should add option something like "Follow the path"... sometime.

Message 11 of 20

Just because I was interested in whether I could figure out a way to do it, I came up with the attached.  It handles both situations in my earlier image appropriately.  See comments at the top, and the EDIT suggestion where it defines how far from the Block-to-Block line to put the dimension line.

Kent Cooper, AIA
Message 12 of 20

Thanks Kent Cooper, it works like a charm
Message 13 of 20
jonik_89
in reply to: Kent1Cooper

Hy,

 

Can anyone help with an automatic lisp for dimensioning a distance, with aligned dimension, between some circles that are paralel with a polyline? Something like in the picture below, from the center of circle perpendicular on the polyline.

 

Thanks!

Message 14 of 20
ВeekeeCZ
in reply to: jonik_89

Try the code...

 

(defun c:DimCircles (/ ss en i pt tx)

  (if (and (setq ss (ssget '((0 . "CIRCLE"))))
           (setq en (car (entsel "\nSelect an object to dim to: ")))
           (or (wcmatch (cdr (assoc 0 (entget en))) "LINE,LWPOLYLINE,ARC")
               (prompt "\nError: Selected object must be LINE, LWPOLYLINE or ARC."))
           )
    (repeat (setq i (sslength ss))
      (setq pt (cdr (assoc 10 (entget (ssname ss (setq i (1- i)))))))
      (if (setq px (vlax-curve-getClosestPointTo en pt))
        (command "_.DIMALIGNED"
                 "_none" (trans pt 0 1)
                 "_none" (trans px 0 1)
                 "_none" (trans px 0 1)))))
  (princ)
)
Message 15 of 20
jonik_89
in reply to: ВeekeeCZ

It works very good.

 

Thanks!!!

Message 16 of 20
raju.nimbargi
in reply to: Kent1Cooper

Eg fileEg file

Message 17 of 20
Sea-Haven
in reply to: raju.nimbargi

Take the DIMCIRCLES code and do it opposite way around use ssget "F" to look for circles touching the line pline etc. Start by selecting the lines then loop through them.

(setq lst (list (setq p1 (getpoint "\nPick 1st point"))
(setq p2 (getpoint p1 "\nDrag over *lines"))
))

(setq sslines (ssget "f" lst (list (cons 0 "*line"))))

 

Message 18 of 20
Kent1Cooper
in reply to: raju.nimbargi


@raju.nimbargi wrote:

bds.PNG


That is because it's designed to do multiple groups at once, and without any connecting object(s), such as this:

bds2.PNG

So if some are too much farther from each other than they are from closer ones, they may be considered separate groups.

 

If I do one row of them, it works fine:
bds3.PNG

 

With selection of Blocks only, it can't know that a row of them is a group, when others in other rows are closer than some of the spacings within the same row.  That's why a Line or something, to define groupings as those that touch it, is appropriate, but that would work in an entirely different way from this routine.

 

[And it's AutoLisp, not LIPS.]

 

 

Kent Cooper, AIA
Message 19 of 20
Sea-Haven
in reply to: raju.nimbargi

Agree with Kent need a real dwg to look at, does red line exists as I suggested as the method to find the circles.

Message 20 of 20
raju.nimbargi
in reply to: Kent1Cooper

Dear Sir,

Good Day!

Thank you for this LISP. Its save lots of my drafting time.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost