Script for layers and purging

Script for layers and purging

Anonymous
Not applicable
6,053 Views
23 Replies
Message 1 of 24

Script for layers and purging

Anonymous
Not applicable

I'm trying to write a script that will do the following:

purge, then all, then close

 

-purge then registered apps, all, then "no"

 

setbylayer

all

Yes, Yes, Yes

 

change color to 253 on all those layers selected above, then i want to repeat purge steps again.

then audit

saveas to a directory folder

End

0 Likes
Accepted solutions (2)
6,054 Views
23 Replies
Replies (23)
Message 21 of 24

roland.r71
Collaborator
Collaborator

Note to self: Test thoroughly before posting...

 

As i noticed, setting filedia to 0, makes it ask for a version twice.

At the same time it kinda makes the use of the + obsolete, as all dialogs are off now.

 

So the correct(ed) code becomes:

(setvar "filedia" 0)
(command "_.saveas" "2013" (strcat "C:/path/to/" (getvar "dwgname")))
(setvar "filedia" 1)

 

I also added some code to use the current dwg name for saving. (as i'm sure you'll ask next) - and you'll need to add a correct path instead of the red one.

Message 22 of 24

Anonymous
Not applicable
Accepted solution

@roland.r71 

Was almost what I suggest here >>> Link <<<

(defun c:test nil
  
  (command "_.Purge" "_All" "*" "_No"
	   "_.Setbylayer" "_All" "" "_Yes" "_Yes"
	   "_.Layer" "_Color" 253 "*" ""
	   "_.Audit" "_Yes")
  
  (command "_.SAVEAS" "2013" (strcat "C:\\File Location\\" (getvar "dwgname")) "_Yes")
  (princ)
  )

But I would choose to use the SAVE

(command "_SAVE" (strcat "File Location" (getvar "dwgname")))

 

0 Likes
Message 23 of 24

roland.r71
Collaborator
Collaborator
Accepted solution

@Anonymous wrote:

Sorry, let me just summarize my last question so you don't have to read everything. Code is working, just need to know how to save as in the last line. I'm saving from one directory to the specific one below, I want to use the existing drawing number that I will currently be in at all times. There are many different codes to grab this, but I'm not sure how to tie it in. 

 

(defun c:test ()

(command "_.purge" "_all" "*" "_no"
"_.setbylayer" "_all" "" "_yes" "_yes"
"_.layer" "_color" "253" "*" ""
"_.audit" "_yes"
"_.saveas" "2013" "S:\ENGINEERING\JOBS\16-006 GM Ramos\DRAWINGS\GK\GK XREF\" "dwgname")


As you where close, i'll try to explain what exactly is wrong here:

 

"_.saveas" "2013" "S:\ENGINEERING\JOBS\16-006 GM Ramos\DRAWINGS\GK\GK XREF\" "dwgname"

 

There are 2 problems with this piece of code:

1: Each argument given to the command needs to be inside 1 string. Your path & "dwgname" are 2 arguments, not 1. This way only the path is used as filename and the "dwgname" would be to answer any next prompt, if there where any, otherwise it will be seen as a next command. You need to join them into 1 string.

 

2: Although typing variable names at the commandline works to get their value, this isn't true for lisp. You need to retrieve the value with the GETVAR command. (getvar "dwgname")

 

So, to suply a correct path use: (strcat "your path" (getvar "dwgname"))

This will join the 2 strings (path & dwgname) together into 1 string = 1 argument for filename.

 

0 Likes
Message 24 of 24

roland.r71
Collaborator
Collaborator

Yes it is. Not so strange as there aren't that many different options to do it.

...but as is, it doesn't work.

The most important thing to make it work is to turn the file dialog off, so you can suply a filename thru script (or lisp) instead.

 

Unless there is a reason it should saveas 2013, he might as well use save in this case, yes.