Author Topic: File size is upnormal  (Read 3252 times)

0 Members and 1 Guest are viewing this topic.

HasanCAD

  • Swamp Rat
  • Posts: 1420
File size is upnormal
« on: February 13, 2023, 06:39:38 AM »
Hi All,
This file size is upnormal even when is empty.

Peter2

  • Swamp Rat
  • Posts: 650
Re: File size is upnormal
« Reply #1 on: February 14, 2023, 05:36:20 AM »
Seem to be some dictionaries, and maybe one is damaged ..

https://www.afralisp.net/autolisp/tutorials/dictionaries-and-xrecords.php

Peter

AutoCAD Map 3D 2023 German (so some technical terms will be badly retranslated to English)
BricsCAD V23

HasanCAD

  • Swamp Rat
  • Posts: 1420
Re: File size is upnormal
« Reply #2 on: February 15, 2023, 02:17:50 AM »
How to detect damaged dictionaries?

It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8659
  • AKA Daniel
Re: File size is upnormal
« Reply #3 on: February 15, 2023, 02:52:32 AM »
this one and the one below it have 600-700 entries.
they are customs objects so my utility won't purge them

maybe one of these will https://apps.autodesk.com/en/Publisher/PublisherHomepage?ID=200809200499705

ronjonp

  • Needs a day job
  • Posts: 7526
Re: File size is upnormal
« Reply #4 on: February 20, 2023, 11:32:27 AM »
You can use this to analyze drawings too: http://www.theswamp.org/lilly_pond/mp/lisp/counts.txt

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

dexus

  • Newt
  • Posts: 196
Re: File size is upnormal
« Reply #5 on: February 21, 2023, 03:07:34 AM »
I quickly combined DCL List Tile Dependency (Lee Mac) with a loop through the dictionaries.
This way you can look through what dictionaries are in the drawing.
No other functionality yet. Repair/delete/find empty etc. would be great.

