Script writing advice needed
Printed From: CAD Forum
Category: EN
Forum Name: AutoCAD
Forum Description: Discussion about AutoCAD and AutoCAD LT, viewers, DWG and DWF formats, Design Review, AutoCAD 360, add-ons
URL: https://www.cadforum.cz/forum_en/forum_posts.asp?TID=11370
Printed Date: 25.Apr.2026 at 23:05
Topic: Script writing advice needed
Posted By: tieniemaree
Subject: Script writing advice needed
Date Posted: 22.Sep.2015 at 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???
|
Replies:
Posted By: John Connor
Date Posted: 22.Sep.2015 at 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.
------------- "Humans have a strength that cannot be measured. This is John Connor. If you are reading this, you are the resistance."
<<AutoCAD 2015>>
|
Posted By: John Connor
Date Posted: 22.Sep.2015 at 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.
------------- "Humans have a strength that cannot be measured. This is John Connor. If you are reading this, you are the resistance."
<<AutoCAD 2015>>
|
Posted By: John Connor
Date Posted: 22.Sep.2015 at 18:54
A simple linetype scale macro might be ^C^CPLTSCALE;
------------- "Humans have a strength that cannot be measured. This is John Connor. If you are reading this, you are the resistance."
<<AutoCAD 2015>>
|
Posted By: tieniemaree
Date Posted: 23.Sep.2015 at 13:06
John Connor wrote:
AutoCAD LT does indeed utilize macros. Anyone who tells you otherwise probably doesn't use the program to begin with or is an idiot.
|
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.
|
Posted By: tieniemaree
Date Posted: 23.Sep.2015 at 13:09
@John
thanks 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...]
|
Posted By: John Connor
Date Posted: 23.Sep.2015 at 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.
------------- "Humans have a strength that cannot be measured. This is John Connor. If you are reading this, you are the resistance."
<<AutoCAD 2015>>
|
Posted By: tieniemaree
Date Posted: 23.Sep.2015 at 16:26
John Connor wrote:
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.
|
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???
|
Posted By: John Connor
Date Posted: 23.Sep.2015 at 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.
------------- "Humans have a strength that cannot be measured. This is John Connor. If you are reading this, you are the resistance."
<<AutoCAD 2015>>
|
Posted By: tieniemaree
Date Posted: 23.Sep.2015 at 16:39
John Connor wrote:
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.
|
yes I am aware of that
|
Posted By: John Connor
Date Posted: 23.Sep.2015 at 17:14
Set linetype scale globally. Any entity that is already set to that won't be affected.
Change > All > Properties > ltScale.
------------- "Humans have a strength that cannot be measured. This is John Connor. If you are reading this, you are the resistance."
<<AutoCAD 2015>>
|
Posted By: tieniemaree
Date Posted: 23.Sep.2015 at 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!
|
Posted By: tieniemaree
Date Posted: 24.Sep.2015 at 17:07
|
No worries, finally got it sorted out yay!!!
|
Posted By: John Connor
Date Posted: 24.Sep.2015 at 19:12
And what, if I might ask, was the solution you arrived at?
------------- "Humans have a strength that cannot be measured. This is John Connor. If you are reading this, you are the resistance."
<<AutoCAD 2015>>
|
Posted By: tieniemaree
Date Posted: 24.Sep.2015 at 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!
|
Posted By: tieniemaree
Date Posted: 28.Sep.2015 at 14:04
@john
how do you deal with yes/no variables in scripts?
|
Posted By: John Connor
Date Posted: 28.Sep.2015 at 15:18
Wouldn't you use the SETVAR command, variable name then either a 0 or 1?
------------- "Humans have a strength that cannot be measured. This is John Connor. If you are reading this, you are the resistance."
<<AutoCAD 2015>>
|
Posted By: tieniemaree
Date Posted: 29.Sep.2015 at 14:54
HERE IT IS!!!!
MODEL
-PURGE A N
-LAYER UNLOCK *
_FILEDIA 0
EXPERT 3
-LINETYPE L PDASH2SPACE,PDASHED,PDASHED2,PDASHEDX2,PCENTRE,PCENTRE2,PPHANTOM,PPHANTOM2 "C:/MK AUTOCAD FILES/acadlt.lin"
EXPERT 0
_FILEDIA 1
_AI_SELALL CHPROP S 1
PSLTSCALE 1
MSLTSCALE 1
LTSCALE 1
CELTSCALE 1
CANNOSCALE 1:100
ZOOM EXTENTS REGEN SAVE
|
Posted By: tieniemaree
Date Posted: 29.Sep.2015 at 14:55
must be said, local CAD guys did eventually provide the last piece of the puzzle.
|
Posted By: John Connor
Date Posted: 29.Sep.2015 at 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.
------------- "Humans have a strength that cannot be measured. This is John Connor. If you are reading this, you are the resistance."
<<AutoCAD 2015>>
|
Posted By: tieniemaree
Date Posted: 29.Sep.2015 at 16:21
MODEL
AUDIT Y
-PURGE A N N
-LAYER UNLOCK *
_FILEDIA 0
EXPERT 3
-LINETYPE L PDASH2SPACE,PDASHED,PDASHED2,PDASHEDX2,PCENTRE,PCENTRE2,PPHANTOM,
PPHANTOM2 "C:/MK AUTOCAD FILES/acadlt.lin"
EXPERT 0
_FILEDIA 1
_AI_SELALL CHPROP S 1
PSLTSCALE 1
MSLTSCALE 1
LTSCALE 1
CELTSCALE 1
CANNOSCALE 1:100
ZOOM EXTENTS REGEN SAVE
AND NOW?
|
Posted By: John Connor
Date Posted: 29.Sep.2015 at 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?
------------- "Humans have a strength that cannot be measured. This is John Connor. If you are reading this, you are the resistance."
<<AutoCAD 2015>>
|
Posted By: tieniemaree
Date Posted: 29.Sep.2015 at 16:30
@John
thanks 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?
|
Posted By: John Connor
Date Posted: 29.Sep.2015 at 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.
------------- "Humans have a strength that cannot be measured. This is John Connor. If you are reading this, you are the resistance."
<<AutoCAD 2015>>
|
Posted By: tieniemaree
Date Posted: 29.Sep.2015 at 16:59
|