End the "-LAYER" command in a Lisp routine or Scrip

End the "-LAYER" command in a Lisp routine or Scrip

jcds.ltd
Contributor Contributor
2,230 Views
17 Replies
Message 1 of 18

End the "-LAYER" command in a Lisp routine or Scrip

jcds.ltd
Contributor
Contributor

Hi all,

I'm trying to automate cleaning up a load of drawings, so I was intending to use Lee Mac's Script Writer to automate the process, as I already have a script file that does the job.

However, I can't remember how to include a CR character to terminate the -LAYER command.  I'm pretty sure that I've managed to do this previously, but the method I adopted is lost in the mists of time.

 

I've attached the original script file, and you will see that I've got a blank line below the -LAYER command.  That's where my problem lies.  Converting the SCRIPT file into a Lisp version is straightforward, but however I do it, LISP or SCRIPT I still need to terminate the -LAYER command

 

Any help would be appreciated ... TIA

(LOAD "K:\Autocad Support/LISP/DeleteAllAnnotationScales_V1.LSP")
PURGESCALES
WHIPTHREAD 3
FILETABPREVIEW 0
FILETABTHUMBHOVER 0
VTENABLE 0
WIPEOUTFRAME 2
UCSFOLLOW 0
EDGEMODE 0
PROXYSHOW 1
PROXYGRAPHICS 1
PROXYNOTICE 0
GEOMARKERVISIBILITY 0
ANNOAUTOSCALE 0
AUPREC 3
HPLAYER .
-layer s 0

CECOLOR BYLAYER
CELTSCALE 1
CELTYPE BYLAYER
CELWEIGHT -1
CETRANSPARENCY ByLayer
audit y
-purge a * n
-purge r * n
ZOOM E
qsave

 

0 Likes
Accepted solutions (1)
2,231 Views
17 Replies
Replies (17)
Message 2 of 18

cadffm
Consultant
Consultant
Accepted solution

In Autocad scripts a line-break is an Enter

 

In lisp command it is an empty string = ""

 

Sebastian

Message 3 of 18

Shneuph
Collaborator
Collaborator

I copied and pasted what you wrote directly into my commandline and it worked fine and went on to the CECOLOR command...  There are no error messages or what is in your commandline when this is happening?

 

My method would be to, as you did, use hard returns until the layer command had ended.

 

-layer s 0

CECOLOR BYLAYER
---sig---------------------------------------
'(83 104 110 101 117 112 104 64 71 109 97 105 108 46 99 111 109)
0 Likes
Message 4 of 18

cadffm
Consultant
Consultant

Or better, all  "whatever" is send by an enter

 

-LAYER<enter>

Co<enter>

1<enter>

Mylayer<enter>

<enter>

 

(command "-Layer" "co" "1" "mylayer" "")

 

But Note: You can set a layer current, only if the layer is not freezed.

You should update your script/lisp!

First THAW the layer, then SET

Sebastian

Message 5 of 18

jcds.ltd
Contributor
Contributor

The problem is to generate the result you have seen, but doing it from within a SCRIPT or LISP routine.

 

Fortunately @cadffm has reminded me just how bad my memory can be ... 🙂

0 Likes
Message 6 of 18

cadffm
Consultant
Consultant

Your copy&paste test

You have a linebreak after your zero(following a useless blank you should remove from the script)

 

And the next (empty) line have also a line break.

So you have ...0<linebreak><linebreak>

Start -LAYER command by hand and follow the workflow..

Write down ALL keystroks and you will see how it works

Sebastian

0 Likes
Message 7 of 18

jcds.ltd
Contributor
Contributor

Well @cadffm you've reminded me just how shockingly bad my memory can be ... 🙄

For whatever reason, I was convinced that including a space within the quotes was the way to go, but then I was left wondering why things weren't working.

 

Many thanks for the prompt, accurate and succinct reply ... 👍

0 Likes
Message 8 of 18

jcds.ltd
Contributor
Contributor

@cadffm good call on ensuring that layer 0 is visible, unlocked, etc ... 👍

0 Likes
Message 9 of 18

ВeekeeCZ
Consultant
Consultant

CLAYER 0

 

Seems more suitable to me for your script than dealing with -layer.

Message 10 of 18

jcds.ltd
Contributor
Contributor

@ВeekeeCZ I'm not sure I've ever used CLAYER, but I don't feel like I'm missing out on anything ... 😉

However, to be serious for a moment, thanks for the suggestion ... 👍

After being prompted by @cadffm, I've just done a trial run with layer 0 being off, frozen and locked and CLAYER just spat out an error message.  That suggests to me that LAYER is the better command to be using in this particular situation.

0 Likes
Message 11 of 18

cadffm
Consultant
Consultant

@jcds.ltd wrote:

Z9E3zK5E I'm not sure I've ever used CLAYER, but I don't feel like I'm missing out on anything ... 
Change the current layer, how you do it the usual way by hand (hopeful you using the Ribbon, QAT ot Toolbar),

Press the UP-Arrow button or use the Contextmenu -> Recent Input

All that GUI ways using CLAYER

After being prompted by @cadffm, I've just done a trial run with layer 0 being off, frozen and locked and CLAYER just spat out an error message.

