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

LISP FOR LINE PROFILE AND CHAINAGE

23 REPLIES 23
SOLVED
Reply
Message 1 of 24
kishku
19205 Views, 23 Replies

LISP FOR LINE PROFILE AND CHAINAGE

Hi friends ,

   any body have a lisp programme for creating a line profile and chainage. I have attached a sample drawing. The blocks on the line have elevation and lines are drawn from the datum .If i mannually draw it will take too much time. if anybody have please send me  thanks 

Tags (1)
23 REPLIES 23
Message 2 of 24
pbejse
in reply to: kishku

lokks like a tough one but doable. too bad dont know really much about chainage and profiles.

I notice there are two blocks use as reference in creating your profile,

Cross_circle_18 and

Cross_2 (inerpolated points?)

, are you using the same name block for every profile?

 

I believe profiiles are created with Y scale different for X scale, will it always be the same factor? (10)

What do you have so far? have you searched the forum the forum yet?

 

 

 

 

 

 

Message 3 of 24
kishku
in reply to: pbejse

 

Only consider one block CROSS-2, this is for every profile.

scale is always same for all profiles ie  x=1 and y=10.  searched in the forum  but didnt get

Message 4 of 24
pbejse
in reply to: kishku

Ttry this for now:

 

(defun c:Cprof  (/ pts pt_lst ins_pt a b c chn_lst)
;;;		pBe 2011		;;
  (vl-load-com)
  (if (setq pts
         (ssget
           '((2 . "CROSS-2,CROSS_CIRCLE-18")
             (8 . "CROSSING POINT,MPGN__POINTS_P3"))))
    (progn
      (mapcar
        '(lambda (p)
           (setq pt_lst (cons (cdr (assoc 10 (entget p))) pt_lst)))
        (vl-remove-if 'listp (mapcar 'cadr (ssnamex pts))))
      (setq pt_lst
         (vl-sort pt_lst
           (function (lambda (p1 p2) (< (car p1) (car p2))))))
      (setq ins_pt (car pt_lst)
        ins_pt
         (list (car ins_pt) (setq c (+ (cadr ins_pt) 500.00))))
      (while (and (>= (length pt_lst) 2) (setq a (car pt_lst)))
        (setq b (cdr pt_lst))
        (setq ins_pt
           (append (list
               (nth 0 (car b))
               (setq c
                  (+ (* (- (last (car b)) (last a)) 10)
                     c)))
             ins_pt)
          pt_lst b))
      (setq chn_lst
         (vlax-make-safearray
           vlax-vbDouble
           (cons 0 (1- (length ins_pt)))))
      (vlax-safearray-fill chn_lst ins_pt)
      (vla-AddLightWeightPolyline
        (vla-get-modelspace
          (vla-get-activedocument (vlax-get-acad-object)))
        chn_lst)))
  (princ))

 

Thiis will draw the polyline for you and contrary to what you posted., i still process the block, crossing_circle_18 otherwise it would be incomplete.

 

Tried on the the attached file. it seems to do what you want

 

 

 

 

 

 

 

Message 5 of 24
kishku
in reply to: pbejse

Dear pbejse ,

           Thanks for the reply. I tried the lisp polyline is coming for cross-2 and cross circle blocks, it is good. Is there any way to make the chainage and vertical lines?. Also is it better or possible  to go for visual basic.  any way thanks for reply.

Message 6 of 24
pbejse
in reply to: kishku


@kishku wrote:

...... Is there any way to make the chainage and vertical lines?......


 

 Somehow I knew you'll going to say that .

 


...... Also is it better or possible  to go for visual basic. 

 


 I wouldnt say its better, possible yes.but IMO, with the recent migration from VBA to .NET on newAutocad versions

I think i would stick with Vanila lisp, plus i'm a beginner when it comes to VBA. sorry cant help you with that.

 

 

 

 

 

 

Message 7 of 24
pbejse
in reply to: kishku

I will try to wirte a code for the "chainage" thingy, but you need to explain to me what those numbers are just to be on the clear.

 

135 M

146.70 <-- elevation?

0+000.000<--

0+100.002<-- distance?

 

are the text styles and text height constant?

 

BTW: judging bythe way the chainage is drawn i'm guessing you already have a routine for that. could you post it here and we can incorporate it with the previous code.   (or you drawn this lines and text one by one?) it looks as if its done progmatically

Also if possible, post the interpolation code as well.

 

 

 

Message 8 of 24
kishku
in reply to: kishku

135 M

146.70 <-- elevation?

0+000.000<--

0+100.002<-- distance?

 

are the text styles and text height constant?

 

 

135 M    datum 

146.70 <-- elevation?     yes elevation

0+000.000<--                    starting chainage  distance

0+100.002<-- distance?

 

are the text styles and text height constant?      yes text styles and height constant

  the sample done by some other person but he not revealing how he done. and also which lisp or vba used.

Message 9 of 24
pbejse
in reply to: kishku

So you're telling me your company has a routine for that task and not sharing it?

 

Anyhoo.. i'll post the code later today.

 

keep you posted

 

 

 

Message 10 of 24
pbejse
in reply to: pbejse

try this

 

