I am attempting to create an AutoLISP that removes all un-used drawing scales from a file, then adds the standard scales used in civil engineering. This is what I tried using:
;;;Add Engineering Scales
(defun C:AES ()
(command ".CANNOSCALE"
"1" = 1'"
(command "-scalelistedit"
"delete" "*"
"add" "1" = 10" "1:10"
"add" "1" = 20" "1:20"
"add" "1" = 30" "1:30"
"add" "1" = 40" "1:40"
"add" "1" = 50" "1:50"
"add" "1" = 60" "1:60"
"add" "1" = 100" "1:100"
"add" "1" = 200" "1:200"
"add" "1" = 300" "1:300"
"add" "1" = 400" "1:400"
"add" "1" = 500" "1:500"
"add" "1" = 600" "1:600"
"add" "1" = 1000" "1:1000"
"add" "1" = 2000" "1:2000"
"add" "1" = 3000" "1:3000"
"add" "1" = 4000" "1:4000"
"add" "1" = 5000" "1:5000"
"Exit")
(princ)
)
Now, I am only a beginner to writing LISP, but I know that my problem is that it is reading the inch marks after the one in the scale name as a enter, but I don't know how to get around this. Also, I don't know how to get it to skip scales that are still in the drawing.
Any help would be great!
Thanks,
Walter
In lisp the inch marks are used to define text inputs. When you want inch marks as part of your text you need to put a backslash in front of them.
That made it so that it works as long as none of the scales that it is adding are in the file because of an annotative object or annotative viewport scale. Thanks.
I now need to get it to recognize what scales are used in the drawing and skip them...
The backslash character is used to "escape" other characters which have special formatting purposes e.g. "\t" for tab, "\\" for backslash, and so on.
For scale list manipulation, have a search for ScaleListDel.lsp by Steve Johnson. It contains a number of functions for working with annotation scale entries.
Hi,
setting the system variable EXPERT to 5 suppresses the
Do you want to overwrite? prompts, so you could try the following,
although I had to change the line (command "CANNOSCALE" "1\" = 1'")
to (command "CANNOSCALE" "1:1") to get it to work in my Autocad.
(defun C:ENGS ( / xpt)
(command "-scalelistedit"
"reset"
"yes"
"exit")
(command "CANNOSCALE" "1\" = 1'")
(setq xpt (getvar "EXPERT"))
(setvar "EXPERT" 5)
(command "-scalelistedit"
"delete" "*"
"add" "1\" = 10'" "1:10"
"add" "1\" = 20'" "1:20"
"add" "1\" = 30'" "1:30"
"add" "1\" = 40'" "1:40"
"add" "1\" = 50'" "1:50"
"add" "1\" = 60'" "1:60"
"add" "1\" = 100'" "1:100"
"add" "1\" = 200'" "1:200"
"add" "1\" = 300'" "1:300"
"add" "1\" = 400'" "1:400"
"add" "1\" = 500'" "1:500"
"add" "1\" = 600'" "1:600"
"add" "1\" = 1000'" "1:1000"
"add" "1\" = 2000'" "1:2000"
"Exit")
(setvar "EXPERT" xpt)
(princ)
)
Regards Ian
I done a little modification to your code for metric scales but thanks for doing that code to get me started. Only a week in using LISPS and somehow managed to make this work. I added an extra line or two. First one sets the CANNOSCALE to 1:1 Metric meaning it will reset it. And the rest adds all the relevant scales our office uses. It then sets the scale to 1:100 as thats the most used scale in our office.
I added the line (C:Reset_Cannoscale_List_Metric) at the end so it runs straight away when loading it through APPLOAD or putting
(LOAD "Reset_Cannoscale_List_Metric")
in your acaddoc.lsp file so it runs automatically when you open the dwg. I hope this is of use to someone.
Can't find what you're looking for? Ask the community or share your knowledge.