Visual LISP, AutoLISP and General Customization

Reply
Distinguished Contributor
wsargent
Posts: 147
Registered: ‎01-12-2007
Message 1 of 6 (982 Views)

Annotative Drawing Scale LISP

982 Views, 5 Replies
04-26-2012 09:18 AM

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 2012 (Primary), 2011 by contract.
Dell Percision T3500: MS Windows 7 64-bit SP1; Intel Xeon CPU W3505 @ 2.53GHz, 12.00 GB RAM, NVIDIA Quadro 600
*Expert Elite*
M_Hensley
Posts: 1,676
Registered: ‎12-11-2003
Message 2 of 6 (973 Views)

Re: Annotative Drawing Scale LISP

04-26-2012 12:23 PM 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.

Distinguished Contributor
wsargent
Posts: 147
Registered: ‎01-12-2007
Message 3 of 6 (972 Views)

Re: Annotative Drawing Scale LISP

04-26-2012 12:53 PM 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 2012 (Primary), 2011 by contract.
Dell Percision T3500: MS Windows 7 64-bit SP1; Intel Xeon CPU W3505 @ 2.53GHz, 12.00 GB RAM, NVIDIA Quadro 600
*Expert Elite*
dgorsman
Posts: 5,044
Registered: ‎10-12-2006
Message 4 of 6 (965 Views)

Re: Annotative Drawing Scale LISP

04-26-2012 02:50 PM 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.
Adopt. Adapt. Overcome. Or be overcome.
A good question will be halfway to a good answer.


Valued Mentor
Ian_Bryant
Posts: 362
Registered: ‎06-02-2005
Message 5 of 6 (946 Views)

Re: Annotative Drawing Scale LISP

04-27-2012 04:26 AM 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

 

Active Contributor
3dwannab
Posts: 26
Registered: ‎06-18-2012
Message 6 of 6 (605 Views)

LISP to Reset CANNOSCALE for METRIC use

04-17-2013 12:35 PM 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.

-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
OS: Windows 7 Ultimate x64 CPU: i7 CPU 965 @ 3.20GHz RAM: Crosair 12288 MBytes DDR3 GPU: ATI Radeon HD 4870 X2 MONITOR: 32" HP LP3065 LCD
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Freelance CAD and 3d Architectural Visual Artist: stephensherry147@yahoo.co.uk

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community