Code - Auto/Visual Lisp: [Select]
  1. (defun c:dictBrowser ( / *error* dch dcl des lst rtn)
  2.   ; Based on http://www.lee-mac.com/listtiledependency.html
  3.   (defun *error* ( msg )
  4.       (if (= 'file (type des))
  5.           (close des)
  6.       )
  7.       (if (< 0 dch)
  8.           (unload_dialog dch)
  9.       )
  10.       (if (and (= 'str (type dcl)) (findfile dcl))
  11.           (vl-file-delete dcl)
  12.       )
  13.       (if (and msg (not (wcmatch (strcase msg t) "*break,*cancel*,*exit*")))
  14.           (princ (strcat "\nError: " msg))
  15.       )
  16.       (princ)
  17.   )
  18.  
  19.   (if
  20.     (and
  21.       (setq lst (getDict (entget (namedobjdict))))
  22.       (setq dcl (vl-filename-mktemp "tmp.dcl"))
  23.       (setq des (open dcl "w"))
  24.       (foreach str
  25.         '(
  26.           "lbx : list_box"
  27.           "{"
  28.           "    alignment = centered;"
  29.           "    fixed_width = true;"
  30.           "    fixed_height = true;"
  31.           "    width = 30;"
  32.           "    height = 30;"
  33.           "}"
  34.           "test : dialog"
  35.           "{"
  36.           "    label = \"Dictionaries in current drawing: \";"
  37.           "    spacer;"
  38.           "    : row"
  39.           "    {"
  40.           "        : lbx { key = \"lb0\"; label = \"Dictionary\"; }"
  41.           "        : lbx { key = \"lb1\"; label = \"Items\"; }"
  42.           "    }"
  43.           "    spacer;"
  44.           "    ok_cancel;"
  45.           "}"
  46.         )
  47.         (write-line str des)
  48.       )
  49.       (not (setq des (close des)))
  50.       (< 0 (setq dch (load_dialog dcl)))
  51.       (new_dialog "test" dch)
  52.     )
  53.     (progn          
  54.       (setq rtn '(0 0))
  55.       (LM:dcld:action '("lb0" "lb1") 'lst 'rtn)
  56.       (if (= 1 (start_dialog))
  57.         (princ
  58.           (strcat "\nThe user selected:"
  59.             (substr
  60.               (apply 'strcat
  61.                 (mapcar '(lambda ( x ) (strcat ", " x))
  62.                   (LM:dcld:getitems rtn lst)
  63.                 )
  64.               )
  65.               2
  66.             )
  67.           )
  68.         )
  69.         (princ "\n*Cancel*")
  70.       )
  71.     )
  72.   )
  73.   (*error* nil)
  74.   (princ)
  75. )
  76.  
  77. (defun getDict (lst / itm rtn ed)
  78.   (while (setq itm (assoc 3 lst))
  79.     (setq ed (cdr (assoc 350 lst)))
  80.     (setq ed
  81.       (cons (strcat "[" (cdr (assoc 5 (entget ed))) "]")
  82.         (mapcar-remove-nil
  83.           (function (lambda (e)
  84.             (if (= (car e) 3) (cdr e))
  85.           ))
  86.           (entget ed)
  87.         )
  88.       )
  89.     )
  90.     (setq rtn (cons (cons (cdr itm) (list ed)) rtn)
  91.           lst (cdr (member itm lst)))
  92.   )
  93.   (reverse rtn)
  94. )
  95.  
  96. (defun ALE_Fix_Dictionaries (EntDct / OutLst)
  97.   (vlax-for VlaFor EntDct
  98.     (if (vlax-property-available-p VlaFor 'Name)
  99.       (setq OutLst (cons (cons (vlax-get VlaFor 'Name) VlaFor) OutLst))
  100.     )
  101.   )
  102.   (reverse OutLst)
  103. )
  104.  
  105. (defun ALE_Fix_DelDictionaries (DctNms)
  106.     (if (wcmatch (car ForElm) DctNms)
  107.       (progn
  108.         (try 'vla-delete (list (cdr ForElm)))
  109.         (p "Dict Deleted" (car ForElm))
  110.       )
  111.     )
  112.   )
  113.   (princ)
  114. )
  115.  
  116. (defun mapcar-remove-nil (func lst / item rtn)
  117.   ;; ---------------------------------------------------------------- ;;
  118.   ;; mapcar-remove-nil - dexus                                        ;;
  119.   ;; ---------------------------------------------------------------- ;;
  120.   ;; A combination of (vl-remove nil (mapcar ... )) in one function.  ;;
  121.   ;; This function will apply the provided function to all elements   ;;
  122.   ;; of a list, if the return of the function is true than the item   ;;
  123.   ;; will be added, otherwise it will be removed.                     ;;
  124.   ;; ---------------------------------------------------------------- ;;
  125.   ;; func:    [list] Function to apply to all elements in list, if    ;;
  126.   ;;                 result is nil the item will be removed           ;;
  127.   ;; lst:     [list] List of items to process                         ;;
  128.   ;; returns: [list] List of all returns from func that were not nil  ;;
  129.   ;; ---------------------------------------------------------------- ;;
  130.  
  131.   (while lst
  132.     (if (setq item (apply func (list (car lst))))
  133.       (setq rtn (cons item rtn))
  134.     )
  135.     (setq lst (cdr lst))
  136.   )
  137.   (reverse rtn)
  138. )
  139.  
  140. ;; DCL List-Tile Dependency  -  V2.1 (2019-04-27)  -  Lee Mac
  141. ;; Configures action_tile statements for the list of keys to enabled dependency between the DCL tiles.
  142. ;; key     - [lst] List of DCL tile keys in order of dependency
  143. ;; lst-sym - [sym] Quoted variable containing list data
  144. ;; rtn-sym - [sym] Quoted variable containing initial selection indexes
  145.  
  146. (defun LM:dcld:action ( key lst-sym rtn-sym )
  147.  
  148.   (defun LM:dcld:addlist ( key lst )
  149.     (start_list key)
  150.     (foreach itm lst (add_list itm))
  151.     (end_list)
  152.   )
  153.  
  154.   (defun LM:dcld:getlists ( idx lst )
  155.     (if (cdr idx)
  156.       (cons (mapcar 'car lst) (LM:dcld:getlists (cdr idx) (cdr (nth (car idx) lst))))
  157.       lst
  158.     )
  159.   )
  160.  
  161.   (defun LM:substnth ( itm idx lst )
  162.     (if lst
  163.       (if (zerop idx)
  164.         (cons itm (mapcar '(lambda ( x ) 0) (cdr lst)))
  165.         (cons (car lst) (LM:substnth itm (1- idx) (cdr lst)))
  166.       )
  167.     )
  168.   )
  169.  
  170.   (defun LM:dcld:actions ( key lst-sym rtn-sym lvl / fun )
  171.     (setq fun
  172.       (if (cdr key)
  173.         (list 'lambda '( val lst )
  174.           (list 'setq rtn-sym (list 'LM:substnth '(atoi val) lvl rtn-sym))
  175.           (list 'LM:dcld:addlist (cadr key) (list 'nth (1+ lvl) (list 'LM:dcld:getlists rtn-sym 'lst)))
  176.           (list
  177.             (LM:dcld:actions (cdr key) lst-sym rtn-sym (1+ lvl))
  178.             (list 'set_tile (cadr key) "0") 'lst
  179.           )
  180.         )
  181.         (list 'lambda '( val lst )
  182.           (list 'setq rtn-sym (list 'LM:substnth '(atoi val) lvl rtn-sym))
  183.         )
  184.       )
  185.     )
  186.     (action_tile (car key) (vl-prin1-to-string (list fun '$value lst-sym)))
  187.     fun
  188.   )
  189.  
  190.   (mapcar 'LM:dcld:addlist key (LM:dcld:getlists (eval rtn-sym) (eval lst-sym)))
  191.  
  192.   (
  193.     (eval (LM:dcld:actions key lst-sym rtn-sym 0))
  194.     (set_tile (car key) (itoa (car (eval rtn-sym))))
  195.     (eval lst-sym)
  196.   )
  197.   (princ)
  198. )
  199.  
  200. ;; DCL List-Tile Dependency  -  Get Items  -  Lee Mac
  201. ;; Returns a list of the items selected from each dependent list tile.
  202. ;; idx - [lst] List of selection indexes
  203. ;; lst - [lst] List data
  204.  
  205. (defun LM:dcld:getitems ( idx lst / tmp )
  206.   (if (cdr idx)
  207.     (cons (car (setq tmp (nth (car idx) lst))) (LM:dcld:getitems (cdr idx) (cdr tmp)))
  208.     (list (nth (car idx) (car lst)))
  209.   )
  210. )

ronjonp

  • Needs a day job
  • Posts: 7526
Re: File size is upnormal
« Reply #6 on: February 21, 2023, 10:49:24 AM »
Hi All,
This file size is upnormal even when is empty.
The old wblock trick knocks this file down to 96 kb.
Code - Auto/Visual Lisp: [Select]
  1. (command "_.-wblock" (strcat (getvar 'dwgprefix) (getvar 'dwgname)) "*")


Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC