Display full version of the post: Script writing advice needed

tieniemaree
22.09.2015, 17:23
Hi all,As our company is moving over from CADDIE to AUTOCAD LT 2016, I would like to write a script that will reload the linetype file I have created in order for the plotted drawings to still appear the same, whether these existing drawings are plotted using CADDIE or AUTOCAD LT.The second part or script should then select all linetypes PDASH2SPACE and set it to a new custom linetype I have created.Lastly, a script to set all the linetype scales to 1.If ALL of the above can be done in 1 script so much the better.[I understand a Macro would have worked so much better but unfortunately AUTOCAD LT won't run Macro's, only scripts]I have tried to write a textbook/manual for our users to guide them through this process step by step, but it is an arduous exercise that many find above their level of ability. Hence, writing a script will do these steps for them, or at least that is what I am hoping.CAN ANYONE PLEASE ASSIST???

John Connor
22.09.2015, 18:46
AutoCAD LT does indeed utilize macros.  Anyone who tells you otherwise probably doesn't use the program to begin with or is an idiot.
John Connor2015-09-22 18:49:43

John Connor
22.09.2015, 18:49
An example taken directly from the AutoDesk Knowledge Base.
To load a specific linetype without using a dialog box, use the following syntax in your macro:
^C^C_filedia;0;_-linetype;L;<linetype name>;"<path>/<lin file>";;filedia;1;
For example:
^C^C_filedia;0;_-linetype;L;ACAD_ISO02W100;"C:/Documents
and Settings/<user name>/Application Data/Autodesk/AutoCAD
2009/R17.2/enu/Support/acadiso.lin";;filedia;1; Note: You should use forward slashes in the path.

John Connor
22.09.2015, 18:54
A simple linetype scale macro might be ^C^CPLTSCALE;

tieniemaree
23.09.2015, 13:06
[QUOTE=John Connor]AutoCAD LT does indeed utilize macros.  Anyone who tells you otherwise probably doesn't use the program to begin with or is an idiot.
[/QUOTE]HAHA,that was the answer I got from the local CAD training centre in Cape Town! haha... however, they have since replied to my email and said they are investigating as there appears to be a couple of options.

tieniemaree
23.09.2015, 13:09
@Johnthanks for your input. I am trying to teach myself about scripting and macros so progress is slow, however your input is much appreciated!stupid question: if I wrote a macro, can other users on their pc's also run it? can i send them the file and just instruct them to run the script? [i know it's probably is stupid question, like i said, im a novice at this stage...]

John Connor
23.09.2015, 16:22
Macros and scripts are not the same thing and you should not be mixing the terminology.Yes, your macro or script should run.  There will always be that one "gotcha" exception though and since it is random you can't plan for it.

tieniemaree
23.09.2015, 16:26
[QUOTE=John Connor]Macros and scripts are not the same thing and you should not be mixing the terminology.Yes, your macro or script should run.  There will always be that one "gotcha" exception though and since it is random you can't plan for it.[/QUOTE]ok thanks, and sorry for mixing the terminology!i am making relatively good progress. this morning I was useless, I have since written a script to thaw, switch on, unlock all layers and to load the selected linetypes.now I need to set all the entities to linescale 1 (those that arent) and the only way seems to be by means of using the Quickselect function, which means a script cannot be written for it as its a dialogue box - am i correct in saying this? now what???

John Connor
23.09.2015, 16:38
You must be aware that there are command line versions of commands that open some dialog windows aren't you?For example: LAYER will bring up the Layer Properties Manager while -LAYER will show the options on the command line.

tieniemaree
23.09.2015, 16:39
[QUOTE=John Connor]You must be aware that there are command line versions of commands that open some dialog windows aren't you?For example: LAYER will bring up the Layer Properties Manager while -LAYER will show the options on the command line.
[/QUOTE]yes I am aware of that

John Connor
23.09.2015, 17:14
Set linetype scale globally.  Any entity that is already set to that won't be affected.Change > All > Properties > ltScale. 
John Connor2015-09-23 17:29:27

