Results 1 to 5 of 5

Thread: Lisp question...where to add these lines

  1. #1
    I could stop if I wanted to
    Join Date
    2007-05
    Location
    Brookfield WI
    Posts
    331

    Default Lisp question...where to add these lines

    Here is what I want to add...will combine lines later

    Code:
    (progn (command "_.layer" "_t" "insert" "_s" "insert" "")
    (progn (command "_.layer" "_t" "cpwp" "_s" "cpwp" "")  
    (progn (command "_.layer" "_t" "cpdp" "_s" "cpdp" "")
    I also want to freeze the layers not listed but I get tons of different ones from architects do I use "*" for that?

    I want to add above text to this, at the end

    Code:
    (defun C:cpdp (/ entselection ;entity name of selection
    int count ;iteration counter for selection set
    objselection ;visual lisp activex object
    ssSelections ;selection set of entities
    )
      (setq old-Cmdecho (getvar "cmdecho"))
      (setvar "cmdecho" 0)
    (vl-load-com)
    (princ "nPick objects to be changed to layer cpdp: ")
    (if (setq ssSelections (ssget))
    (repeat (setq intcount (sslength ssSelections))
    (setq intcount (- intcount 1)
    entselection (ssname ssSelections intcount)
    objselection (vlax-ename->vla-object entselection)
    )
            (if (tblsearch "layer" "cpdp") ;; if layer is there then just put selected objects on that layer
    	  (progn
              ;(command "-layer" "s" "0" "")
    	  (vla-put-layer objselection "cpdp")
    	  );; end of progn
              (progn
    	  (command "-layer" "m" "cpdp" "c" "red" "cpdp" "p" "n" "cpdp" "");; if layer is not there make that layer and put selected objects on the layer
              ;(command "-layer" "s" "0" "")
    	  (vla-put-layer objselection "cpdp")
              );; end of progn
            );;end of if
    )
    )
        (setvar "cmdecho" old-Cmdecho)
    )
    suggestions?
    Last edited by Opie; 2007-08-24 at 06:30 PM. Reason: [CODE] tags added

  2. #2
    Certified AUGI Addict rkmcswain's Avatar
    Join Date
    2004-09
    Location
    Houston
    Posts
    7,543

    Exclamation Re: Lisp question...where to add these lines

    You don't need the (progn) function.

    I also condensed the three lines into one.

    Starting near the end of your lisp file

    Code:
    	)
    	;; end of progn
          )
          ;;end of if
        )
        (command "_.layer" "_t" "insert,cpwp,cpdp" "_s" "cpdp" "")
      )
      (setvar "cmdecho" old-Cmdecho)
    )
    As far as wildcards, yes * is the wildcard for everything. If you say freeze * , then you are trying to freeze every layer (which you cannot do - the current layer cannot be frozen).

    But you can use wildcards to freeze groups of layers like *TOP* - which will freeze all layers that contain the string "top"

  3. #3
    I could stop if I wanted to
    Join Date
    2007-05
    Location
    Brookfield WI
    Posts
    331

    Default Re: Lisp question...where to add these lines

    so I should then freeze the layers I need cpwp, insert and cpdp and erase what is left

    then use my layer state 'thaw all layers' to show what i need to wblock

    thanks for the help

  4. #4
    I could stop if I wanted to
    Join Date
    2007-05
    Location
    Brookfield WI
    Posts
    331

    Default Re: Lisp question...where to add these lines

    so I added the layers to freeze and the layers to thaw, but the only thing that happens is the selected objects turn to layer cpdp like they should

    no layers freeze or thaw afterwards, I don't know enough to find my mistake

    Code:
    (defun C:clean (/ entselection ;entity name of selection
    int count ;iteration counter for selection set
    objselection ;visual lisp activex object
    ssSelections ;selection set of entities
    )
      (setq old-Cmdecho (getvar "cmdecho"))
      (setvar "cmdecho" 0)
    (vl-load-com)
    (princ "nPick objects to be changed to layer cpdp: ")
    (if (setq ssSelections (ssget))
    (repeat (setq intcount (sslength ssSelections))
    (setq intcount (- intcount 1)
    entselection (ssname ssSelections intcount)
    objselection (vlax-ename->vla-object entselection)
    )
            (if (tblsearch "layer" "cpdp") ;; if layer is there then just put selected objects on that layer
    	  (progn
              ;(command "-layer" "s" "0" "")
    	  (vla-put-layer objselection "cpdp")
    	  );; end of progn
              (progn
    	  (command "-layer" "m" "cpdp" "c" "red" "cpdp" "p" "n" "cpdp" "");; if layer is not there make that layer and put selected objects on the layer
              ;(command "-layer" "s" "0" "")
    	  (vla-put-layer objselection "cpdp")
              )
    	;; end of progn
          )
          ;;end of if
        )
        (command "_.layer" "_f" "insert,cpwp,cpdp" "_s" "0,*1*,*2*,3sd,4ld,*8X11*,*AP*,ATLGC,AXTRC,*B*,*CH*,CLGHT,*CO*,*CPS*,CXTRC,*D*,*E*,*F*,*G*,IXTRC,*J*,*K*,*L*,*M*,*N*,*O*,*P*,*R*,*S*,*T*,VIEWPORT,*W*,*X*,ZXTRC" "")
      )
      (setvar "cmdecho" old-Cmdecho)
    )
    Last edited by Opie; 2007-08-27 at 02:46 PM. Reason: [CODE] tags added

  5. #5
    AUGI Addict kennet.sjoberg's Avatar
    Join Date
    2002-05
    Posts
    1,706

    Default Re: Lisp question...where to add these lines

    Quote Originally Posted by d_m_hopper View Post
    . . .no layers freeze or thaw afterwards, I don't know enough to find my mistake
    If one layer doesn’t exist it will error out the layer freeze command.

    : ) Happy Computing !

    kennet
    The essential thing is what you write in the post. . . .not the numbers of posts.

Similar Threads

  1. Need Lisp to Extend all lines
    By mikehaff in forum AutoLISP
    Replies: 10
    Last Post: 2011-12-20, 02:03 AM
  2. Drawing a row of four lines with Lisp.
    By Ko.Bach276562702 in forum AutoLISP
    Replies: 8
    Last Post: 2011-11-18, 02:18 PM
  3. Complex Lisp Question
    By BM75 in forum AutoLISP
    Replies: 7
    Last Post: 2010-03-12, 03:38 AM
  4. AutoCAD LISP for 3D Lines to 2D Lines
    By guala5 in forum AutoCAD General
    Replies: 3
    Last Post: 2009-03-24, 12:35 PM
  5. Lisp how to question
    By BCrouse in forum AutoLISP
    Replies: 38
    Last Post: 2005-03-31, 06:37 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
  •