Author Topic: Purge excess scales  (Read 17498 times)

0 Members and 1 Guest are viewing this topic.

GDF

  • Water Moccasin
  • Posts: 2079
Purge excess scales
« on: July 28, 2009, 11:13:02 AM »
Ok, I"ve just switched from version 2006 to 2010. I'm looking for a routine to automatically purge excess scales.

I keep getting this message in my drawings when opened:
It is recommended you open and resave the Xref file to remove excess scales.

Can anyone point me in the right direction?
Why is there never enough time to do it right, but always enough time to do it over?
BricsCAD 2020x64 Windows 10x64

Matt__W

  • Seagull
  • Posts: 12955
  • I like my water diluted.
Re: Purge excess scales
« Reply #1 on: July 28, 2009, 11:14:13 AM »
I would try opening and resaving the xref file to remove excess scales.
Autodesk Expert Elite
Revit Subject Matter Expert (SME)
Owner/FAA sUAS Pilot @ http://skyviz.io

GDF

  • Water Moccasin
  • Posts: 2079
Re: Purge excess scales
« Reply #2 on: July 28, 2009, 11:15:30 AM »
I would try opening and resaving the xref file to remove excess scales.

Thanks Matt

Is there a way to automatically keep this from happening?
Why is there never enough time to do it right, but always enough time to do it over?
BricsCAD 2020x64 Windows 10x64

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Purge excess scales
« Reply #3 on: July 28, 2009, 11:18:49 AM »
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

Krushert

  • Seagull
  • Posts: 13679
  • FREE BEER Tomorrow!!
Re: Purge excess scales
« Reply #4 on: July 28, 2009, 11:18:57 AM »
Do a search for scalelist

here is what I do.

http://www.theswamp.org/index.php?topic=23501.msg302279#msg302279

*Edit*
Tim beat me to it
I + XI = X is true ...  ... if you change your perspective.

I no longer CAD or Model, I just hang out here picking up the empties beer cans

GDF

  • Water Moccasin
  • Posts: 2079
Re: Purge excess scales
« Reply #5 on: July 28, 2009, 11:32:22 AM »
Thanks

Sorry, I should have done a search first...
Why is there never enough time to do it right, but always enough time to do it over?
BricsCAD 2020x64 Windows 10x64

Crank

  • Water Moccasin
  • Posts: 1503
Vault Professional 2023     +     AEC Collection

VVA

  • Newt
  • Posts: 166