tieniemaree
23.09.2015, 17:32
thanks John, but...if i have entities in my drawing that was to a LTSCALE of 5 (for whatever reason), I need to set that entity to LTSCALE 1 so that all entities will plot the same from the various paperspace layouts.does that make sense?sorry, im struggling with this one!

tieniemaree
24.09.2015, 17:07
No worries, finally got it sorted out yay!!!

John Connor
24.09.2015, 19:12
And what, if I might ask, was the solution you arrived at?

tieniemaree
24.09.2015, 20:32
Select all, chprop, ltscale and then set value to 1, which was the last piece of my puzzle. Now with a single click our new autocad users can import the new line definitions, set the linetype scale to 1 in mspace and pspace. Set the global scale and set the use paperspace units function. Im busy adding a few bits and pieces but all in all im happy with this simple script file that will make life easier for our new users. Im posting from my phone so i cant post the entire script right now, but if anyone is interested i will do so when im back at my desktop pc on monday.Super stoked! Simple script i suppose but if i think that our local CAD dealers couldnt even answer me by now, i guess its not so simple after all!

tieniemaree
28.09.2015, 14:04
@johnhow do you deal with yes/no variables in scripts?

John Connor
28.09.2015, 15:18
Wouldn't you use the SETVAR command, variable name then either a 0 or 1?

tieniemaree
29.09.2015, 14:54
HERE IT IS!!!!MODEL-PURGEAN-LAYERUNLOCK*_FILEDIA0EXPERT3-LINETYPELPDASH2SPACE,PDASHED,PDASHED2,PDASHEDX2,PCENTRE,PCENTRE2,PPHANTOM,PPHANTOM2"C:/MK AUTOCAD FILES/acadlt.lin"EXPERT0_FILEDIA1_AI_SELALLCHPROPS1PSLTSCALE1MSLTSCALE1LTSCALE1CELTSCALE1CANNOSCALE1:100ZOOMEXTENTSREGENSAVE

tieniemaree
29.09.2015, 14:55
must be said, local CAD guys did eventually provide the last piece of the puzzle.

John Connor
29.09.2015, 16:12
Your Purge > All is not thorough enough, you don't run Overkill and you don't run Audit.  Why?  You obviously want to do some clean up of your drawing but all you are doing is shaking out the rugs without dusting, mopping and vacuuming.

tieniemaree
29.09.2015, 16:21
MODELAUDITY-PURGEANN-LAYERUNLOCK*_FILEDIA0EXPERT3-LINETYPELPDASH2SPACE,PDASHED,PDASHED2,PDASHEDX2,PCENTRE,PCENTRE2,PPHANTOM,PPHANTOM2"C:/MK AUTOCAD FILES/acadlt.lin"EXPERT0_FILEDIA1_AI_SELALLCHPROPS1PSLTSCALE1MSLTSCALE1LTSCALE1CELTSCALE1CANNOSCALE1:100ZOOMEXTENTSREGENSAVEAND NOW?

John Connor
29.09.2015, 16:24
Still needs work.First you run Overkill to get rid of any duplicate or overlapping lines.Second you do a -Purge (note the dash?) of Regapps.Third you do -Purge > All.Fourth, and finally, you do an Audit.Why the Regen at the end?  What is that supposed to accomplish?

tieniemaree
29.09.2015, 16:30
@Johnthanks for your feedback. Overkill is not needed as we oftentimes deliberately have multiple lines on different layers on top of each other, and Overkill will get rid of these IMO.I did punt a dash in so I don't know what you are implying.Purge could possibly have to run in some drawings yes, but not always. I am happy to run it once.the REGEN is possibly also redundant yes.all in all the script works fine for what I wanted to achieve. what would you change then if I may ask? and why?

John Connor
29.09.2015, 16:49
I'll concede the point re Overkill.If I missed the dash I apologize.  Regapps are Registered Applications.  Like anything else that is not being referenced (ex. - blocks) when one purges a drawing you want to clean those out.

tieniemaree
29.09.2015, 16:59
ah ok, thanks mate.