LISP : Find Distance of multiple parallel lines from a single baseline

LISP : Find Distance of multiple parallel lines from a single baseline

jaggisingh003
Advocate Advocate
2,654 Views
14 Replies
Message 1 of 15

LISP : Find Distance of multiple parallel lines from a single baseline

jaggisingh003
Advocate
Advocate

Hi All,

I have a requirement of finding the distance of multiple parallel lines from a single baseline.

I want LISP that will allow me to select the baseline(from which I need the distance of other lines) and lines for which I need distance. Here in the image below, the yellow line is the baseline and I need distance for all other lines from the yellow line.

large.jpg

 

If anyone has worked on this before, kindly help me out.

0 Likes
Accepted solutions (1)
2,655 Views
14 Replies
Replies (14)
Message 2 of 15

Kent1Cooper
Consultant
Consultant

@jaggisingh003 wrote:

…. I have a requirement of finding the distance of multiple parallel lines from a single baseline.

I want LISP that will allow me to select the baseline(from which I need the distance of other lines) and lines for which I need distance. ….

....


That's not difficult, but in what form do you want the distances?  Reported at the Command line?  Written as Text in the drawing?  Sent out to a text or spreadsheet file?  Something else?

Kent Cooper, AIA
Message 3 of 15

Moshe-A
Mentor
Mentor

Hi,

 

if i send you a program that will print a list of the distances between the lines. can you take it from there and complete what you want to do?

 

Moshe

 

Message 4 of 15

jaggisingh003
Advocate
Advocate

In in AutoCAD text  format....

0 Likes
Message 5 of 15

jaggisingh003
Advocate
Advocate

Thanks. Moshe

 

 I am happy to use your code. but I don't have any knowledge of Lisp programming. 

0 Likes
Message 6 of 15

Moshe-A
Mentor
Mentor

then you did not explained what would you do with the list of distances? it's only a list of numbers?

you want only to know the distances or you want to do something with it?

0 Likes
Message 7 of 15

Kent1Cooper
Consultant
Consultant

You can use ORDINATE DIMENSIONS.  Make a Dimension Style with both extension lines suppressed if you want only the textual part.  Specify the Xdatum option.  If your reference line isn't at X=0, you can put them all in with the "wrong" values, and afterwards select them all, and STRETCH the shared grip at 0,0 to anywhere on that Line.

Kent Cooper, AIA
Message 8 of 15

jaggisingh003
Advocate
Advocate

see this image.....

 

I have to write the distance from baseline at the specified place. like this image.. 
large.jpg

0 Likes
Message 9 of 15

jaggisingh003
Advocate
Advocate

I don't use ordinate dimensions. I am using baseline dimension for this like the image below...

baseline dimensionsbaseline dimensions Remove extension lines in dimension style.

0 Likes
Message 10 of 15

Moshe-A
Mentor
Mentor

so what you want to do is to specify an horizontal line and the lisp will draw all the base dimension from your specified base line?  are you using a special dimension style? post the dwg

Message 11 of 15

jaggisingh003
Advocate
Advocate

Yes, you get it correct.

No, I am not using any special type dimension style only.

please find the attached drawing for more information.

0 Likes
Message 12 of 15

Moshe-A
Mentor
Mentor

are you sure you are doing dimbaseline? cause what i see in your file is just horizontal dimensions between the lines and for that kind of dimension you do not need any lisp use the QDIM command it will do just prefact what you want.

 

0 Likes
Message 13 of 15

jaggisingh003
Advocate
Advocate

see this

0 Likes
Message 14 of 15

Moshe-A
Mentor
Mentor
Accepted solution

Ok i see now what you mean.

here is AutoDB command to do what you want

first you be asked to specify the 1st dimension line point: you need to pick the 1st point to the left of your base line. than pick the 2nd point to the right (turn ortho on) over the last line

the lisp will select all lines (only lines and if there are other lines remove them) by "Fence"

than the dimensions will be drawn

 

improve your dimension style so the outcome will be more readable.

if this suits you, mark it as solusion.

 

enjoy

moshe

 

(defun c:AutoDB (/ p0 p1 ss lst^ p13 item0 item1)

 (setvar "cmdecho" 0)
 (command ".undo" "_begin")
  
 (if (and
       (setq p0 (getpoint "\nSpecify first dimension line point: "))
       (setq p1 (getpoint p0 "\nSpecify second dimension line point: "))
       (setq ss (ssget "F" (list p0 p1) '((0 . "line"))))
     )
  (progn
   (setq lst^ (vl-sort (ssnamex ss) (function (lambda (item0 item1) (< (distance p0 (cadr (last item0))) (distance p0 (cadr (last item1))))))))

   (setq item0 (car lst^) item1 (cadr lst^))
   (command "._dimlinear" (setq p13 (cadr (last item0))) (cadr (last item1)) (polar p13 (/ pi 2) (* (getvar "dimtxt") (getvar "dimscale")))
            "._dimtedit" "_last" "_right")

   (foreach item1 (cddr lst^)
    (command "._dimbaseline" (cadr (last item1)) "" ""
             ".dimtedit" "_last" "_right")
   ); foreach
  ); progn
 ); if

 (command "._undo" "_end")
 (setvar "cmdecho" 1)
  
 (princ)
)
Message 15 of 15

jaggisingh003
Advocate
Advocate

 

It is highly appreciable for the code provided by you.

 

Thanks for the kind & quick reply.

 

Thanks  a lot, Moshe 

0 Likes