Re: Purge excess scales
« Reply #7 on: July 29, 2009, 07:05:09 AM »
My five cents
Code: [Select]
(defun SetScale (/ lst pat tmp)
;;; Pat - the pattern scale is made up of lists of species
;;; (("Name of the Scale 1" Scale_paper_unit_1 Scale_drawing_unit_1)
;;; ("Name of the Scale 2"  Scale_paper_unit_2 Scale_drawing_unit_2)
;;; ...
;;;)
;;; Usage: (SetScale)
  (setq pat '(("1:1" 1 1)  ;_Correct scale here
              ("1:2" 1 2)
              ("1:10" 1 10)
              ("1:50" 1 50)
              ("1:100" 1 100)
              ("2:1" 2 1)
             )
  ) ;_ end of setq
  (setq tmp (mapcar 'car pat))
  (if (dictsearch (namedobjdict) "ACAD_SCALELIST")
    (progn
      (foreach item (dictsearch (namedobjdict) "ACAD_SCALELIST")
        (if
          (and (= 350 (car item))
               (not (member (cdr (assoc 300 (entget (cdr item)))) tmp))
          ) ;_ end of and
           (vl-catch-all-apply 'entdel (list (cdr item)))
        ) ;_ end of if
      ) ;_ end of foreach
      (foreach item (dictsearch (namedobjdict) "ACAD_SCALELIST")
        (if (= 350 (car item))
          (setq lst (cons (cdr (assoc 300 (entget (cdr item)))) lst))
        ) ;_ end of if
      ) ;_ end of foreach
      (if (and lst
               (setq
                 pat (vl-remove-if '(lambda (x) (member (car x) lst)) pat)
               ) ;_ end of setq
          ) ;_ end of and
        (progn
          (while (> (getvar "CMDACTIVE") 0) (command))
          (command "_.-scalelistedit")
          (foreach item pat
            (command "_Add"
                     (car item)
                     (strcat (rtos (cadr item)) ":" (rtos (caddr item)))
            ) ;_ end of command
          ) ;_ end of foreach
          (command "_Exit")
          (while (> (getvar "CMDACTIVE") 0) (command))
        ) ;_ end of progn
      ) ;_ end of if
    ) ;_ end of progn
  ) ;_ end of if
  (princ)
) ;_ end of defun

rkmcswain

  • Swamp Rat
  • Posts: 978
Re: Purge excess scales
« Reply #8 on: July 29, 2009, 10:10:33 AM »
Quote from: GDF
Is there a way to automatically keep this from happening?

By default, scale list entries in top level xrefs will always be imported into the parent drawing, but entries from nested xrefs no longer are.

Crank

  • Water Moccasin
  • Posts: 1503
Re: Purge excess scales
« Reply #9 on: July 29, 2009, 11:05:51 AM »
That was fixed in Acad2008 SP1.

In order to be complete, in acad2009 the following annotation scaling changes were made:
  • Unused scales from parent drawing are no longer brought in while inserting an external block or copy/pasting objects.
  • The XREF bind bug after SCALELISTEDIT reset is fixed.
  • SCALELISTEDIT reset now looks at the MEASUREMENT sysvar. If it is set to 1 then the inches scales are not created.
  • When a drawing containing  > 100 scales is opened, the user is now presented with an alert dialog prompting him to reset his scale list.
  • When resolving an Xref that contains over 100 scales, AutoCAD now displays the following message at the command line as each Xref is loaded to inform the user that there are excessive scales:

     "# annotation scales detected.  It is recommended you open and resave the Xref file to remove excess scales."
  • A "Hide Xref scales" item has been added to the Scales list dropdown list in the Status bar.  Picking the "Hide Xref scales" item displays or hides Xref scales from the list.
  • The SCALELISTEDIT dialog is fixed to allow the Delete button to be enabled when selecting multiple scales if one of the scales is referenced.  Pressing the Delete button deletes any unreferenced scales that are selected and leaves any referenced scales that are selected.

Purging the unused scales would have been a much easier solution.
Vault Professional 2023     +     AEC Collection

rkmcswain

  • Swamp Rat
  • Posts: 978
Re: Purge excess scales
« Reply #10 on: July 29, 2009, 04:46:38 PM »
The "Hide Xref Scales" thing is silly - just a mask for the problem. Now for unsuspecting users, if "Hide Xref Scales" may be on, and they won't know they have thousands of scale list entries until it's too late...

Crank

  • Water Moccasin
  • Posts: 1503
Re: Purge excess scales
« Reply #11 on: July 30, 2009, 04:25:43 AM »
The whole SCALELIST is silly as it is. Why are the default scales fixed by Autocad? They only needed a fixed scale of 1:1, other scales can be added easy. Even after the 'MEASUREMENT fix' we get all kind of scales we will never use and scales we need aren't there...

Our company never had problems with the excessive scales. I recognized most of the problems before we switched to 2008, so we've purged all unused scales from day 1. When you need a scale that doesn't exist, you can just type it or create it from a toolbar (code here):
Vault Professional 2023     +     AEC Collection

gile

  • Water Moccasin
  • Posts: 2492
  • Marseille, France
Re: Purge excess scales
« Reply #12 on: July 30, 2009, 06:26:14 AM »
Hi,

My 2 cents (I'm new to all this cause I just upgrade from 2007 to 2010)

2 sub routines: one to get the current scale list, the other to set a scale list (the lists returned by GetScaleList or requiered by SetScaleList are the same format as VVA's)

EDIT: added PURGESCALES command (and some sub routines too)

Code: [Select]
;;;============================================================;;;
;;;======================= SUB ROUTINES =======================;;;
;;;============================================================;;;

;; GetCurrentScaleList (gile)
;; Returns the current scales as a list of sublists
;; Each sublist type is : (ScaleName PaperUnit DrawingUnit)

(defun GetCurrentScaleList (/ elst result)
  (and
    (setq elst (dictsearch (namedobjdict) "ACAD_SCALELIST"))
    (setq elst (vl-member-if '(lambda (x) (= 3 (car x))) elst))
    (while elst
      (setq result  (cons
      (ScaleList (cdadr elst))
      result
    )
    elst (cddr elst)
      )
    )
  )
  (reverse result)
)

;;;============================================================;;;

;; SetScaleList (gile)
;; Sets the scale list according to the lst argument
;;
;; Argument : lst a list of sublists which type is: (ScaleName PaperUnit DrawingUnit)

(defun SetScaleList (lst / dict)
  (entmod (vl-remove-if
    '(lambda (x) (or (= (car x) 3) (= (car x) 350)))
    (setq dict (dictsearch (namedobjdict) "ACAD_SCALELIST"))
  )
  )
  (setq dict (cdr (assoc -1 dict))
n    -1
  )
  (foreach s lst
    (dictadd dict
     (strcat "A" (itoa (setq n (1+ n))))
     (entmakex
       (list
'(0 . "SCALE")
'(100 . "AcDbScale")
(cons 300 (car s))
(cons 140 (cadr s))
(cons 141 (caddr s))
       )
     )
    )
  )
)

;;;============================================================;;;

;; ScaleList (gile)
;; Returns the "SCALE" object list as (ScaleName PaperUnit DrawingUnit)
;;
;; Argument scl (ENAME) a "SCALE" object

(defun ScaleList (scl / elst)
  (setq elst (entget scl))
  (list
    (cdr (assoc 300 elst))
    (cdr (assoc 140 elst))
    (cdr (assoc 141 elst))
  )
)

;;;============================================================;;;

;; GetAnnotativeScaleList (gile)
;; Returns the list of the currently used annotative scales as a list
;; of sublists which type is (ScaleName PaperUnit DrawingUnit)

(defun GetAnnotativeScaleList (/ n ss ent xDict dict slst result)
  (setq n 0)
  (if (setq ss (ssget "_X" '((-3 ("AcadAnnotative")))))
    (while (setq ent (ssname ss n))
      (setq n (1+ n))
      (if (and
    (setq xDict (GetExtDict ent))
    (setq dict (dictsearch xDict "AcDbContextDataManager"))
    (setq dict (dictsearch (cdr (assoc -1 dict)) "ACDB_ANNOTATIONSCALES"))
  )
(foreach p dict
  (if (= (car p) 350)
    (setq slst (ScaleList (cdr (assoc 340 (entget (cdr p)))))
  result  (if (not (vl-position slst result))
    (cons slst result)
    result
  )
    )
  )
)
      )
    )
  )
  result
)

;;;============================================================;;;

;; GetExtDict (gile)
;; Returns the entity extension dictionary ename (or nil)
;;
;; Argument : ent (ENAME)

(defun GetExtDict (ent)
  (cdr
    (assoc 360
   (member '(102 . "{ACAD_XDICTIONARY") (entget ent))
    )
  )
)

And two three little commands:
- SAVESCALES: runs the SCALELISTEDIT native command and stores the resulted scale list in an environment variable (registry).
- RESTORESCALES: restores the scale list stored in the environment variable (or runs SAVESCALES if no previous saving)
- PURGESCALES: purges all unused annotative scales except "1:1"[color]

Code: [Select]
;;;============================================================;;;
;;;========================= COMMANDS =========================;;;
;;;============================================================;;;

;; SAVESCALES (gile)
;; Runs SCALELISTEDIT command and save the resulting list in an
;; environment variable

(defun c:SaveScales ()
  (initdia)
  (vl-cmdf "_.scalelistedit")
  (while (/= (getvar 'cmdactive) 0)
    (vl-cmdf pause)
  )
  (setenv "SavedScaleList"
  (vl-prin1-to-string (GetCurrentScaleList))
  )
  (princ)
)

;;;============================================================;;;

;; RESTORESCALES (gile)
;; Restores the scale list previously saved with SAVESCALES
;; or runs SCALAESAVE if no previous saving

(defun c:RestoreScales (/ lst)
  (if (and
(setq lst (getenv "SavedScaleList"))
(setq lst (read lst))
      )
    (SetScaleList lst)
    (c:SaveScales)
  )
  (princ)
)

;;;============================================================;;;

;; PURGESCALES (gile)
;; Purges all unused annotative scales except "1:1"

(defun c:PurgeScales (/ alst cnt)
  (setq alst (GetAnnotativeScaleList)
cnt 0
)
  (foreach p (dictsearch (namedobjdict) "ACAD_SCALELIST")
    (and
      (= 350 (car p))
      (setq slst (ScaleList (cdr p)))
      (/= "1:1" (car slst))
      (null (member slst alst))
      (entdel (cdr p))
      (setq cnt (1+ cnt))
    )
  )
  (princ (strcat (itoa cnt) " échelle(s) purgée(s)."))
  (princ)
)
« Last Edit: August 02, 2009, 11:49:00 AM by gile »
Speaking English as a French Frog

gile

  • Water Moccasin
  • Posts: 2492
  • Marseille, France
Re: Purge excess scales
« Reply #13 on: August 01, 2009, 03:46:09 PM »
Hi,

I revised the upper code: add a PURGESCALES command which removes from the scale list all the scales which aren't currently used by an annotative object (except "1:1").
Speaking English as a French Frog

GDF

  • Water Moccasin
  • Posts: 2079
Re: Purge excess scales
« Reply #14 on: August 03, 2009, 10:53:38 AM »
Thanks Gile.

I can sure make use of these, thanks for sharing.
Why is there never enough time to do it right, but always enough time to do it over?
BricsCAD 2020x64 Windows 10x64