(defun c:Cprof  (/ Text Line str_draw pts pt_lst z_val_str ins_pt a b c fdst
             chn_lst)
;;;			pbe 22Mar2011				;;;
;;;  								;;;
  (vl-load-com)
  (defun
     Text  (pt str)
    (entmakex
      (list
        (cons 0 "TEXT")
        (cons 10 pt)
        '(8 . "Profile")
        '(40 . 3.0)
        '(50 . 1.57143)
        (cons 1 str))))
  (defun
     Line  (p1 p2)
    (entmakex (list (cons 0 "LINE") (cons 10 p1) (cons 11 p2))))
  (defun
     str_draw  (sts pls / base_y ptx zero+)
    (setq
      base_y
       (- (car pls) 120.00)
      cntr -1)
    (foreach
       str_  sts
      (text
        (list
          (setq ptx (nth (setq cntr (+ 2 cntr)) pls))
          (- base_y 20.00))
        (car str_))
      (text
        (list (nth cntr pls) (- base_y 50.00))
        (if (<= (vl-string-position
                  (ascii ".")
                  (setq zero+ (cdr str_)))
                3)
          (strcat "0+" zero+)
          (strcat (substr zero+ 1 1) "+" (substr zero+ 2))))
      (Line (list ptx (nth (1- cntr) pls)) (list ptx base_y)))
    (Line
      (list (nth 1 pls) base_y)
      (list (nth 2 ins_pt) base_y))
    (Line
      (list (nth 1 pls) (- base_y 20.00))
      (list (nth 2 ins_pt) (- base_y 20.00)))
    (Line
      (list (nth 1 pls) (- base_y 50.00))
      (list (nth 2 ins_pt) (- base_y 50.00)))
    (princ))
  (if (setq
        pts
         (ssget
           '((2 . "CROSS-2,CROSS_CIRCLE-18")
             (8 . "CROSSING POINT,MPGN__POINTS_P3"))))
    (progn
      (mapcar
        '(lambda (p)
           (setq pt_lst (cons (cdr (assoc 10 (entget p))) pt_lst)))
        (vl-remove-if 'listp (mapcar 'cadr (ssnamex pts))))
      (setq
        pt_lst
         (vl-sort
           pt_lst
           (function (lambda (p1 p2) (< (car p1) (car p2))))))
      (setq
        ins_pt
         (car pt_lst)
        ins_pt
         (list (car ins_pt) (setq c (+ (cadr ins_pt) 500.00)))
        fdst
         (nth 0 (car pt_lst)))
      (while (and (>= (length pt_lst) 2) (setq a (car pt_lst)))
        (setq b (cdr pt_lst))
        (setq
          z_val_str
           (cons
             (cons
               (rtos (last a) 2 3)
               (if (not z_val_str)
                 "000.000"
                 (rtos (- (car a) fdst) 2 3)))
             z_val_str))
        (setq
          ins_pt
           (append
             (list
               (nth 0 (car b))
               (setq
                 c
                  (+ (* (- (last (car b)) (last a)) 10)
                     c)))
             ins_pt)
          pt_lst b))
      (setq
        z_val_str
         (cons
           (cons
             (rtos (last (car pt_lst)) 2 3)
             (rtos (- (car (car pt_lst)) fdst) 2 3))
           z_val_str))
      (str_draw (reverse z_val_str) (reverse ins_pt))
      (setq
        chn_lst
         (vlax-make-safearray
           vlax-vbDouble
           (cons 0 (1- (length ins_pt)))))
      (vlax-safearray-fill chn_lst ins_pt)
      (vla-AddLightWeightPolyline
        (vla-get-modelspace
          (vla-get-activedocument (vlax-get-acad-object)))
        chn_lst)))
  (princ))

 

 

Reminder: (disclaimer);;Not really   Smiley Happy
This will work ONLY under this conditions
Blocks with the names
"CROSS-2" and "CROSS_CIRCLE-18"
Under layers
"CROSSING POINT" "MPGN__POINTS_P3"
Same units
Same textstyle
same height
As your sample drawing

AND i leave the Datum value to you. I have no idea where to reference that

 

Hope thi helps

 

Tags (1)
Message 11 of 24
kishku
in reply to: kishku

THANKS  PBAJSE  its working  well, now my work reduced i can do i week work in one minute. THANKS A LOT.  Only some negligible points like datum. it is not a problem i can correct it. THANKS A LOT DEAR

Message 12 of 24
pbejse
in reply to: kishku

You  are welcome.

 

Thats what we're here for,

IMO the purpose of this forum is to help, teach, learn and SHARE

 

Have fun profiling Smiley Happy

Message 13 of 24
Anonymous
in reply to: kishku

what is the comment

Message 14 of 24
HR2323
in reply to: pbejse

Can you please add more required data generate from lisp please see dwg file

Tags (1)
Message 15 of 24
Anonymous
in reply to: kishku

I want to use that lisp too. Kisku can you describe the process of getting profile?

Message 16 of 24
Anonymous
in reply to: kishku

Gud day to all can you help me solve this problem.

 

Do you have a lisp that will indicate all the crossings in proposed center line on the profile.( mud road, over head line,Steel Fence, valley crossing) 

with the same location of stationing on the propose centerline to profile.

 

attach drawing for sample...

 

 

Pleaseeeeeeeeeeeee...

Message 17 of 24
Merretts
in reply to: pbejse

Hi, this script is great! I am wondering how to modify it in order to draw two sets of data, for example a pipe running under the profile. Can you help me?

Message 18 of 24
Anonymous
in reply to: pbejse

May I know the commend for this lisp (LISP FOR LINE PROFILE AND CHAINAGE)

Message 19 of 24
pbejse
in reply to: Anonymous


@Anonymous wrote:

May I know the commend for this lisp (LISP FOR LINE PROFILE AND CHAINAGE)


 

Wow, this thread is 5 years old and there's a few requests along the way 😄 

 

Perhaps we can write a new one for your  kalusalingam33., what is it you require?

 

 

 

Message 20 of 24
Anonymous
in reply to: pbejse

I need a lisp program for creating road profile by using the existing contour or spot levels. with chainage .

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

Post to forums  

Forma Design Contest


AutoCAD Beta