Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Annotative Drawing Scale LISP

5 REPLIES 5
Reply
Message 1 of 6
wsargent
3810 Views, 5 Replies

Annotative Drawing Scale LISP

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

__________

AutoCAD Civil 3D 2016 SP3.0, built on: AutoCAD 2016 SP1, Map 3D 2016 SP2
Dell Percision T5810: MS Windows 10 Pro; Intel Xeon CPU E5-1620 v3 @ 3.50 GHz, 16.00 GB RAM, NVIDIA K2200 4.00 GB Memory
5 REPLIES 5
Message 2 of 6
M_Hensley
in reply to: wsargent

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.

Message 3 of 6
wsargent
in reply to: M_Hensley

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...

__________

AutoCAD Civil 3D 2016 SP3.0, built on: AutoCAD 2016 SP1, Map 3D 2016 SP2
Dell Percision T5810: MS Windows 10 Pro; Intel Xeon CPU E5-1620 v3 @ 3.50 GHz, 16.00 GB RAM, NVIDIA K2200 4.00 GB Memory
Message 4 of 6
dgorsman
in reply to: wsargent

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.

----------------------------------
If you are going to fly by the seat of your pants, expect friction burns.
"I don't know" is the beginning of knowledge, not the end.


Message 5 of 6
Ian_Bryant
in reply to: wsargent

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

 

Message 6 of 6
3dwannab
in reply to: Ian_Bryant

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.

Post to forums  

Autodesk Design & Make Report

”Boost