Thread: How to import scalelist in 2008
|
Replies:
7
-
Last Post:
Jan 7, 2009 10:40 PM
Last Post By: scot-65
|
|
|
Posts:
288
Registered:
12/09/03
|
|
|
|
How to import scalelist in 2008
Posted:
Apr 27, 2007 2:01 AM
|
|
|
|
Hi,
How would I go about importing a scalelist for AutoCAD 2008?
In 2006, we ran a registry hack which populated each drawing. Now since the scalelist is saved in each file, I need a way to delete all scales in a dwg and import them from a pre-set file somehow.
Issue being that each block we bring into a dwg, along with xref's etc just keeps adding more scales (and incorrect ones) to the sheet.
Any help would be most appreciated.
Regards, Devon
|
|
|
|
Posts:
10
Registered:
05/30/07
|
|
|
|
Re: How to import scalelist in 2008
Posted:
May 31, 2007 9:37 AM
in response to: devon.middledit...
|
|
|
|
Hi Devon,
We've had the same problem overhere. I've used a bit of code posted on this forum and added some of our own stuff to it. This is what i've come up with sofar:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defun c:scales (/ olderr scalelist xr add2slzx add2slmx slmx slzx) (setq olderr *error*) ; (defun *error* (msg) ; (if (= msg "quit / exit abort") ; (princ) ; (princ (strcat "error: " msg)) ; ) ; (setq *error* olderr) ;error handler (setvar "cmdecho" 1) ; (princ) ; ) ;
(setvar "cmdecho" 0) (command "undo" "begin")
(scalelist_filter)
(command "undo" "end") (setvar "cmdecho" 1) (setq *error* olderr) (princ) ) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defun delete_scalelist (/) (create_scalelist) (while (/= scalelist nil) (command "-scalelistedit" "delete" (car scalelist) "exit") (setq scalelist (cdr scalelist)) ) (new_scalelist) ) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defun new_scalelist (/) (command "-scalelistedit" "add" "1:2" "1:2" "add" "1:5" "1:5" "add" "1:10" "1:10" "add" "1:20" "1:20" "add" "1:50" "1:50" "add" "1:100" "1:100" "add" "1:200" "1:200" "add" "1:500" "1:500" "add" "1:1000" "1:1000" "add" "1:2000" "1:2000" "add" "1:5000" "1:5000" "exit") ) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defun create_scalelist (/ ScaleListDict ScaleListEnts ScaleListNumber ScaleListUnits N DIGIT ACAD-KEY) (setq ScaleListDict (dictsearch (namedobjdict) "ACAD_SCALELIST") ScaleListEnts (MASSOC 350 ScaleListDict) ScaleList (list "") N 0 ) (repeat (length ScaleListEnts) (setq ScaleList (cons (cdr (assoc 300 (entget (nth N ScaleListEnts)))) ScaleList) N (+ N 1) ) ) (setq ScaleList (cdr (reverse ScaleList))) ) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defun MASSOC (KEY ALIST / X NLIST) (foreach X ALIST (if (eq KEY (car X)) (setq NLIST (cons (cdr X) NLIST)) ) ) (reverse NLIST) ) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defun scalelist_filter (/) (setvar "cmdecho" 0) (create_scalelist)
(while (/= scalelist nil) (if ( (strlen (car scalelist)) 4) (setq xr (substr (car scalelist) (- (strlen (car scalelist)) 4) 5)) ) (if (= xr "_XREF") (setq add2slmx (car scalelist)) )
(if (/= xr "_XREF") (setq add2slzx (car scalelist)) )
(if (/= add2slzx nil) (if (= (member add2slzx slzx) nil) (setq slzx (cons (car scalelist) slzx)) ) )
(if (/= add2slmx nil) (if (= (member add2slmx slmx) nil) (setq slmx (cons (car scalelist) slmx)) ) )
(setq xr nil add2slmx nil add2slzx nil) (setq scalelist (cdr scalelist)) )
(if (= (> (length slzx) 12) T) (delete_scalelist) ) );end ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
This routine does the following: It first creates a list of present scales. (This is the code i found on this forum) Then only the scales that are not in an xref are put into another list. If there are more then 12 scales present in the list then all the scales in the drawing are deleted and the custom ones are added. If there are 12 scales (this is our office standard) then nothing is done.
I've added this line to the acad2008doc.lsp (load "scalelist.lsp")(scalelist_filter) So each time a drawing is opened it checks if the custom scales are the only ones present. In the beginning most drawings will have the custom scales added. But ones this is done in a drawing nothing has to be done the next time the drawing is opened.
Please note the following: -This only works on V2008. -You can alter the custom scalelist, just be sure that if you do, you have to alter the number 12. The routine checks if there are 12 scales present in the current drawing. The command is only executed if there are more.
I hope this helps you (and others) a little bit. We've only just started using this, but sofar it seems to work fine.
Vincent
Message was edited by: vvandraanen
|
|
|
|
|
Posts:
288
Registered:
12/09/03
|
|
|
|
Re: How to import scalelist in 2008
Posted:
May 31, 2007 10:39 PM
in response to: v.van.draanen@o...
|
|
|
|
Vincent Thanks very much for your code. This is a fantastic starting point and is the best solution to come out of the forum on this issue.
1 question, With the list being set to 12 scales, I would now like to make it work for both MM and M untis.
So I would probably need 24 scales as there would be 12 for meters and 12 for Millimeters.
Do I simply change the (if (= (> (length slzx) 12) T) to 24 and then add in my Meters scales to the scale list code?
Thanks Devon
|
|
|
|
|
Posts:
10
Registered:
05/30/07
|
|
|
|
Re: How to import scalelist in 2008
Posted:
Jun 1, 2007 6:08 AM
in response to: devon.middledit...
|
|
|
|
Hi Devon,
I'm glad to be of help. I sometimes find the answers to my programming questions on this forum. This time i'm able to give something back.
You're right about changing the scale list and number.
You can add or remove as many scales you want to this part: (defun new_scalelist (/) (command "-scalelistedit" "add" "1:2" "1:2" "add" "1:5" "1:5" "add" "1:10" "1:10" "add" "1:20" "1:20" "add" "1:50" "1:50" "add" "1:100" "1:100" "add" "1:200" "1:200" "add" "1:500" "1:500" "add" "1:1000" "1:1000" "add" "1:2000" "1:2000" "add" "1:5000" "1:5000" "exit") )
Just be sure that the number in this line: (if (= (> (length slzx) 12) T) is set to the excact number of scales in the list above.
Vincent
|
|
|
|
|
Posts:
2
Registered:
01/07/09
|
|
|
|
Re: How to import scalelist in 2008
Posted:
Jan 7, 2009 6:27 PM
in response to: v.van.draanen@o...
|
|
|
|
Note: the first "while" statement in (scalelist_filter) has a typo. Needs an equals sign. Like this:
(while (/= scalelist nil) (if (= (strlen (car scalelist)) 4) (setq xr (substr (car scalelist) (- (strlen (car scalelist)) 4) 5)) )
Also: working with the scales list is a major pain when you don't know what scales are already defined, so I found it easier to start from scratch every single time, reset to the hard-coded defaults, and then customize as necessary. The thing I'm not sure how to handle is when opening an existing file and trying to clear back to the defaults. If a custom scale is already in use, AutoCAD won't let you delete it. Then when you run through the (command "-scalelistedit") and try to add the custom scales, everything gets messed up when it tries to "add" the scale that is already there. Does anyone have a way to handle this error?
The code I use is below, modified and simplified from wandraanen's because his version didn't work very well for me.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun c:scales (/ olderr scalelist xr add2slzx add2slmx slmx slzx) (setq olderr *error*) (defun *error* (msg) (if (= msg "quit / exit abort") (princ) (princ (strcat "error: " msg)) ) (setq *error* olderr) ;error handler (setvar "cmdecho" 1) (princ) )
(setvar "cmdecho" 0) (command "undo" "begin")
(scalelist_filter)
(command "undo" "end") (setq *error* olderr) (princ) )
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun delete_scalelist (/) (setvar "cmdecho" 0) (command "-scalelistedit" "reset" "yes" "exit" ) )
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun new_scalelist (/) (setvar "cmdecho" 0) (command "-scalelistedit" "delete" "1/64\" = 1'-0\"" "delete" "3/16\" = 1'-0\"" "delete" "3/8\" = 1'-0\"" "delete" "3/4\" = 1'-0\"" "delete" "1 1/2\" = 1'-0\"" "delete" "3\" = 1'-0\"" "delete" "6\" = 1'-0\"" "add" "1\" = 100'-0\"" "1:1200" "add" "1\" = 50'-0\"" "1:600" "add" "1\" = 20'-0\"" "1:240" "add" "1\" = 40'-0\"" "1:480" "exit" ) )
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun scalelist_filter (/) (delete_scalelist) (new_scalelist)
)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
|
Posts:
1,196
Registered:
12/11/03
|
|
|
|
Re: How to import scalelist in 2008
Posted:
Jan 7, 2009 10:40 PM
in response to: chris4d
|
|
|
|
Chris, I nabbed this code from this fourm for possible use in my environment. Not been able to try this out yet...
(defun Delete_Annotation_Scales ( / scale_dictionary_entity_info) (setq scale_dictionary_entity_info (entget (cdr (assoc -1 (dictsearch (namedobjdict) "ACAD_SCALELIST")))) ) (setq scale_dictionary_entity_info (append (reverse (member '(3 . "A0") (reverse scale_dictionary_entity_info))) (list (cadr (member '(3 . "A0") scale_dictionary_entity_info))) ) ) (entmod scale_dictionary_entity_info) (princ) )
Will this work for 2008? I do not know.
|
|
|
|
|
Posts:
5
Registered:
10/30/08
|
|
|
|
Re: How to import scalelist in 2008
Posted:
Nov 10, 2008 9:38 AM
in response to: devon.middledit...
|
|
|
|
Hi
Found this script interesting and tried to copy it to notepad naming it "something.scr" and loading/running it in AutoCAD, but i couldnt get it to work. Anyone got some tips on getting this script to work?
Thx in advance!:)
tAC
|
|
|
|
|
Posts:
2
Registered:
01/07/09
|
|
|
|
Re: How to import scalelist in 2008
Posted:
Jan 7, 2009 6:32 PM
in response to: The_Alpine_Cow
|
|
|
|
TAC, You need to give it .lsp filename and put it in the search path of your autocad installation. Call it scalelist.lsp for example. Also create a file named "acaddoc.lsp" in the same folder and enter these two lines in that file:
(load "scalelist") (scalelist_filter)
what this does, is everytime autocad opens a file it automatically runs the file named "acaddoc.lsp" (just something autocad does), and that file tells it to load the other lsp file and run a function from inside it.
|
|
|
|
|
|
|
|