Change layers w/ pausing to select objects to separate onto another layer

Change layers w/ pausing to select objects to separate onto another layer

cdmiske
Enthusiast Enthusiast
823 Views
4 Replies
Message 1 of 5

Change layers w/ pausing to select objects to separate onto another layer

cdmiske
Enthusiast
Enthusiast

Being a gluten for punishment I am working on a third script because this one is now important for our current marching orders.

 

Was trying to make a simple script to changes objects from one layer to another using laymrg which was fairly straight forward. I spend most of my day yesterday with no success to add functionality to either pause a command to select certain objects on a layer as other objects to convert them to a different layer. Example: the drawings I am useing have both the dining room furniture and the kitchen equipment on the same layer. I want to separate those objects while in the routine just because it would be nice to not have to do that separately outside the lisp routine.

 

;;; Wendy's Custom Function
;;; Tip: Wenlay.lsp   wenlay   (c) Chris Miske
;;; Credits for assistance: 
;;; Sets layers for walls, doors, glazing, etc.. of CAD scans to Wendy's layer standards
;;; May/2020

(defun C:wenlay(/ selset1 i output1)
  (setq sellst1 '())
  (command "._clayer" "0")
  (setvar 'CELTYPE "ByLayer")
  (setvar 'CECOLOR "ByLayer")
  
  (command "laymrg" "T" "A-GLAZ" "" "t" "A-Glaze-E" "y")
  (command "laymrg" "T" "A-DOOR" "" "t" "A-Door-E" "y")
  (command "laymrg" "T" "A-WALL" "" "t" "A-Wall-E" "y")
  (command "laymrg" "T" "P-SANR-FIXT" "" "t" "Q-Equip-E" "y")
  (command "pselect" pause) ;one of many attenpts to meke selecting object to work
  ;(command "change" pause "p" "la" "Q-Equip-E" "")
  ;
  ;(command "change")
  ;(while (= 1 (getvar "cmdactive"))
   ;(command pause))
  ;(command "p")
  ;(command "la")
  ;(command "Q-Equip-E")
  ;(command "")

  (princ)
 )
(princ)

 

I had tried multiple variations of calling ssget as well as a way to hold selected objects to hold and run the change command on with no success but have deleted every attempt.

0 Likes
Accepted solutions (1)
824 Views
4 Replies
Replies (4)
Message 2 of 5

johnyDFFXO
Advocate
Advocate
Accepted solution

Usually something like this:

 

(setq ss (ssget))
(command "change" ss "" "p" "la" "Q-Equip-E" "")

 

Or simply use the select command.

(command "select" pause)   ; pause is usually for a simple click (selection) only, but the select command is an exception.
(command "change" "p" "" "p" "la" "0" "") ; see p for a previous selection.

 

Or you also can use a trick with 

(command-s "select")

then the same as the previous example.

 
Message 3 of 5

cdmiske
Enthusiast
Enthusiast

@johnyDFFXO 

 

Thank you. Worked perfectly. Not sure why I struggled with this so much yesterday. Probably was overthinking it really.

0 Likes
Message 4 of 5

johnyDFFXO
Advocate
Advocate

I would say two things to remember

- the workflow is usually: somehow make a selection - run the command - use the previous selection.

- the second... the selection set always has to be closed even if it's stored in a variable... see: ss "" , or "_p" ""

Message 5 of 5

cdmiske
Enthusiast
Enthusiast

@johnyDFFXO 

Thank you for the tips. Hopefully they will help me on the other 2 scripts I am trying to develop to help with my workflow.

0 Likes