See the top rated post in this thread. Click here

Results 1 to 9 of 9

Thread: lisp to draw multiple polylines

  1. #1
    I could stop if I wanted to
    Join Date
    2005-08
    Posts
    378
    Login to Give a bone
    0

    Cool lisp to draw multiple polylines

    Guys,
    Can someone please assist me.
    I want to use lisp to draw multiple polylines on a set layer and colour and line width ect.
    I can make it do it for a polyline though how do I make it repeat without giving it a set number ?

    below is the routine at present:

    Code:
    (defun c:APL (/ oldexpert oldfiledia oldclayer pln SJC)
      (setvar "cmdecho" 0)
      (setvar "orthomode" 1)
      (setq oldexpert  (getvar "expert")
    	oldfiledia (getvar "filedia")
            oldclayer (getvar "clayer")
      )
     
    
    ;;loop to draw pline
    (defun pln ()
      (command "plinewid" 100)  ;sets polyline width to 100
      (command "_pline")
      (while (= (getvar "cmdactive") 1 ) (command pause) )
      (command "plinewid" 0)  ;sets polyline width back to 0
    ) ;end defun
    
    
    ;;looks for SJC.lin linetype file and loads DASHED2 linetype file if found
      (setq SJC (findfile "SJC.lin"))  ;states the file to be looked for
      (if (= SJC (findfile "SJC.lin"))  ;looks for the file stated above
        (progn  ;says if the file is found do these things
          (setvar "expert" 3)
          (setvar "filedia" 0)
          (command "._-linetype" "l" "DASHED2" SJC "")
          (setvar "expert" oldexpert)
          (setvar "filedia" oldfiledia)
          (princ
    	(strcat "\nlinetype DASHED2 in file SJC.lin was loaded.")  ;tells the user the file was found and loaded
          )
        )
        (princ (strcat "\nlinetype file SJC.lin was not found!"))  ;tells the user the file was not found or loaded
      )
    
    ;;set layer and draw polyline
      (command "-layer"   "m"	 "-M-AREA"  "C"	       "20"
    	   "-M-AREA"  "Lt"	 "DASHED2"  "-M-AREA"  "p"
    	   "n"	      "-M-AREA"	 ""
      )  ;creates new layer -M-AREA
      (pln)  ;runs polyline loop
    
      (setvar "clayer" oldclayer)
      (princ)  ;exit cleanly
    )
    Last edited by Opie; 2007-07-30 at 02:19 PM. Reason: [CODE] tags added

  2. #2
    AUGI Addict fixo's Avatar
    Join Date
    2005-05
    Location
    Pietari, Venäjä
    Posts
    1,269
    Login to Give a bone
    1

    Default Re: lisp to draw multiple polylines

    Hi Stephen
    You can use something like this
    Code:
    (defun C:TEST()
    (alert "Use ESC to exit loop")
    (command "plinewid" 100)
    (while (not (vl-catch-all-error-p
                    (vl-catch-all-apply
                        (function (lambda()
    (progn                                  
    (command "_pline")
    (while (= (getvar "cmdactive") 1) (command pause)))))))))
    (command "plinewid" 0)
    (if (= (getvar "errno") 2)(princ "Interrupted by user"))  
    )

  3. #3
    Member
    Join Date
    2002-06
    Posts
    16
    Login to Give a bone
    0

    Default Re: lisp to draw multiple polylines

    Quote Originally Posted by fixo
    ...something like this
    ...or like this (as variant):
    Code:
    (defun C:TEST1 (/ pt)
      (vl-cmdf "plinewid" 100)
      (while (setq pt (getpoint "\nPick first point or <Exit>"))
        (princ "\nDraw polyline")
        (vl-cmdf "_pline" pt)
        (while (= (getvar "cmdactive") 1) (vl-cmdf pause))
      )
      (vl-cmdf "plinewid" 0)
    )

  4. #4
    I could stop if I wanted to
    Join Date
    2005-08
    Posts
    378
    Login to Give a bone
    0

    Cool Re: lisp to draw multiple polylines

    Thank you both.
    I will most likely use the later. Not that I am any good at Lisp, i atleast i have some idea what I am looking at ?

    Stephen

  5. #5
    I could stop if I wanted to
    Join Date
    2005-08
    Posts
    378
    Login to Give a bone
    0

    Cool Re: lisp to draw multiple polylines

    doooh,
    What am I saying they are both in vlisp, I give up !

    stephen

  6. #6
    I could stop if I wanted to
    Join Date
    2005-08
    Posts
    378
    Login to Give a bone
    0

    Cool Re: lisp to draw multiple polylines

    Fixo,
    That's great thank you very much. I like the whole idea of the esc to exit as I have a habbit of doing that.

    Stephen

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

    Cool Re: lisp to draw multiple polylines

    Guys,
    If I was to add this routine into another routine, what else could be used to stop the polyline function though allow the rest of the routine to then function ?

    Stephen

  8. #8
    AUGI Addict fixo's Avatar
    Join Date
    2005-05
    Location
    Pietari, Venäjä
    Posts
    1,269
    Login to Give a bone
    0

    Default Re: lisp to draw multiple polylines

    Hi Stephen
    In this case you need to use this as local
    defun, e.g.

    Code:
    ;;local defun to draw polylines multiply
    (defun multipoly()
    (alert "Use ESC to exit loop")
    (command "plinewid" 100)
    (while (not (vl-catch-all-error-p
                    (vl-catch-all-apply
                        (function (lambda()
    (progn                                  
    (command "_pline")
    (while (= (getvar "cmdactive") 1) (command pause)))))))))
    (command "plinewid" 0)
    (if (= (getvar "errno") 2)(princ "Interrupted by user"))  
    );_eof
    ;;main part
    (defunc C:main (/ )
    <<your code goes here>>
    (multipoly)
    <<another code goes here>>
    (princ)
    );_ eof

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

    Cool Re: lisp to draw multiple polylines

    Thank you Fixo,
    That works well.


    Stephen

Similar Threads

  1. LISP for filleting all polylines at once
    By leenaunton705564 in forum AutoLISP
    Replies: 1
    Last Post: 2015-07-22, 02:45 PM
  2. Total length of multiple polylines
    By Wish List System in forum AutoCAD Wish List
    Replies: 2
    Last Post: 2013-12-18, 10:03 PM
  3. Draw 3d-polylines to points
    By cadplayer in forum AutoLISP
    Replies: 0
    Last Post: 2012-02-07, 02:50 PM
  4. Area of multiple polylines
    By .chad in forum ACA General
    Replies: 10
    Last Post: 2010-01-27, 08:33 PM
  5. Polylines with multiple vertices same x,y, looks like one segment
    By norrin in forum AutoCAD Map 3D - General
    Replies: 2
    Last Post: 2009-09-11, 01:54 PM

Posting Permissions

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