See the top rated post in this thread. Click here

Page 1 of 2 12 LastLast
Results 1 to 10 of 13

Thread: Lisp routine to show visibilty splays

  1. #1
    Member
    Join Date
    2003-08
    Posts
    26
    Login to Give a bone
    0

    Default Lisp routine to show visibilty splays

    Hi, I need a lisp routine to show a visibility splay along a kerbline. Unfortunately the parameters are not based on the angle so I can't use the MEASURE command. I need to draw chord lines along a curve that are 215m long.

    Manually I would draw a circle on the kerbline with a radius of 215m and I would draw a line from the centre to where the circle intersects the kerbline and repeat it every 1m or so. As the kerbline varies in radius the angle isn't constant.

    I could use the MEASURE command to place a circle along its length and draw the lines in manually but there is a lot of kerbline to do and a lisp routine would save the day.

    I hope this makes sense.

    Thanks

    Dan
    Last edited by earld; 2009-12-22 at 11:46 AM. Reason: To respond to comment on email.

  2. #2
    AUGI Addict
    Join Date
    2008-02
    Posts
    1,141
    Login to Give a bone
    1

    Default Re: Lisp routine to show visibilty splays

    This might help.....
    (I used MText in the example GIF, but it will work on anything one can normally copy)
    Attached Images Attached Images
    Attached Files Attached Files

  3. #3
    AUGI Addict
    Join Date
    2008-02
    Posts
    1,141
    Login to Give a bone
    0

    Default Re: Lisp routine to show visibilty splays

    Let me know if this helps.

  4. #4
    Member
    Join Date
    2003-08
    Posts
    26
    Login to Give a bone
    0

    Default Re: Lisp routine to show visibilty splays

    Thanks for helping but it isn't what I need.

    I have to plot a 215m line of sight around a kerbline. I need a lisp routine that will automatically do the equivalent of the following; draw a circle on the kerbline with a radius of 215m and and draw a line from the centre to where the circle intersects the kerbline as it curves and repeat it every 1m or suitable distance.

    I need to plot the green line in the example attached or the grey lines and I can trim them to suit. As you can see, where the kerbline changes radius the angle of the splay then changes.

    Good luck.
    Attached Files Attached Files

  5. #5
    I could stop if I wanted to
    Join Date
    2002-08
    Posts
    231
    Login to Give a bone
    1

    Default Re: Lisp routine to show visibilty splays

    Hi,

    A start for you. I hope can help you?

    Code:
    (vl-load-com)
    ((lambda ( / js vlaobj perim_obj d_x lst_pt pt_last rad inc pt)
    	(princ (strcat"\nSelect kerbline."))
    	(while
    		(not
    			(setq js
    				(ssget "_+.:E:S" 
    					(list
    						(cons 0 "*POLYLINE,ARC,SPLINE")
    						(cons 67 (if (eq (getvar "CVPORT") 2) 0 1))
    						(cons 410 (if (eq (getvar "CVPORT") 2) "Model" (getvar "CTAB")))
    						(cons -4 "<NOT")
    							(cons -4 "&") (cons 70 112)
    						(cons -4 "NOT>")
    					)
    				)
    			)
    		)
    	)
    	(setq
    		vlaobj (vlax-ename->vla-object (ssname js 0))
    		perim_obj (vlax-curve-getDistAtParam vlaobj (vlax-curve-getEndParam vlaobj))
        d_x 0.0
        lst_pt nil
        pt_last nil
        rad perim_obj
        inc perim_obj
      )
      (while (>= rad perim_obj)
        (initget 7)
        (setq rad (getdist "\nDistance of visibility?: "))
        (if (>= rad perim_obj) (princ "\nDistance execeded length kerbline!"))
      )
      (while (>= inc perim_obj)
        (initget 7)
        (setq inc (getdist "\nDistance of resolution?: "))
        (if (>= inc perim_obj) (princ "\nDistance execeded length kerbline!"))
      )
    	(while (< d_x perim_obj)
    		(setq
    			lst_pt (cons (vlax-curve-getPointAtDist vlaobj d_x) lst_pt)
    			d_x (+ d_x inc)
    		)
    	)
      (while lst_pt
        (entmake
          (append
            '(
              (0 . "CIRCLE")
              (100 . "AcDbEntity")
              (67 . 0)
              (410 . "Model")
              (8 . "splay")
              (60 . 1)
              (62 . 256)
              (6 . "ByLayer")
              (370 . -2)
              (100 . "AcDbCircle")
            )
            (list (cons 40 rad))
            (list (cons 10 (car lst_pt)))
            '((210 0.0 0.0 1.0))
          )
        )
        (setq pt (vlax-invoke vlaobj 'IntersectWith (vlax-ename->vla-object (entlast)) acExtendNone))
        (if (and pt pt_last (> (length pt) 3))
          (if (> (distance (list (car pt) (cadr pt) (caddr pt)) pt_last) (distance (list (cadddr pt) (car (cddddr pt)) (last pt)) pt_last))
            (setq pt (list (cadddr pt) (car (cddddr pt)) (last pt)))
            (setq pt (list (car pt) (cadr pt) (caddr pt)))
          )
        )
        (entdel (entlast))
        (if pt
          (entmake
            (append
              '(
                (0 . "LINE")
                (100 . "AcDbEntity")
                (67 . 0)
                (410 . "Model")
                (8 . "splay")
                (62 . 256)
                (6 . "ByLayer")
                (370 . -2)
                (100 . "AcDbLine")
              )
              (list (cons 10 (car lst_pt)))
              (list (cons 11 pt))
              '((210 0.0 0.0 1.0))
            )
          )
        )
        (setq lst_pt (cdr lst_pt) pt_last pt)
      )
      (prin1)
    ))

  6. #6
    Member
    Join Date
    2003-08
    Posts
    26
    Login to Give a bone
    0

    Default Re: Lisp routine to show visibilty splays

    That's spot on, this will save hours. Thanks for your help. If an outline can be drawn to show an envelope that would the cherry on the cake but not essential.

    Thanks again.

  7. #7
    I could stop if I wanted to
    Join Date
    2002-08
    Posts
    231
    Login to Give a bone
    0

    Smile Re: Lisp routine to show visibilty splays

    Quote Originally Posted by earld View Post
    That's spot on, this will save hours. Thanks for your help. If an outline can be drawn to show an envelope that would the cherry on the cake but not essential.

    Thanks again.
    Try my french version

    Code:
    (vl-load-com)
    (defun c:epure-masque_lateral ( / js ldat vlaobj perim_obj pt_start pt_end d_x lst_pt pt_last inc vref rad pt pt_int e_last env_mask)
     (princ (strcat"\nSélectionner l'objet représentant le bord de la bande de rive de la chaussée."))
     (while
      (not
       (setq js
        (ssget "_+.:E:S" 
         (list
          (cons 0 "*POLYLINE,ARC,SPLINE")
          (cons 67 (if (eq (getvar "CVPORT") 2) 0 1))
          (cons 410 (if (eq (getvar "CVPORT") 2) "Model" (getvar "CTAB")))
          (cons -4 "<NOT")
           (cons -4 "&") (cons 70 113) ;(70 . 121)
          (cons -4 "NOT>")
         )
        )
       )
      )
     )
     (setq
      ldat '((20 . 15.5)(30 . 26.5)(40 . 40.0)(50 . 55.0)(60 . 72.0)(70 . 95.0)(80 . 121.0)(90 . 151.0)(100 . 187.0))
      vlaobj (vlax-ename->vla-object (ssname js 0))
      perim_obj (vlax-curve-getDistAtParam vlaobj (vlax-curve-getEndParam vlaobj))
      pt_start (vlax-curve-getStartPoint vlaobj)
      pt_end (vlax-curve-getEndPoint vlaobj)
      d_x 0.0
      lst_pt nil
      pt_last nil
      env_mask (list pt_end)
      inc perim_obj
     )
     (initget "20 30 40 50 60 70 80 90 100")
     (setq vref (getkword "\nVitesse de référence en Km/h de la voie? [20/30/40/50/60/70/80/90/100]<90>: "))
     (if (not vref) (setq vref "90"))
     (setq rad (cdr (assoc (read vref) ldat)))
     (if (>= rad perim_obj) (progn (princ "\nLa distance de visibilité excède la longueur de la bande de rive sélectionnée!") (exit)))
     (while (>= inc perim_obj)
       (initget 6)
       (setq inc (getdist (strcat "\nEquidistance de résolution? <" (rtos (/ rad 10.0)) ">: ")))
       (if (not inc) (setq inc (/ rad 10.0)))
       (if (>= inc perim_obj) (princ "\nLa distance de résolution de l'épure excède la longueur de la bande de rive sélectionnée!"))
     )
     (while (< d_x perim_obj)
      (setq
       lst_pt (cons (vlax-curve-getPointAtDist vlaobj d_x) lst_pt)
       d_x (+ d_x inc)
      )
     )
     (while lst_pt
      (entmake
       (append
        '(
          (0 . "CIRCLE")
          (100 . "AcDbEntity")
          (67 . 0)
          (410 . "Model")
          (8 . "degagement-visibilite-lateral")
          (60 . 1)
          (62 . 256)
          (6 . "ByLayer")
          (370 . -2)
          (100 . "AcDbCircle")
        )
        (list (cons 40 rad))
        (list (cons 10 (car lst_pt)))
        '((210 0.0 0.0 1.0))
       )
      )
      (setq pt (vlax-invoke vlaobj 'IntersectWith (vlax-ename->vla-object (entlast)) acExtendNone))
      (if (and pt pt_last (> (length pt) 3))
       (if (> (distance (list (car pt) (cadr pt) (caddr pt)) pt_last) (distance (list (cadddr pt) (car (cddddr pt)) (last pt)) pt_last))
        (setq pt (list (cadddr pt) (car (cddddr pt)) (last pt)))
        (setq pt (list (car pt) (cadr pt) (caddr pt)))
       )
      )
      (entdel (entlast))
      (if (and pt (<(length pt) 4))
       (progn
        (entmake
         (append
          '(
            (0 . "LINE")
            (100 . "AcDbEntity")
            (67 . 0)
            (410 . "Model")
            (8 . "degagement-visibilite-lateral")
            (62 . 9)
            (6 . "ByLayer")
            (370 . -2)
            (100 . "AcDbLine")
          )
          (list (cons 10 (car lst_pt)))
          (list (cons 11 pt))
          '((210 0.0 0.0 1.0))
         )
        )
        (if e_last
         (progn
          (setq pt_int (vlax-invoke (vlax-ename->vla-object e_last) 'IntersectWith (vlax-ename->vla-object (entlast)) acExtendNone))
          (if pt_int (setq env_mask (cons pt_int env_mask)))
         )
        )
        (setq e_last (entlast))
       )
       (setq pt nil)
      )
      (setq lst_pt (cdr lst_pt) pt_last pt)
     )
     (setq env_mask (mapcar '(lambda (x) (list 10 (car x) (cadr x))) (reverse (cons pt_start env_mask))))
     (entmake
      (append
       '(
        (0 . "LWPOLYLINE")
        (100 . "AcDbEntity")
        (67 . 0)
        (410 . "Model")
        (8 . "degagement-visibilite-lateral")
        (62 . 3)
        (6 . "ByLayer")
        (370 . -2)
        (100 . "AcDbPolyline")
       )
       (list (cons 90 (length env_mask)))
       '((70 . 0))
       (apply 'append (mapcar '(lambda (x10) (append (list x10 '(40 . 0.0) '(41 . 0.0) '(42 . 0.0)))) env_mask))
       '((210 0.0 0.0 1.0))
      )
     ) 
     (prin1)
    )

  8. #8
    Member
    Join Date
    2003-08
    Posts
    26
    Login to Give a bone
    0

    Default Re: Lisp routine to show visibilty splays

    I've modified one of the speed settings to be a 215 visibility splay.

    Merci

    Dan

  9. #9
    I could stop if I wanted to
    Join Date
    2002-08
    Posts
    231
    Login to Give a bone
    0

    Default Re: Lisp routine to show visibilty splays

    I think that you have understand the list LDAT and the associated speed in km with distance of visibility.
    LDAT can be easy change for miles and your table of distances recommanded in your country.
    The variable RAD is come on this list, the length of this list isn't important.

    Glad to has help you.

  10. #10
    Woo! Hoo! my 1st post
    Join Date
    2017-01
    Posts
    1
    Login to Give a bone
    0

    Default Re: Lisp routine to show visibilty splays

    Hi,

    This is very useful indeed.

    Could you please help me to modify this to draw visibility splays of a particular length along the object (instead of chord length)?

    Thank you,
    Regards,
    Pravin Kumar

    Quote Originally Posted by Bruno.Valsecchi View Post
    Hi,

    A start for you. I hope can help you?

    Code:
    (vl-load-com)
    ((lambda ( / js vlaobj perim_obj d_x lst_pt pt_last rad inc pt)
    	(princ (strcat"\nSelect kerbline."))
    	(while
    		(not
    			(setq js
    				(ssget "_+.:E:S" 
    					(list
    						(cons 0 "*POLYLINE,ARC,SPLINE")
    						(cons 67 (if (eq (getvar "CVPORT") 2) 0 1))
    						(cons 410 (if (eq (getvar "CVPORT") 2) "Model" (getvar "CTAB")))
    						(cons -4 "<NOT")
    							(cons -4 "&") (cons 70 112)
    						(cons -4 "NOT>")
    					)
    				)
    			)
    		)
    	)
    	(setq
    		vlaobj (vlax-ename->vla-object (ssname js 0))
    		perim_obj (vlax-curve-getDistAtParam vlaobj (vlax-curve-getEndParam vlaobj))
        d_x 0.0
        lst_pt nil
        pt_last nil
        rad perim_obj
        inc perim_obj
      )
      (while (>= rad perim_obj)
        (initget 7)
        (setq rad (getdist "\nDistance of visibility?: "))
        (if (>= rad perim_obj) (princ "\nDistance execeded length kerbline!"))
      )
      (while (>= inc perim_obj)
        (initget 7)
        (setq inc (getdist "\nDistance of resolution?: "))
        (if (>= inc perim_obj) (princ "\nDistance execeded length kerbline!"))
      )
    	(while (< d_x perim_obj)
    		(setq
    			lst_pt (cons (vlax-curve-getPointAtDist vlaobj d_x) lst_pt)
    			d_x (+ d_x inc)
    		)
    	)
      (while lst_pt
        (entmake
          (append
            '(
              (0 . "CIRCLE")
              (100 . "AcDbEntity")
              (67 . 0)
              (410 . "Model")
              (8 . "splay")
              (60 . 1)
              (62 . 256)
              (6 . "ByLayer")
              (370 . -2)
              (100 . "AcDbCircle")
            )
            (list (cons 40 rad))
            (list (cons 10 (car lst_pt)))
            '((210 0.0 0.0 1.0))
          )
        )
        (setq pt (vlax-invoke vlaobj 'IntersectWith (vlax-ename->vla-object (entlast)) acExtendNone))
        (if (and pt pt_last (> (length pt) 3))
          (if (> (distance (list (car pt) (cadr pt) (caddr pt)) pt_last) (distance (list (cadddr pt) (car (cddddr pt)) (last pt)) pt_last))
            (setq pt (list (cadddr pt) (car (cddddr pt)) (last pt)))
            (setq pt (list (car pt) (cadr pt) (caddr pt)))
          )
        )
        (entdel (entlast))
        (if pt
          (entmake
            (append
              '(
                (0 . "LINE")
                (100 . "AcDbEntity")
                (67 . 0)
                (410 . "Model")
                (8 . "splay")
                (62 . 256)
                (6 . "ByLayer")
                (370 . -2)
                (100 . "AcDbLine")
              )
              (list (cons 10 (car lst_pt)))
              (list (cons 11 pt))
              '((210 0.0 0.0 1.0))
            )
          )
        )
        (setq lst_pt (cdr lst_pt) pt_last pt)
      )
      (prin1)
    ))

Page 1 of 2 12 LastLast

Similar Threads

  1. baby steps in lisp/script attribute visibilty
    By maomuchmar in forum AutoLISP
    Replies: 4
    Last Post: 2014-04-03, 08:04 AM
  2. Controlling Visibilty States With Lisp
    By sovby254640 in forum AutoLISP
    Replies: 6
    Last Post: 2013-08-06, 12:16 PM
  3. Help with a lisp routine to add a 12" line to this routine
    By Orbytal.edge341183 in forum AutoLISP
    Replies: 3
    Last Post: 2012-11-14, 10:33 PM
  4. Replies: 9
    Last Post: 2012-01-21, 07:58 AM
  5. How can i use Visibilty States in a Lisp?
    By ReachAndre in forum AutoLISP
    Replies: 13
    Last Post: 2009-08-14, 02:27 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •