Need help with writing a script.

Need help with writing a script.

Anonymous
Not applicable
865 Views
4 Replies
Message 1 of 5

Need help with writing a script.

Anonymous
Not applicable

Hi all,

 

First of, I'm new and very grateful for this forum! Been a longtime lurker and these forums have helped me on so many different occasions! I have some spare-time at work on my hand so i am currently looking into the advantages of scripting.

My idea is to automate some of the steps we take when finishing and plotting drawings, but in all honesty I have no idea how these commands work, and the mere basics of writing a script seem a djungle to me. With that said, I would love to know if there is a thorough but basic and understandable compilation of these script-commands, what they do and how they are applied and written in a script. For every experiment I do, I seem to miss out on an asterisk or comma or line or at..

The basics of what I want to do for my company is as follows (when we´re done with the drawing):

  • Set to Worldview
  • Set to layer 0
  • Freeze selected layers on X-ref "A01" (example)
  • Set all layers on X-ref "A01" to gray
  • Delete/Remove all unused/unreferenced X-refs
  • Set all X-refs to Relative
  • Purge
  • Audit
  • Regen

Is there anyway I can turn to get me going on this quest?

Thank you for taking you time to read this. Very grateful for any advice.

/Ed from Sweden

0 Likes
866 Views
4 Replies
Replies (4)
Message 2 of 5

cadffm
Consultant
Consultant

Welcome,

and help yourself.

" I have no idea how these commands work,"
Type-In and check it out (and read online Help if needed)

"and the mere basics of writing a script seem a djungle to me."
But Why?

"compilation of these script-commands"
There are no "Script-commands", only normal AutoCAD-Commands.

1) Find the command you need
   (Start from Ribbon, Toolbar or in another kind, look into commandline and Textscreen[F2])

2) Type in the command and write down your keyboard-hits.
   Script: As Enter, make a linebreak (in a MenuMacro: As Enter use a Semicolon)

Note: AutoCAD use for commands from Script the commandlineversion of a command if available,
for testing you can use the commandlineversion too (it is a normal command).
LAYER vs -LAYER
XREF vs -XREF
...
but a commandline Version ist not available for all commands, for example: FILTER QSELECT are only Dialogmask-Commands


Start with a Script
    Set to Worldview

Extend the Script for
    Set to layer 0
    Freeze selected layers on X-ref "A01"
    Set all layers on X-ref "A01" to gray
    Purge
    Audit
    Regen


For example: Set to layer 0

You can set current Layer by command LAYER option set, note in Acad you can´t set a freezed Layer current.
So thaw the Layer0 and then setq Layer0 current (better: unlock,thaw, turn on ON and then set current)
Thats the reason why using systemvariable CLAYER work but isn't so well, for that you have to know that the wanted Layer isn´t freezed and on.
Use command -LAYER in commandline and look to Textscreen to [F2],
write all hits down:
-LAYER<enter=linebreak>

_thaw<enter=linebreak>
and so on, the finished script is (save as MyFileName.SCR without *.txt)
;=========
-LAYER
_thaw
0
_set
0

;=========

 


Start the Script and look to your Textscreen:
Command: SCRIPT

Command: -LAYER

Current layer:  "Model-Front"
Enter an option [?/Make/Set/New/Rename/ON/OFF/Color/Ltype/LWeight/TRansparency/MATerial/Plot/PStyle/Freeze/Thaw/LOck/Unlock/stAte/Description/rEconcile]: _thaw

Enter name list of layer(s) to thaw: 0
Enter an option [?/Make/Set/New/Rename/ON/OFF/Color/Ltype/LWeight/TRansparency/MATerial/Plot/PStyle/Freeze/Thaw/LOck/Unlock/stAte/Description/rEconcile]: _set

Enter layer name to make current or <select object>: 0
Enter an option [?/Make/Set/New/Rename/ON/OFF/Color/Ltype/LWeight/TRansparency/MATerial/Plot/PStyle/Freeze/Thaw/LOck/Unlock/stAte/Description/rEconcile]:

Command:




We will discuss this part later
    Delete/Remove all unused/unreferenced X-refs (DWG-XREFs? AutoCAD delete them themselfe, with Version are you using?)
    Set all X-refs to Relative (I think that will not work that way)

Sebastian

Message 3 of 5

Anonymous
Not applicable

Thank you very much! Will look into this. Very appreciated.

0 Likes
Message 4 of 5

Kent1Cooper
Consultant
Consultant

@Anonymous wrote:

.... i am currently looking into the advantages of scripting.

.... I would love to know if there is a thorough but basic and understandable compilation of these script-commands, what they do and how they are applied and written in a script. For every experiment I do, I seem to miss out on an asterisk or comma or line or at..

....


I have to ask....

 

I often see people misuse the word "script" to mean [or at least to include ] other ways of defining combined actions, such as AutoLisp routines or command macros.  "Script" may be a term used generically  in such ways in other contexts, but in AutoCAD, the word has a specific  meaning.  Are you, in fact, talking specifically about a SCRIPT by AutoCAD's definition of the word  [a file with .SCR filetype ending, called for with the SCRIPT command ], or would one of those other kinds of things be acceptable to do what you need?

Kent Cooper, AIA
0 Likes
Message 5 of 5

Anonymous
Not applicable
An excellent question! I would do with any type of solution/s (be it macros or any other) that help me achieve what I'm working towards. It does NOT need to be specifically a script.
0 Likes