That suggests to me that LAYER is the better command to be using in this particular situation.

In this particular situation, yes. But if you knowing (for another particular situation)  the layerproperties are as expected, setvar CLAYER is better than command Layer (in theory, i would use clayer too)

 


 

 

 

Sebastian

0 Likes
Message 12 of 18

jcds.ltd
Contributor
Contributor

Yes, I take your point, but perhaps I should should elaborate on my experience and current situation.

 

My first taste of Autocad was with R10, which was followed by R10-386, and a couple of years after that i started working as a contract draughtsman, and for the most part I have continued in that role ever since. 

 

So, I've seen some ... unusual practices, or things that are at odds with what any experienced AutoCAD draughter might be expected to encounter.

 

Then, in this particular situation, I've been contracted to prepare some "As Built" drawings, whilst working remotely, on a project I had no prior knowledge of, and a project team that I've never met.  Yes, I'll accept that the situation is slightly unusual, but we seem to be living in unusual times ... 😀

 

Therefore, I try to avoid making assumptions as to what I might expect to find when I open a drawing, no matter how rigorous the clients, or project, draughting standards may be.  Trust me, there have been some shocking examples of how not to structure a set of drawings ... 😁

 

So, to address your point about CLAYER having a time and a place, yes of course I accept that.  The more tools you have available in your toolbox, the better, but over the years my "muscle memory" has me typing "-la s 0" rather than remembering the typical keyboard shortcut for CLAYER, or even worse, what a client has customised the keyboard shortcuts to be.

 

Again, thanks ... 👍

0 Likes
Message 13 of 18

Kent1Cooper
Consultant
Consultant

@jcds.ltd wrote:

... I've just done a trial run with layer 0 being off, frozen and locked and CLAYER just spat out an error message.  That suggests to me that LAYER is the better command to be using in this particular situation.


A point of curiosity, that further suggests a Layer command in preference to using the CLAYER System Variable in this situation:

 

If you do it using a Layer command, here to Layer 0 in a macro with the Thaw and Set options:

  -LAYER T 0 S 0

[or to be universally applicable:]

  _.-LAYER _T 0 _S 0

 

then the Layer will also be turned on  if it happens to be off -- there is no need to also include the On option.

 

By contrast, doing it by setting the CLAYER System Variable, whether by using CLAYER like a command or with an AutoLisp (setvar) function, will not  turn it on if it's off.  [Yes, the current Layer can be turned Off, which can be very confusing when you go to draw something.]

Kent Cooper, AIA
Message 14 of 18

jcds.ltd
Contributor
Contributor

Well @Kent1Cooper, I'm definitely learning more that I expected with this question, thanks ... 😊

 

As I mentioned above, I have been using AutoCAD for quite a number of years, but I will freely admit that I am something of a dinosaur when it comes to exploring new features as they are released, unless that exploration is to find out how to disable new features that are ... frustrating.  The VTENABLE variable springs immediately to mind, as the effect makes me feel quite queasy, and I'm not prone to motion sickness.

However, back on topic, I will try to remember that Setting a LAyer will turn it on, though I rarely use the layer off option, unless I am using layer isolation.

Out of interest, can you point me at a learning resource for the "universally applicable", as I'm not familiar with it.  Obviously, I'm familiar with using command line versions of commands, but I wasn't aware that there was a need for "universally applicable" commands.

 

Many thanks ... 👍

John

0 Likes
Message 15 of 18

cadffm
Consultant
Consultant

International Command and Command Options are easy for english version users, because

they are the same as the english, but with an underline in front of

LINE

_LINE

off

_off

end

_end

 

The DOT is for "native command version", because commands can be un- or redefine by programming.

With the dot you make sure the standard Autodesk command will run´.

 

These commands will work in all(?) language versions.

 

Sebastian

Message 16 of 18

Kent1Cooper
Consultant
Consultant

@jcds.ltd wrote:

.... can you point me at a learning resource for the "universally applicable", as I'm not familiar with it.  ....


>Here< is an entry in the AutoLisp Reference that explains both the _ and the . prefix characters.

 

As for the hyphen, that is to make it use the command-line version instead of the dialog-box version of those commands that have a dialog box [including LAYER].  BUT while you should include it in a command macro or Script, it's not  needed [though it does no harm] when inside an AutoLisp (command) function, where the command-line version is always used even without the hyphen.

Kent Cooper, AIA
Message 17 of 18

jcds.ltd
Contributor
Contributor

Thank you @cadffm, occasionally I do forget the additional challenges for those using English as a second language.

Additionally, I have worked for a client that uses a heavily modified AutoCAD interface, to the point where they have redefined a few commands, and until I was aware of what had happened.

Client customisations are a big reason for me using the command line in preference to the ribbon, so knowing there is a method of calling the native command, rather than a client's idea of what a command should be.

 

Again, thanks ... 👍

0 Likes
Message 18 of 18

jcds.ltd
Contributor
Contributor

@Kent1Cooper, thanks for the link, I'll check it out a little later.

 

As for the rest of your comments, they do seem to echo what @cadffm has said, thank you, but I see no point in duplicating what I said in my reply them ... 😊

 

Again, many thanks ... 👍

0 Likes