Author Topic: How to detect and fix damaged dictionaries?  (Read 1888 times)

0 Members and 1 Guest are viewing this topic.

HasanCAD

  • Swamp Rat
  • Posts: 1422
How to detect and fix damaged dictionaries?
« on: February 15, 2023, 04:46:17 AM »
Hi All,
This file size is up-normal even when is empty.
Suppose to be a damaged dictionary.

So
How to detect and fix damaged dictionaries?

Marc'Antonio Alessi

  • Swamp Rat
  • Posts: 1453
  • Marco
Re: How to detect and fix damaged dictionaries?
« Reply #1 on: February 15, 2023, 05:39:24 AM »

With:
(dictremove (namedobjdict) "AEC_DISPLAY_PROPS_DEFAULTS")
(vl-Catch-All-Apply '(lambda () (vla-Remove  (vla-GetExtensionDictionary (vla-Get-Layers (vla-get-ActiveDocument (vlax-get-Acad-Object)))) "ACAD_LAYERSTATES")))
Purge and you go on about 900Kb

But the best result is:
Code: [Select]
(defun C:ALE_Fix_Clean ( / FilNam)
  (setq FilNam (strcat (getvar "DWGPREFIX") "Clean_" (getvar "DWGNAME")))
  (if (findfile FilNam)
    (command "_.QSAVE" "_.WBLOCK" FilNam "_Y" "*")
    (command "_.QSAVE" "_.WBLOCK" FilNam "*")
  )
)
(C:ALE_Fix_Clean)

VovKa

  • Water Moccasin
  • Posts: 1631
  • Ukraine

HasanCAD

  • Swamp Rat
  • Posts: 1422
Re: How to detect and fix damaged dictionaries?
« Reply #3 on: February 15, 2023, 06:31:30 AM »
What's a magic.
Simple and effective solution.

So, This solution shall Solve damaged dictionaries?


Thanks Marc

But the best result is:
Code: [Select]
(defun C:ALE_Fix_Clean ( / FilNam)
  (setq FilNam (strcat (getvar "DWGPREFIX") "Clean_" (getvar "DWGNAME")))
  (if (findfile FilNam)
    (command "_.QSAVE" "_.WBLOCK" FilNam "_Y" "*")
    (command "_.QSAVE" "_.WBLOCK" FilNam "*")
  )
)
(C:ALE_Fix_Clean)

HasanCAD

  • Swamp Rat
  • Posts: 1422


HasanCAD

  • Swamp Rat
  • Posts: 1422

Marc'Antonio Alessi

  • Swamp Rat
  • Posts: 1453
  • Marco
Re: How to detect and fix damaged dictionaries?
« Reply #7 on: February 16, 2023, 10:00:25 AM »
What's a magic.
Simple and effective solution.

So, This solution shall Solve damaged dictionaries?


Thanks Marc

But the best result is:
Code: [Select]
(defun C:ALE_Fix_Clean ( / FilNam)
  (setq FilNam (strcat (getvar "DWGPREFIX") "Clean_" (getvar "DWGNAME")))
  (if (findfile FilNam)
    (command "_.QSAVE" "_.WBLOCK" FilNam "_Y" "*")
    (command "_.QSAVE" "_.WBLOCK" FilNam "*")
  )
)
(C:ALE_Fix_Clean)
I do not know, it is a normal Wblock...

Marc'Antonio Alessi

  • Swamp Rat
  • Posts: 1453
  • Marco
Re: How to detect and fix damaged dictionaries?
« Reply #8 on: February 16, 2023, 12:18:29 PM »

Try command -EXPORTTOAUTOCAD or this at your own risk (not fully tested):
Code: [Select]

(defun ALE_Fix_Dictionaries (EntDct / OutLst)
  (vlax-for VlaFor EntDct
    (if (vlax-property-available-p VlaFor 'Name)
      (setq OutLst (cons (cons (vlax-get VlaFor 'Name) VlaFor) OutLst))
    )
  )
  (reverse OutLst)
)
(defun ALE_Fix_DelDictionaries (DctNms)
  (foreach ForElm (ALE_Fix_Dictionaries (vla-get-dictionaries (vla-get-activedocument (vlax-get-acad-object))))
    (if (wcmatch (car ForElm) DctNms)
      (progn
        (vla-delete (cdr ForElm))
        (prompt (strcat "\nDict Deleted: " (car ForElm)))
      )
      (prompt (strcat "\nDict NOT Deleted: " (car ForElm)))
    )
  )
  (princ)
)
Code: [Select]
(ALE_Fix_DelDictionaries "IDAT-BASEDICTIONARY") ; this is eavy
(ALE_Fix_DelDictionaries "*AEC*")
(ALE_Fix_DelDictionaries "ASE_INDEX_DICTIONARY")
(ALE_Fix_DelDictionaries "ItDictLayerStateSet")
(ALE_Fix_DelDictionaries "Patrick_35")