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

Program to get layers from external file, write to file, and manipulate drawing

21 REPLIES 21
SOLVED
Reply
Message 1 of 22
adjg13
1018 Views, 21 Replies

Program to get layers from external file, write to file, and manipulate drawing

I have this program I have been working on in pieces. I put it all together and it doesn't work. It is supposed to:

 

  • read layer names from a set of external files
  • convert them to a set of dotted pairs
  • save the dotted pairs in a series of lists that correspond to the filenames
  • get all the layers present in a drawing
  • check each layer to see if it is already in one of the lists
  • if it is not in one of the list prompt the user and ask which list to place it in (which layer it should be changed to)
  • write the layer name to the approriate list
  • gather the objects based on the layers in each list
  • change the objects to the appropriate layer based on the list in which the original layer is contained.

Here is the code

 

(defun c:oneblk ()
	(command "undo" "m")
	(setq oldsnap (getvar "osmode"))
	(setq oldblips (getvar "blipmode"))
	
	(setvar "osmode" 0)
	(setvar "blipmode" 0)
	
	(setvar "qaflags" 1)
	(command "explode" "all" "")
	(setvar "qaflags" 0)
	
;;;;;;;;open files and read layers to layer filter lists;;;;;;;;
(setq layerslist (list "0" "AQSL-Clearance" "AQSL-Clearance-E" "AQSL-Detail" "AQSL-Doors-Drawers" "AQSL-Hidden" "AQSL-Hidden-E" "deletelist")) ;names of files and lists
(foreach thislayer layerslist
  (set (read thislayer) nil)
)
(setq count 0)
(foreach thislayer layerslist ;here thislayer is the filename and the name of the list that holds the file contents
  (setq f (open (strcat "C:\\filterlists\\" thislayer ".txt") "r"))
  (while (setq text (read-line f))
    (set (read thislayer)
      (cond
        (
	      (= 0 count)
	      (cons (cons 8 text) (eval (read thislayer)))
		)
		(
		  (append (eval (read thislayer)) (list (cons 8 text)))
		)
	  );cond
	);setq
    (setq count (+ count 1))
  );while
  (close f)
 );foreach
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(command "insert" "layers=C:\\important stuff\\layersblock.dwg" "0,0" "1" "1" "0" "")
(entdel (entlast))
;;;;;;;;;;;;;;;;;;;;;;Check for unlisted layers and write to file
(setq layerspresent (vla-get-layers (vla-get-activedocument (vlax-get-acad-object))))
(setq i 0)
(repeat (vla-get-count layerspresent)
  (setq thislayer (vla-get-name (vla-item layerspresent i))) ;thislayer is a string it's the layer names from inside the files
  (setq templist (cons 8 thislayer))
  (if ; not in any of the layer lists?
    (= ;'testexpr'
      (length
        (vl-remove
          nil ; remove any nil results from list returned by (mapcar)
          (mapcar ; apply member check of layer name across all lists, return list of results
            '(lambda (x) (member templist x)); applied to all in following list
            (list 0 AQSL-Clearance AQSL-Clearance-E AQSL-Detail AQSL-Doors-Drawers AQSL-Hidden AQSL-Hidden-E deletelist)
          ); mapcar
        ); vl-remove
      ); length
      0 ; all nils removed from list of results, so it's empty [returned nil for all lists]
    ); =
    (progn ; 'thenexpr'
      (initget "0 aqsl-CLEarance aqsl-CLeArance-e aqsl-DETail aqsl-DOOrs-drawers aqsl-HIDden aqsl-HIdden-E DELetelist")
      (setq
        userchoice
          (getkword
            (strcat
              "\nChange "
              thislayer
              " to which AQSL layer/delete layer? [0 aqsl-CLEarance aqsl-CLeArance-e aqsl-DETail aqsl-DOOrs-drawers aqsl-HIDden aqsl-HIdden-E DELetelist]"
            ); strcat
          ); getkword & 'userchoice'
        listname
          ; makes list name, also beginning of file name, from 'userchoice' with
          ; hyphen(s) and "and" removed, forced to all lower-case, as text string
        f (open (strcat "C:\\filterlists\\" listname "list.txt") "a")
      ); setq
      (write-line thislayer f)
      (close f)
      (set (read listname) (cons templist (eval (read listname)))); put layer name in local list
    ); progn -- 'thenexpr'
  ); if [no 'elseexpr' -- do nothing if it is already in one of the lists]
  (setq i (1+ i))
); repeat
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(setq AQSLLayers (list "0" "AQSL-Clearance" "AQSL-Clearance-E" "AQSL-Detail" "AQSL-Doors-Doors" "AQSL-Hidden" "AQSL-Hidden-E"))

(foreach thislayer AQSLLayers
  (setq lyrlist (ssget "X" (eval (read thislayer))))
    (if lyrlist
	  (progn
	    (command "change" lyrlist "" "p" "layer" thislayer "")
		(command "change" lyrlist "" "p" "color" "bylayer" "")
		(command "change" lyrlist "" "p" "ltype" "bylayer" "")
      )
    )

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(setq lyrlist (ssget "X" (eval (read thislayer))))
(if lyrlist
  (progn
    (command "erase" lyrlist "")
  )
)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(setq pntlist (ssget "X" '(0 . "point")))
  (if pntlist
    (command "erase" pntlist "")
  )
)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
	(princ)
	
	(command "-layer" "s" "0" "")
	(command "-insert" "AQSL-ITMNO" "6,6" "1" "1" "0" "explode" "last")
	(command "-overkill" "all" "" "")
	(c:pm)
	(setvar "osmode" oldsnap)
	(setvar "blipmode" oldblips)
)

 I have also attached a sample of the files. It is just the names of the layers. Written one per line.

21 REPLIES 21
Message 2 of 22
Kent1Cooper
in reply to: adjg13


@adjg13 wrote:

I have this program I have been working on in pieces. I put it all together and it doesn't work. ....


Before digging into the nitty-gritty, it would be helpful to know in what way it doesn't work.  Do you get an error message?  Does nothing happen?  Does something happen but not what you intended?  Does something happen but not all you intended?  etc....

Kent Cooper, AIA
Message 3 of 22
adjg13
in reply to: adjg13

I made a slight change to the code. The first error I am getting is in this loop

 

(setq layerslist (list "0" "AQSL-Clearance" "AQSL-Clearance-E" "AQSL-Detail" "AQSL-Doors-Drawers" "AQSL-Hidden" "AQSL-Hidden-E" "deletelist")) ;names of files and lists
(setq count 0)
(foreach thislayer layerslist ;here thislayer is the filename and the name of the list that holds the file contents
  (setq f (open (strcat "C:\\filterlists\\" thislayer ".txt") "r"))
  (while (setq text (read-line f))
    (set (read thislayer)
      (cond
        (
	      (= 0 count)
	      (cons (cons 8 text) (eval (read thislayer)))
		)
		(
		  (append (eval (read thislayer)) (list (cons 8 text)))
		)
	  );cond
	);setq
    (setq count (+ count 1))
  );while
  (close f)
 );foreach

 You helped me before with this part of the code Kent. I changed the names of the files I was using to correspond with the actual layer names in AutoCAD. I get the error symbolp 0 when I run it. I assume because at the beginning where it says (set (read thislayer) it is getting 0 as an int instead of a string. I am not exactly sure though.

Message 4 of 22
Kent1Cooper
in reply to: adjg13


@adjg13 wrote:

I made a slight change to the code. The first error I am getting is in this loop

.... I get the error symbolp 0 when I run it. I assume because at the beginning where it says (set (read thislayer) it is getting 0 as an int instead of a string. I am not exactly sure though.


That sounds right -- you can't use a number [integer or real] as a variable name.  Maybe you can use a stand-in:

....

    (set (read (if (= thislayer "0") "Zero" thislayer)))
      (cond

....

 

And you would need to use "Zero" in place of "0" in some other lists and (initget) arguments and prompts.  Then later, when you want to designate that Layer 0 is the one you want to put things from some Layer(s) on, you would need to work it back again, with another (if) function looking at the target Layer, and substituting "0" back in if it's "zero", such as:

....

     (command "change" lyrlist "" "p" "layer" (if (= thislayer "Zero") "0" thislayer) "")

....

Kent Cooper, AIA
Message 5 of 22
adjg13
in reply to: Kent1Cooper

Thank you. That fixed it. I went ahead and changed all the instances of 0 to Zero. I only actually use 0 once or twice in the program so it is easier to change that.

 

Another problem I am having in this same part of the program is implementing some type of error check so that the same layers are not added twice to one list. The problem is when I try to use (member (cons 8 text) (read (thislayer))) I get error bad argument consp "Zero". I assume because Zero is not yet a list. i tried using multiple conditions to overcome this, but I still keep getting the same error.

 

Here is one solution I tried that still won't work.

 

(setq layerslist (list "Zero" "AQSL-Clearance" "AQSL-Clearance-E" "AQSL-Detail" "AQSL-Doors-Drawers" "AQSL-Hidden" "AQSL-Hidden-E" "deletelist")) ;names of files and lists
(setq count 0)
(foreach thislayer layerslist ;here thislayer is the filename and the name of the list that holds the file contents
  (setq f (open (strcat "C:\\filterlists\\" thislayer ".txt") "r"))
  (while (setq text (read-line f))
    (set (read thislayer)
      (cond
        (
	      (and (= 0 count) (or (= nil (listp (read thislayer))) (= nil (member (cons 8 text) (read thislayer)))))
	      (cons (cons 8 text) (eval (read thislayer)))
		)
		(
		  (if (= nil (member (cons 8 text) (read thislayer)))
		    (append (eval (read thislayer)) (list (cons 8 text)))
		  )
		)
	  );cond
	);set
    (setq count (+ count 1))
  );while
  (close f)
 );foreach

If I run it once, it adds (8 . 200) to Zero and does not modify any of the other lists. The second time I run it, I get a bad argument type consp Zero error.

 

Message 6 of 22
Kent1Cooper
in reply to: adjg13


@adjg13 wrote:

... when I try to use (member (cons 8 text) (read (thislayer))) I get error bad argument consp "Zero". I assume because Zero is not yet a list. ....


[The parentheses around the word thislayer in the blue above are extra, but I don't see them in the code itself.]

 

Try changing all the places where you have (read thislayer) except the one in this line:

 

(set (read thislayer)

 

that don't already have an (eval) wrapper around them as some do, to (eval (read thislayer))

Kent Cooper, AIA
Message 7 of 22
adjg13
in reply to: Kent1Cooper

I found what I think will be a much simpler solution. I will just set each list to nil at the beginning of the program and since the new layers will be written to the external file it can just put in the entire updated list each time the program runs.

 

I basically took the original code and added

 

(foreach x layerslist
  (if x (set (read x) nil))
)

 

It isn't the nice error checking I would like to have, but i just can't seem to get anything else to work. I'm going to keep going through this, I knwo there are more problems with it farther down.

Message 8 of 22
adjg13
in reply to: adjg13

So here is the updated code.

 

(defun c:oneblk ()
	(command "undo" "m")
	(setq oldsnap (getvar "osmode"))
	(setq oldblips (getvar "blipmode"))
	
	(setvar "osmode" 0)
	(setvar "blipmode" 0)
	
	(setvar "qaflags" 1)
	(command "explode" "all" "")
	(setvar "qaflags" 0)
	
;;;;;;;;open files and read layers to layer filter lists;;;;;;;;
(setq layerslist (list "Zero" "AQSL-Clearance" "AQSL-Clearance-E" "AQSL-Detail" "AQSL-Doors-Drawers" "AQSL-Hidden" "AQSL-Hidden-E" "deletelist")) ;names of files and lists
(setq count 0)
(foreach x layerslist
  (if x (set (read x) nil))
)
(foreach thislayer layerslist ;here thislayer is the filename and the name of the list that holds the file contents
  (setq f (open (strcat "C:\\filterlists\\" thislayer ".txt") "r"))
  (while (setq text (read-line f))
    (set (read thislayer)
      (cond
        (
	      (= 0 count)
	      (cons (cons 8 text) (eval (read thislayer)))
		)
		(
		  (append (eval (read thislayer)) (list (cons 8 text)))
		)
	  );cond
	);set
    (setq count (+ count 1))
  );while
  (close f)
 );foreach
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(command "insert" "layers=C:\\important stuff\\layersblock.dwg" "0,0" "1" "1" "0" "")
(entdel (entlast))
;;;;;;;;;;;;;;;;;;;;;;Check for unlisted layers and write to file
(setq layerspresent (vla-get-layers (vla-get-activedocument (vlax-get-acad-object))))
(setq i 0)
(repeat (vla-get-count layerspresent)
  (setq thislayer (vla-get-name (vla-item layerspresent i))) ;thislayer is a string it's the layer names from inside the files
  (setq templist (cons 8 thislayer))
  (if ; not in any of the layer lists?
    (= ;'testexpr'
      (length
        (vl-remove
          nil ; remove any nil results from list returned by (mapcar)
          (mapcar ; apply member check of layer name across all lists, return list of results
            '(lambda (x) (member templist x)); applied to all in following list
            (list Zero AQSL-Clearance AQSL-Clearance-E AQSL-Detail AQSL-Doors-Drawers AQSL-Hidden AQSL-Hidden-E deletelist)
          ); mapcar
        ); vl-remove
      ); length
      0 ; all nils removed from list of results, so it's empty [returned nil for all lists]
    ); =
    (progn ; 'thenexpr'
      (initget "Zero aqsl-CLEarance aqsl-CLeArance-e aqsl-DETail aqsl-DOOrs-drawers aqsl-HIDden aqsl-HIdden-E DELetelist")
      (setq
        userchoice
          (getkword
            (strcat
              "\nChange "
              thislayer
              " to which AQSL layer/delete layer? [Zero aqsl-CLEarance aqsl-CLeArance-e aqsl-DETail aqsl-DOOrs-drawers aqsl-HIDden aqsl-HIdden-E DELetelist]"
            ); strcat
          ); getkword & 'userchoice'
        listname userchoice
          ; makes list name, also beginning of file name, from 'userchoice' with
          ; hyphen(s) and "and" removed, forced to all lower-case, as text string
        f (open (strcat "C:\\filterlists\\" listname ".txt") "a")
      ); setq
      (write-line thislayer f)
      (close f)
      (set (read listname) (cons templist (eval (read listname)))); put layer name in local list
    ); progn -- 'thenexpr'
  ); if [no 'elseexpr' -- do nothing if it is already in one of the lists]
  (setq i (1+ i))
); repeat
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(setq AQSLLayers (list "Zero" "AQSL-Clearance" "AQSL-Clearance-E" "AQSL-Detail" "AQSL-Doors-Doors" "AQSL-Hidden" "AQSL-Hidden-E"))

(foreach thislayer AQSLLayers
  (setq lyrlist (ssget "X" (eval (read thislayer))))
    (if lyrlist
	  (progn
	    (command "change" lyrlist "" "p" "layer" (if (= thislayer "Zero") "0" thislayer) "")
		(command "change" lyrlist "" "p" "color" "bylayer" "")
		(command "change" lyrlist "" "p" "ltype" "bylayer" "")
      )
    )

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(setq lyrlist (ssget "X" (eval (read thislayer))))
(if lyrlist
  (progn
    (command "erase" lyrlist "")
  )
)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(setq pntlist (ssget "X" '(0 . "point")))
  (if pntlist
    (command "erase" pntlist "")
  )
)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
	(princ)
	
	(command "-layer" "s" "0" "")
	(command "-insert" "AQSL-ITMNO" "6,6" "1" "1" "0" "explode" "last")
	(command "-overkill" "all" "" "")
	(c:pm)
	(setvar "osmode" oldsnap)
	(setvar "blipmode" oldblips)
)

 Everything works except for the part pasted below.

 

(setq AQSLLayers (list "Zero" "AQSL-Clearance" "AQSL-Clearance-E" "AQSL-Detail" "AQSL-Doors-Doors" "AQSL-Hidden" "AQSL-Hidden-E"))

(foreach thislayer AQSLLayers
  (setq lyrlist (ssget "X" (eval (read thislayer))))
    (if lyrlist
	  (progn
	    (command "change" lyrlist "" "p" "layer" (if (= thislayer "Zero") "0" thislayer) "")
		(command "change" lyrlist "" "p" "color" "bylayer" "")
		(command "change" lyrlist "" "p" "ltype" "bylayer" "")
      )
    )

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(setq lyrlist (ssget "X" (eval (read thislayer))))
(if lyrlist
  (progn
    (command "erase" lyrlist "")
  )
)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(setq pntlist (ssget "X" '(0 . "point")))
  (if pntlist
    (command "erase" pntlist "")
  )
)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
	(princ)
	
	(command "-layer" "s" "0" "")
	(command "-insert" "AQSL-ITMNO" "6,6" "1" "1" "0" "explode" "last")
	(command "-overkill" "all" "" "")
	(c:pm)
	(setvar "osmode" oldsnap)
	(setvar "blipmode" oldblips)

 When I run this part I get an error: bad point argument

 


I went through line by line and just wrote something simple that uses the same technique. Here is the input line by line.

 (setq alist (list Zero AQSL-Clearance))

; this is alist printed out (((8 . "200") (8 . "202") (8 . "200-2D-ONLY") (8 . "258PC-LEGS") (8 . "232") (8 . "250") (8 . "252") (8 . "254") (8 . "0") (8 . "800") (8 . "801") (8 . "802") (8 . "DEFPOINTS")) ((8 . "206") (8 . "AQSL-Clearance")))

(foreach thingy alist (setq lyrlist (ssget "X" (eval (read thingy)))))

; error: bad argument type: stringp ((8 . "200") (8 . "202") (8 . "200-2D-ONLY") (8 . "258PC-LEGS") (8 . "232") (8 . "250") (8 . "252") (8 . "254") (8 . "0") (8 . "800") (8 . "801") (8 . "802") (8 . "DEFPOINTS"))

 I am guessing this is what it is trying to do in the actual program. I want to use the lists as fliter lists for my ssget in this part. I'm thinking that it is reading each dotted pair as a string instead of a dotted pair. I am going to probe a little more in the VLIDE and see.

 

This is really frustrating. This is the last part of the function and I can't get it to work.

 

EDIT: they are being stored as dotted pairs, however lyrlist isn't storing anything. I don't understand the stringp error.

Message 9 of 22
Kent1Cooper
in reply to: adjg13


@adjg13 wrote:

....

 

....
(setq pntlist (ssget "X" '(0 . "point"))) ....

....
I went through line by line and just wrote something simple that uses the same technique. Here is the input line by line.

 (setq alist (list Zero AQSL-Clearance))

; this is alist printed out (((8 . "200") (8 . "202") (8 . "200-2D-ONLY") (8 . "258PC-LEGS") (8 . "232") (8 . "250") (8 . "252") (8 . "254") (8 . "0") (8 . "800") (8 . "801") (8 . "802") (8 . "DEFPOINTS")) ((8 . "206") (8 . "AQSL-Clearance")))

(foreach thingy alist (setq lyrlist (ssget "X" (eval (read thingy)))))
....

.... I want to use the lists as fliter lists for my ssget in this part. I'm thinking that it is reading each dotted pair as a string instead of a dotted pair. I am going to probe a little more in the VLIDE and see.

 

This is really frustrating. This is the last part of the function and I can't get it to work.

 

EDIT: they are being stored as dotted pairs, however lyrlist isn't storing anything. I don't understand the stringp error.


Some thoughts [they may not fix everything]....

 

You're formatting at least some (ssget) filter lists without enough parentheses.  For example:

 

(setq pntlist (ssget "X" '(0 . "point")))

 

should be:

 

(setq pntss (ssget "X" '((0 . "point")))) ; [and I changed the variable name, since what (ssget) returns won't be a list, but a selection set]

 

An (ssget) filter list is a list of lists [or dotted pairs], since you might include more than one entity data entry in such a filter list, e.g. for all the Point entities on Layer 0:

 

(setq pntss (ssget "X" '((0 . "point") (8 . "0")))) ; both dotted pairs included together in one list

 

Even when there's only one such entry, it still needs to be inside another pair of parentheses, whether in a "quoted" list [with the apostrophe] as above, or with an explicit (list) function [without the apostrophe] when anything needing evaluation such as a variable name or calculation is inside the filter list:

 

(setq pntss (ssget "X" (list '(0 . "point") (cons 8 LayerNameVariable))))

 

In your "something simple" example, the 'alist' variable holds a list containing just two items, each of which is a list of dotted pairs.  So to do:

 

(foreach thingy alist ... do something involving ... (read thingy) ...

 

means that you're asking it to (read) a list of dotted pairs, which is not a valid argument to the (read) function.  The stringp error is because (read) wants a string, basically to take its quotation marks off, and it's getting a list of dotted pairs [the one printed out in the error message] instead.  If you want 'alist' to be one combined list of dotted pairs, so that (foreach thingy alist ...) will see the dotted pairs themselves, then use this:

 

(setq alist (append Zero AQSL-Clearance)) ; instead of (list)

 

Then if what you want is to find, for example for the first item there, everything on Layer 200, each item in 'alist' is already the dotted-pair Layer-designating entity data entry that you need to put inside the (ssget) filter list, so you want to use the thingy "straight" rather than with (read) applied to it, so you would need to do:

 

(foreach thingy alist (setq lyrss (ssget "X" (list thingy)))) ; [again, I changed the variable name]

 

Work with those, and see whether any problems remain.

Kent Cooper, AIA
Message 10 of 22
adjg13
in reply to: adjg13

I think I may have found why it isn't using the filterlist properly. I noticed in each of the lists there is a space between the dotted pairs and with ssget if you specify a filter list with multiple dotted pairs there aren't supposed to be any spaces. Why are the items getting added to the list like this? Is there a way to remove the spaces?

 

EDIT: I am trying something different along these lines.

 

(setq AQSLLayers (list ZERO AQSL-CLEARANCE AQSL-CLEARANCE-E AQSL-DETAIL AQSL-DOORS-DRAWERS AQSL-HIDDEN AQSL-HIDDEN-E))

(foreach thislayer AQSLLayers
  (foreach z thislayer
    (setq lyrss (ssget "X" '(z)))
  )
  (if lyrlist
	(progn
	  (if (= thislayer "ZERO") (setq thislayer "0"))
	  (command "change" lyrss "" "p" "layer" thislayer "")
	  (command "change" lyrss "" "p" "color" "bylayer" "")
	  (command "change" lyrss "" "p" "ltype" "bylayer" "")
    )
  )
)

 where I add the objects on the layers to lyrss one at a time. I want it to go through each list and then go through each dotted pair in each list add them to lyrlist, change to the appropriate layer and then go to the next list. This is not working either. It doesn't do anything.

Message 11 of 22
adjg13
in reply to: adjg13

Forget everything I just said. I just realized what I am doing wrong. I swear I am still a noob. I'm trying to put the contents of AQSLLayers into the ssget function by name. I didn't realize that when I do (setq AQSLLayers (list whatever ...)) it doesn't keep the names associated with the lists. I'm going to change it so it iterates through the list with a counter instead of using foreach.

Message 12 of 22
adjg13
in reply to: adjg13

Alright I give up. Here is my latest attempt.

 

(setq AQSLLayers (list ZERO AQSL-CLEARANCE AQSL-CLEARANCE-E AQSL-DETAIL AQSL-DOORS-DRAWERS AQSL-HIDDEN AQSL-HIDDEN-E))
(setq AQSLLayerstr (list "ZERO" "AQSL-CLEARANCE" "AQSL-CLEARANCE-E" "AQSL-DETAIL" "AQSL-DOORS-DRAWERS" "AQSL-HIDDEN" "AQSL-HIDDEN-E"))
(setq j 0)
(repeat (length AQSLLayers)
  (setq filtlist (nth j AQSLLayers))
  (setq lyrlist (ssget "X" '(filtlist)))
  (if lyrlist
	(progn
	  (if (= (nth j AQSLLayerstr) "ZERO") (setq thislayer "0") (setq thislayer (nth j AQSLLayerstr)))
	  (command "change" lyrlist "" "p" "layer" thislayer "")
	  (command "change" lyrlist "" "p" "color" "bylayer" "")
	  (command "change" lyrlist "" "p" "ltype" "bylayer" "")
	  (setq j (1+ j))
    )
  )
)

 I keep getting the same error. Bad point argument from the filtlist. I inspected filtlist and it is a proper list of dotted pairs.

Message 13 of 22
Kent1Cooper
in reply to: adjg13


@adjg13 wrote:

Alright I give up. Here is my latest attempt.

 

(setq AQSLLayers (list ZERO AQSL-CLEARANCE AQSL-CLEARANCE-E AQSL-DETAIL AQSL-DOORS-DRAWERS AQSL-HIDDEN AQSL-HIDDEN-E))
(setq AQSLLayerstr (list "ZERO" "AQSL-CLEARANCE" "AQSL-CLEARANCE-E" "AQSL-DETAIL" "AQSL-DOORS-DRAWERS" "AQSL-HIDDEN" "AQSL-HIDDEN-E"))
(setq j 0)
(repeat (length AQSLLayers)
  (setq filtlist (nth j AQSLLayers))
  (setq lyrlist (ssget "X" '(filtlist)))
....

 I keep getting the same error. Bad point argument from the filtlist. I inspected filtlist and it is a proper list of dotted pairs.


[I briefly posted a reply to Message 10, then deleted it when I saw message 11, since much of what I had noticed isn't applicable any more.  The following is similar to one thing that was in the delted message.]

 

Since filtlist is a variable that must be evaluated to get the dotted-pair list [e.g. (8 . "SomeLayer")] out of it, it can't be used in (ssget) in a quoted list with the apostrophe, which means "read what follows literally; there's nothing here to evaluate."  You need to use the (list) function explicitly:

 

  (setq lyrlist (ssget "X" (list filtlist)))

 

EDIT:  Oh, but wait....  If the [for example] Zero list that would be the first put into the filtlist variable looks something like this:

 

((8 . "ABC") (8 . "DEF") (8 . "GHI"))

 

then, if I'm interpreting the relationship of lists correctly, I think your (setq lyrlist...) function should really be

 

  (setq lyrlist (ssget "X" filtlist)); <-- variable name straight, since it's already a list of dotted pairs

 

but effectively, that would be doing this:

 

  (setq lyrlist (ssget "X" ((8 . "ABC") (8 . "DEF") (8 . "GHI"))))

 

and you can't use it in that form as an (ssget) filter list.  At least a quick test finds that (ssget) won't take multiple entries with the same DXF code number [the 8 in this case].  What you would need, to get all the items on all those Layers in one (ssget) function, would be:

 

  (setq lyrlist (ssget "X" ((8 . "ABC,DEF,GHI"))))

 

If I'm not misinterpreting something about the structure of the different levels of lists, it makes me think you'd be better off putting Layer names into lists without dotted-pairing them with 8's, because I think it would easier to roll those together into the right format for a filter list.  You could even put them into a comma-delimited string directly, rather than using a list.

 

Or maybe you could step through the filtlist variable and use each (8 . "SomeLayer") item in it separately as the filter list in its own (ssget) function, in which case you would need to either combine the resulting selections together before changing their properties, or do the properties changes on each of those one-Layer's-worth-at-a-time selections separately.

Kent Cooper, AIA
Message 14 of 22
adjg13
in reply to: Kent1Cooper

Wow, I kind of want to cry now. I will have to go back to here.

 

(setq layerslist (list "0list" "detaillist" "clearancelist" "clearanceelist" "doorsdrawerslist" "hiddenlist" "hiddenelist" "deletelist"))
(foreach thislayer layerslist
  (set (read thislayer) nil)
)
(setq count 0)
(foreach thislayer layerslist
  (setq f (open (strcat "C:\\filterlists\\" thislayer ".txt") "r"))
  (while (setq text (read-line f))
    (set (read thislayer)
      (cond
        (
	      (= 0 count)
	      (cons (cons 8 text) (eval (read thislayer)))
		)
		(
		  (append (eval (read thislayer)) (list (cons 8 text)))
		)
	  );cond
	);setq
    (setq count (+ count 1))
  );while
  (close f)
 );foreach

 and change the way each list is constructed. This should be easier actually. If you saw the files I posted in the beginning it is a layer name per line.

 

I am going to read each layer name into long strings corresponding to each filename one line at a time using strcat and in the end make the dotted pair (8 . "200,202,300,...") to use.

 

Thank you Kent. I will keep this thread updated. There is a lot of good stuff in here for AutoLISP beginners like myself.

 

Message 15 of 22
adjg13
in reply to: adjg13

EDIT: Sorry, here is the code in its entirety

 

(defun c:oneblk ()
	(command "undo" "m")
	(setq oldsnap (getvar "osmode"))
	(setq oldblips (getvar "blipmode"))
	
	(setvar "osmode" 0)
	(setvar "blipmode" 0)
	
	(setvar "qaflags" 1)
	(command "explode" "all" "")
	(setvar "qaflags" 0)
	
;;;;;;;;open files and read layers to layer filter lists;;;;;;;;
(setq layerslist (list "ZERO" "AQSL-CLEARANCE" "AQSL-CLEARANCE-E" "AQSL-DETAIL" "AQSL-DOORS-DRAWERS" "AQSL-HIDDEN" "AQSL-HIDDEN-E" "DELETE")) ;names of files and lists
(setq count 0)
(foreach x layerslist
  (if x (set (read x) nil))
)
(foreach thislayer layerslist ;here thislayer is the filename and the name of the list that holds the file contents
  (setq f (open (strcat "C:\\filterlists\\" thislayer ".txt") "r"))
  (while (setq text (read-line f))
    (set (read thislayer)
      (cond
        (
	      (= 0 count)
	      (cons (cons 8 text) (eval (read thislayer)))
		)
		(
		  (append (eval (read thislayer)) (list (cons 8 text)))
		)
	  );cond
	);set
    (setq count (+ count 1))
  );while
  (close f)
 );foreach
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(command "insert" "layers=C:\\important stuff\\layersblock.dwg" "0,0" "1" "1" "0" "")
(entdel (entlast))
;;;;;;;;;;;;;;;;;;;;;;Check for unlisted layers and write to file
(setq layerspresent (vla-get-layers (vla-get-activedocument (vlax-get-acad-object))))
(setq i 0)
(repeat (vla-get-count layerspresent)
  (setq thislayer (vla-get-name (vla-item layerspresent i))) ;thislayer is a string it's the layer names from inside the files
  (setq templist (cons 8 thislayer))
  (if ; not in any of the layer lists?
    (= ;'testexpr'
      (length
        (vl-remove
          nil ; remove any nil results from list returned by (mapcar)
          (mapcar ; apply member check of layer name across all lists, return list of results
            '(lambda (x) (member templist x)); applied to all in following list
            (list ZERO AQSL-CLEARANCE AQSL-CLEARANCE-E AQSL-DETAIL AQSL-DOORS-DRAWERS AQSL-HIDDEN AQSL-HIDDEN-E DELETE)
          ); mapcar
        ); vl-remove
      ); length
      0 ; all nils removed from list of results, so it's empty [returned nil for all lists]
    ); =
    (progn ; 'thenexpr'
      (initget "Zero aqsl-CLEarance aqsl-CLeArance-e aqsl-DETail aqsl-DOOrs-drawers aqsl-HIDden aqsl-HIdden-E DELetelist")
      (setq
        userchoice
          (getkword
            (strcat
              "\nChange "
              thislayer
              " to which AQSL layer/delete layer? [Zero aqsl-CLEarance aqsl-CLeArance-e aqsl-DETail aqsl-DOOrs-drawers aqsl-HIDden aqsl-HIdden-E DELetelist]"
            ); strcat
          ); getkword & 'userchoice'
        listname (strcase userchoice)
          ; makes list name, also beginning of file name, from 'userchoice' with
          ; hyphen(s) and "and" removed, forced to all lower-case, as text string
        f (open (strcat "C:\\filterlists\\" listname ".txt") "a")
      ); setq
      (write-line thislayer f)
      (close f)
      (set (read listname) (cons templist (eval (read listname)))); put layer name in local list
    ); progn -- 'thenexpr'
  ); if [no 'elseexpr' -- do nothing if it is already in one of the lists]
  (setq i (1+ i))
); repeat
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(setq AQSLLayers (list ZERO AQSL-CLEARANCE AQSL-CLEARANCE-E AQSL-DETAIL AQSL-DOORS-DRAWERS AQSL-HIDDEN AQSL-HIDDEN-E))
(setq AQSLLayerstr (list "ZERO" "AQSL-CLEARANCE" "AQSL-CLEARANCE-E" "AQSL-DETAIL" "AQSL-DOORS-DRAWERS" "AQSL-HIDDEN" "AQSL-HIDDEN-E"))
(foreach x AQSLLayerstr
  (foreach y (eval (read x))
    (setq lyrlist (ssget "X" (list y)))
  )
  (if lyrlist
    (progn
      (if (= (read x) "ZERO") (setq thislayer "0") (setq thislayer (read x)))
      (command "change" lyrlist "" "p" "layer" thislayer "")
      (command "change" lyrlist "" "p" "color" "bylayer" "")
      (command "change" lyrlist "" "p" "ltype" "bylayer" "")
    )
  )
) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (setq lyrlist (ssget "X" (list deletelist)) pntlist (ssget "X" '((0 . "point")))) (if lyrlist (command "erase" lyrlist "")) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (princ) (command "-layer" "s" "0" "") (command "-insert" "AQSL-ITMNO" "6,6" "1" "1" "0" "explode" "last") (command "-overkill" "all" "" "") (c:pm) (setvar "osmode" oldsnap) (setvar "blipmode" oldblips) )

 

 

So I attempted a solution to this problem that takes the layers and reads them in and then saves the lists as a long string of layer names e.g. "200,254,doors,...", but I realized that I would have rewrite a lot more of the code than it's worth to implement this.

 

As a solution, I have left everything exactly the way it is and I am attempting to select the objects one layer at a time and change them to the desired layer using nested foreach functions as shown below.

 

(setq AQSLLayers (list ZERO AQSL-CLEARANCE AQSL-CLEARANCE-E AQSL-DETAIL AQSL-DOORS-DRAWERS AQSL-HIDDEN AQSL-HIDDEN-E))
(setq AQSLLayerstr (list "ZERO" "AQSL-CLEARANCE" "AQSL-CLEARANCE-E" "AQSL-DETAIL" "AQSL-DOORS-DRAWERS" "AQSL-HIDDEN" "AQSL-HIDDEN-E"))
(foreach x AQSLLayerstr
  (foreach y (eval (read x))
    (setq lyrlist (ssget "X" (list y)))
  )
  (if lyrlist
    (progn
	  (if (= (read x) "ZERO") (setq thislayer "0") (setq thislayer (read x)))
	  (command "change" lyrlist "" "p" "layer" thislayer "")
      (command "change" lyrlist "" "p" "color" "bylayer" "")
	  (command "change" lyrlist "" "p" "ltype" "bylayer" "")
    )
  )
)

 I want it to go through the list of strings and for each string go to the list that that string represents and then for each item on that list, select it and add it to the selection set lyrlist.

 

I keep getting the error bad syntax of function call.

Message 16 of 22
Kent1Cooper
in reply to: adjg13


@adjg13 wrote:

....

... I am attempting to select the objects one layer at a time and change them to the desired layer using nested foreach functions as shown below.

 

...
(setq AQSLLayerstr (list "ZERO" "AQSL-CLEARANCE" "AQSL-CLEARANCE-E" "AQSL-DETAIL" "AQSL-DOORS-DRAWERS" "AQSL-HIDDEN" "AQSL-HIDDEN-E"))
(foreach x AQSLLayerstr
  (foreach y (eval (read x))
    (setq lyrlist (ssget "X" (list y)))
  )
  (if lyrlist
    (progn
	  (if (= (read x) "ZERO") (setq thislayer "0") (setq thislayer (read x)))
	  (command "change" lyrlist "" "p" "layer" thislayer "")
      (command "change" lyrlist "" "p" "color" "bylayer" "")
	  (command "change" lyrlist "" "p" "ltype" "bylayer" "")
    )
  )
)

 I want it to go through the list of strings and for each string go to the list that that string represents and then for each item on that list, select it and add it to the selection set lyrlist.

 

I keep getting the error bad syntax of function call.


[It looks like you don't need the AQSLLayerstr list any more.]

 

Try this:

 

 (foreach x AQSLLayerstr ; instances of x below will be the text-string version
  (foreach y (eval (read x)) ; (eval (read x)) appropriate here for getting list of dotted pairs from variable
    (setq lyrlist (ssget "X" (list y)))
  )
  (if lyrlist
    (progn
;;    (if (= (read x) "ZERO") (setq thislayer "0") (setq thislayer (read x)))

;;      (read) not wanted -- functions below need text string
      (if (= x "ZERO") (setq thislayer "0") (setq thislayer x))

      (command "change" lyrlist "" "p" "layer" thislayer "")
      (command "change" lyrlist "" "p" "color" "bylayer" "")
      (command "change" lyrlist "" "p" "ltype" "bylayer" "")
    ); progn
  ); if
); foreach

 

By the way, there's a CHPROP command which will get you, right from the command name, to the same place as the CHANGE command and its Properties option, eliminating the need to specify the "p" option.  And you can change more than one Property in the same command [whether Change or Chprop].  So this:

      (command "change" lyrlist "" "p" "layer" thislayer "")
      (command "change" lyrlist "" "p" "color" "bylayer" "")
      (command "change" lyrlist "" "p" "ltype" "bylayer" "")

can be reduced to this:

      (command "_.chprop" lyrlist "" "_layer" thislayer "_color" "_bylayer" "_ltype" "_bylayer" "")     

Kent Cooper, AIA
Message 17 of 22
Kent1Cooper
in reply to: Kent1Cooper


@Kent1Cooper wrote:

....

[It looks like you don't need the AQSLLayerstr list any more.]
....

Duh...  I meant AQSLLayer [the list of non-text-string list-variable names].

Kent Cooper, AIA
Message 18 of 22
Kent1Cooper
in reply to: Kent1Cooper

But now that I look at the structure more closely, I realize another correction you need to make:

 

 (foreach x AQSLLayerstr
  (foreach y (eval (read x))

    (setq lyrlist (ssget "X" (list y)))
  )
  (if lyrlist ; this needs to be inside the above (foreach) function, so that it will do it with all Layers in

    ; each list -- as done here, it will change the properties of only things on the last Layer in the list
    (progn
      (if (= x "ZERO") (setq thislayer "0") (setq thislayer x))

      (command "_.chprop" lyrlist "" "_layer" thislayer "_color" "_bylayer" "_ltype" "_bylayer" "")

    ); progn
  ); if
); foreach

 

Try it this way:

 

 (foreach x AQSLLayerstr
  (foreach y (eval (read x))

    (setq lyrlist (ssget "X" (list y)))
    (if lyrlist
      (progn
        (if (= x "ZERO") (setq thislayer "0") (setq thislayer x))

        (command "_.chprop" lyrlist "" "_layer" thislayer "_color" "_bylayer" "_ltype" "_bylayer" "")

      ); progn
    ); if

  ); foreach [inner] ; moved from above
); foreach [outer]

 

And here's another little tweak you can make, to eliminate the need for that (progn) function:

....

    (if lyrlist
      (command "_.chprop" lyrlist "" "_layer" (if (= x "ZERO") "0" x) "_color" "_bylayer" "_ltype" "_bylayer" "")

    ); if

....

Kent Cooper, AIA
Message 19 of 22
adjg13
in reply to: Kent1Cooper



EDIT: Just saw your above posts ignore this. I'll try what you've posted.

 

I'm a little confused here. I'm guessing you meant the AQSLLayers list.

 

So using the list shown below

(setq AQSLLayerstr (list "ZERO" "AQSL-CLEARANCE" "AQSL-CLEARANCE-E" "AQSL-DETAIL" "AQSL-DOORS-DRAWERS" "AQSL-HIDDEN" "AQSL-HIDDEN-E"))

 I will try to see if I understand what is going. Let me know if I make any mistakes.

 

I think I am messing up as far as what I am putting into the different functions from the names on the AQSLLayerstr list.

 

(setq AQSLLayerstr (list "ZERO" "AQSL-CLEARANCE" "AQSL-CLEARANCE-E" "AQSL-DETAIL" "AQSL-DOORS-DRAWERS" "AQSL-HIDDEN" "AQSL-HIDDEN-E"))
(foreach x AQSLLayerstr ;;Here x is a string
  (foreach y (eval (read x)) ;;Here y is each dotted pair and x is the dotted pair list
    (setq lyrlist (ssget "X" y)) ;;should not need anything just the variable y it's already dotted pair
  )
  (if lyrlist
    (progn
      (if (= x "ZERO") (setq thislayer "0") (setq thislayer x));;Here back to using x as a string
      (command "_.chprop" lyrlist "" "_layer" thislayer "_color" "_bylayer" "_ltype" "_bylayer" "")
    )
  )
)

 But I run this in the VLIDE and it runs, but this is the error I get at the AutoCAD command line

 

'VLIDE (8 . 200)(8 . 202)(8 . 200-2D-ONLY)(8 . 258PC-LEGS)(8 . 232)(8 . 250)(8 . 252)(8 . 254)(8 . 0)(8 . 800)(8 . 801)(8 . 802)(8 . DEFPOINTS)(8 . 206)(8 . AQSL-Clearance)(8 . 256)(8 . AQSL-Clearance-E)(8 . 204)(8 . 205)(8 . 299)(8 . 204-2D-ONLY)(8 . 204-KCL-SHSIZE)(8 . AQSL-Detail)(8 . 206-KCL-DS)(8 . 206-KCL-DO)(8 . AQSL-Doors-Drawers)(8 . 201-2D-ONLY)(8 . 201)(8 . AQSL-Hidden)(8 . 251)(8 . AQSL-Hidden-E)(8 . 200)(8 . 202)(8 . 200-2D-ONLY)(8 . 258PC-LEGS)(8 . 232)(8 . 250)(8 . 252)(8 . 254)(8 . 0)(8 . 800)(8 . 801)(8 . 802)(8 . DEFPOINTS)(8 . 206)(8 . AQSL-Clearance)(8 . 256)(8 . AQSL-Clearance-E)(8 . 204)(8 . 205)(8 . 299)(8 . 204-2D-ONLY)(8 . 204-KCL-SHSIZE)(8 . AQSL-Detail)(8 . 206-KCL-DS)(8 . 206-KCL-DO)(8 . AQSL-Doors-Drawers)(8 . 201-2D-ONLY)(8 . 201)(8 . AQSL-Hidden)(8 . 251)(8 . AQSL-Hidden-E)bad list: "200"bad point argument

 Does this mean it is trying to read this all in at once?

 

 

Message 20 of 22
adjg13
in reply to: adjg13

Wow thank you Kent. I got it working. It still needs a few tweaks, but overall the program does what I want it to do.

 

(defun c:oneblk ()
	(command "undo" "m")
	(setq oldsnap (getvar "osmode"))
	(setq oldblips (getvar "blipmode"))
	
	(setvar "osmode" 0)
	(setvar "blipmode" 0)
	
	(setvar "qaflags" 1)
	(command "explode" "all" "")
	(setvar "qaflags" 0)
	
;;;;;;;;open files and read layers to layer filter lists;;;;;;;;
(setq layerslist (list "ZERO" "AQSL-CLEARANCE" "AQSL-CLEARANCE-E" "AQSL-DETAIL" "AQSL-DOORS-DRAWERS" "AQSL-HIDDEN" "AQSL-HIDDEN-E" "DELETE")) ;names of files and lists
(setq count 0)
(foreach x layerslist
  (if x (set (read x) nil))
)
(foreach thislayer layerslist ;here thislayer is the filename and the name of the list that holds the file contents
  (setq f (open (strcat "C:\\filterlists\\" thislayer ".txt") "r"))
  (while (setq text (read-line f))
    (set (read thislayer)
      (cond
        (
	      (= 0 count)
	      (cons (cons 8 text) (eval (read thislayer)))
		)
		(
		  (append (eval (read thislayer)) (list (cons 8 text)))
		)
	  );cond
	);set
    (setq count (+ count 1))
  );while
  (close f)
 );foreach
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(command "insert" "layers=C:\\important stuff\\layersblock.dwg" "0,0" "1" "1" "0" "")
(entdel (entlast))
;;;;;;;;;;;;;;;;;;;;;;Check for unlisted layers and write to file
(setq layerspresent (vla-get-layers (vla-get-activedocument (vlax-get-acad-object))))
(setq i 0)
(repeat (vla-get-count layerspresent)
  (setq thislayer (vla-get-name (vla-item layerspresent i))) ;thislayer is a string it's the layer names from inside the files
  (setq templist (cons 8 thislayer))
  (if ; not in any of the layer lists?
    (= ;'testexpr'
      (length
        (vl-remove
          nil ; remove any nil results from list returned by (mapcar)
          (mapcar ; apply member check of layer name across all lists, return list of results
            '(lambda (x) (member templist x)); applied to all in following list
            (list ZERO AQSL-CLEARANCE AQSL-CLEARANCE-E AQSL-DETAIL AQSL-DOORS-DRAWERS AQSL-HIDDEN AQSL-HIDDEN-E DELETE)
          ); mapcar
        ); vl-remove
      ); length
      0 ; all nils removed from list of results, so it's empty [returned nil for all lists]
    ); =
    (progn ; 'thenexpr'
      (initget "Zero aqsl-CLEarance aqsl-CLeArance-e aqsl-DETail aqsl-DOOrs-drawers aqsl-HIDden aqsl-HIdden-E DELete")
      (setq
        userchoice
          (getkword
            (strcat
              "\nChange "
              thislayer
              " to which AQSL layer/delete layer? [Zero aqsl-CLEarance aqsl-CLeArance-e aqsl-DETail aqsl-DOOrs-drawers aqsl-HIDden aqsl-HIdden-E DELete]"
            ); strcat
          ); getkword & 'userchoice'
        listname (strcase userchoice)
          ; makes list name, also beginning of file name, from 'userchoice' with
          ; hyphen(s) and "and" removed, forced to all lower-case, as text string
        f (open (strcat "C:\\filterlists\\" listname ".txt") "a")
      ); setq
      (write-line thislayer f)
      (close f)
      (set (read listname) (cons templist (eval (read listname)))); put layer name in local list
    ); progn -- 'thenexpr'
  ); if [no 'elseexpr' -- do nothing if it is already in one of the lists]
  (setq i (1+ i))
); repeat
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(setq AQSLLayerstr (list "ZERO" "AQSL-CLEARANCE" "AQSL-CLEARANCE-E" "AQSL-DETAIL" "AQSL-DOORS-DRAWERS" "AQSL-HIDDEN" "AQSL-HIDDEN-E"))
(foreach x AQSLLayerstr
  (foreach y (eval (read x))
    (setq lyrlist (ssget "X" (list y)))
    (if lyrlist
      (command "_.chprop" lyrlist "" "_layer" (if (= x "ZERO") "0" x) "_color" "_bylayer" "_ltype" "_bylayer" "")
    )
  )
)

(foreach x DELETE
  (setq lyrlist (ssget "X" (list x)))
)
  
(setq pntlist (ssget "X" '((0 . "point"))))
(if lyrlist (command "erase" lyrlist ""))

	(princ)
	
	(command "-layer" "s" "0" "")
	(command "-insert" "AQSL-ITMNO" "6,6" "1" "1" "0" "explode" "last")
	(command "-overkill" "all" "" "")
	(c:pm)
	(setvar "osmode" oldsnap)
	(setvar "blipmode" oldblips)
)

 This is the program in its entirety. I'm really sick of looking it, I might have to just leave it alone for now. My next step actually is to program the same thing in C# .NET. Ultimately I want to incorporate this into a larger plugin, but I am a total beginner with C# and .NET so I just wanted to make something that would be semi functional for now.

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

Post to forums  

Autodesk Design & Make Report

”Boost