Author Topic: Corrupt database?  (Read 818 times)

0 Members and 1 Guest are viewing this topic.

CincyJeff

  • Newt
  • Posts: 78
Corrupt database?
« on: May 26, 2016, 10:47:45 AM »
We have a drawing that is performing very slowly, especially during saves. It is 6 MB in size and similar drawings save in 10 seconds or so. This one takes minutes. I used Counts (Copyright 2003 Michael Puckett) and it provided some interesting results. Block *U506 is listed with a count of 4046 but when I do a (setq ss (ssget "X" '((0 . "INSERT") (2 . "`*U506")))) it only retrieves one, which is correct. I deleted the one true reference and the count still listed 4046. It did go away after the block was purged. We recreated the drawing using our base template by copy/pasting the items we needed and all is well in the new drawing. If this happens again is there any way to fix the database so we don't have to rebuild the drawing, as an audit had no effect?

ronjonp

  • Needs a day job
  • Posts: 7060
Re: Corrupt database?
« Reply #1 on: May 26, 2016, 10:51:45 AM »
If you're copy pasting from a base template & have issues, it sounds like your template is fuxered.  ;)  Can you post the drawing?

Windows 10 x64 - AutoCAD /C3D 2020

Custom Build PC

MP

  • Seagull
  • Posts: 17498
Re: Corrupt database?
« Reply #2 on: May 26, 2016, 10:55:54 AM »
You are misinterpreting the report. Counts reports the number of objects in collections, blocks etc. Therefore, anonymous block *U506 hosts 4046 entities. Posting the dwg is a good idea. Cheers.
\|// Set goal. Experiment tirelessly until
|Oo| practice has become expertise.  Loop.
|- | LinkedIn | Dropbox

CincyJeff

  • Newt
  • Posts: 78
Re: Corrupt database?
« Reply #3 on: May 26, 2016, 11:49:54 AM »
MP,
Thanks for the clarification. Can't post the drawing - proprietary.

MP

  • Seagull
  • Posts: 17498
Re: Corrupt database?
« Reply #4 on: May 26, 2016, 12:02:38 PM »
Sorry, can't play here. But here's a Hail Mary throw:

Code: [Select]
(progn

    (defun _NukeDics ( doc pattern )
        ;;  e.g. (_NukeDics document "OFFENDING_PREFIX_1*,OFFENDING_PREFIX_2*")
        (   (lambda ( filter matching dead data pattern / kill_list )
                (foreach lst
                    (setq kill_list
                        (vl-remove-if-not 'matching
                            (mapcar 'list
                                (filter 3 data)
                                (filter 350 data)
                            )
                        )
                    )
                    (vl-catch-all-apply 'entdel (cdr lst))     
                )
                ;;  return list of dic names that were successfully deleted
                (mapcar 'car (vl-remove-if-not 'dead kill_list))                           
            )
            (lambda (k d) (mapcar 'cdr (vl-remove-if-not '(lambda (p) (eq k (car p))) d)))
            (lambda (p) (wcmatch (strcase (car p)) pattern))
            (lambda (l) (vlax-erased-p (cadr l)))
            (entget (vlax-vla-object->ename (vla-get-dictionaries doc)))
            (if (eq 'str (type pattern)) (strcase pattern) "*")
        )
    )
   
    (vl-load-com)

    (_NukeDics
        (vla-get-activedocument (vlax-get-acad-object))
        "ACAD_DGNLINESTYLECOMP"
    )

)

Cheers.
\|// Set goal. Experiment tirelessly until
|Oo| practice has become expertise.  Loop.
|- | LinkedIn | Dropbox

Marc'Antonio Alessi

  • Swamp Rat
  • Posts: 1020
  • Marco
Re: Corrupt database?
« Reply #5 on: May 27, 2016, 04:20:07 AM »
Make a safe copy of your DWG and try also:
Code: [Select]
(_NukeDics
        (vla-get-activedocument (vlax-get-acad-object))
        "ACAD_DATALINK,AEC_DISP_REPS,AEC_DISPLAY_PROPS_DEFAULTS,ACAD_SCALELIST,ACAD_DGNLINESTYLECOMP"
)

MP

  • Seagull
  • Posts: 17498
Re: Corrupt database?
« Reply #6 on: May 27, 2016, 12:07:06 PM »
As my friend Marc suggests, experiment on copies of the afflicted drawing.

The following makes it easier to select dictionaries to delete, noting the results (good/bad) on the resulting drawing. Be careful, nuking dictionaries with wild abandon can lead to disastrous results. For example, if one deletes KS_SHAPEREF* dictionaries one will be in for a world of pain as hundreds of dialogs will be thrown when opening the drawing. tl;dr: Use judiciously.

Code: [Select]
(defun c:NukeDics ( / _GetDicsAsNamesAndEnames dic_data selected )
   
    ;;  c:NukeDics.lsp, Version 1.0 2016-05-27.
    ;;
    ;;  Trivial code, nonetheless: Copyright 2016 Michael Puckett
    ;;
    ;;  Provided as is, complete with errors, omissions and various
    ;;  terminal diseases. User must accept all responsibilty for
    ;;  consequences resulting from the use of this utility which
    ;;  is provided solely as a gift to the CAD community.

    (cond
        (   (null dos_checklist)
            (princ
                (strcat
                    "\nSorry, this utility uses DOSLIB which does "
                    "not appear to be loaded. See www.mcneel.com."
                )
            )
        )
        (   (progn (vl-load-com) nil))
        (   (null
                (defun _GetDicsAsNamesAndEnames ( dic )
                    (   (lambda ( filter data ) (mapcar 'list (filter 3 data) (filter 350 data)))
                        (lambda (k d) (mapcar 'cdr (vl-remove-if-not '(lambda (p) (eq k (car p))) d)))
                        (entget (if (eq 'vla-object (type dic)) (vlax-vla-object->ename dic) dic))
                    )
                )
            )
        )
        (   (null
                (setq dic_data
                    (_GetDicsAsNamesAndEnames
                        (vla-get-dictionaries
                            (vla-get-activedocument
                                (vlax-get-acad-object)
                            )
                        )
                    )
                )
            )
            (princ "\nOdd, this dwg appears to be dicless.")
        )
        (   (null
                (setq selected
                    (vl-remove-if-not
                        (function (lambda (p) (eq 1 (cdr p))))
                        (dos_checklist
                            "Nuke Dictionaries:"
                            "Select dictionaries to nuke:"
                            (mapcar
                                (function (lambda (p) (cons (car p) 0)))
                                (setq dic_data
                                    (vl-sort dic_data
                                        (function (lambda (a b) (< (car a ) (car b))))
                                    )
                                )
                            )
                        )
                    )
                )
            )
            (princ "\nNo dics selected for deletion.")
        )
        (   (foreach key (mapcar 'car selected)
                (vl-catch-all-apply 'entdel (setq l (cdr (assoc key dic_data))))
                (princ
                    (strcat
                        "\n"
                        key
                        (if (vlax-erased-p (car l))
                            " [deleted]"
                            " [delete attempt failed]"
                        )
                    )
                )
            )
        )
    )

    (princ)

)
« Last Edit: May 27, 2016, 12:20:13 PM by MP »
\|// Set goal. Experiment tirelessly until
|Oo| practice has become expertise.  Loop.
|- | LinkedIn | Dropbox

hermanm

  • Bull Frog
  • Posts: 282
Re: Corrupt database?
« Reply #7 on: May 27, 2016, 02:10:19 PM »
What is the size of the "recreated" dwg vs. the 6mb slow one?
I am guessing it is much smaller, which means MP's tool (!!) & others can purge the detritus.
Various culprits have been fingered @ various times in the past.
Try searching this forum using "purge"
From memory, a few nasties:

regapps
attached images
anonymous groups (ACAD purge gets these in modern versions)
If you don't know where you are going, you might not get there.
  - L.P. Berra

CincyJeff

  • Newt
  • Posts: 78
Re: Corrupt database?
« Reply #8 on: May 27, 2016, 04:34:44 PM »
hermanm,
Yes, the recreated drawing is much smaller but the issue wasn't regapps, attached images, or anonymous groups. I'm not worried about it as it has only happened once and the drawing was redone without much trouble. If it happens again I'll look more deeply into why. Thanks everyone that posted.

ronjonp

  • Needs a day job
  • Posts: 7060
Re: Corrupt database?
« Reply #9 on: June 10, 2016, 09:10:01 AM »
As my friend Marc suggests, experiment on copies of the afflicted drawing.

The following makes it easier to select dictionaries to delete, noting the results (good/bad) on the resulting drawing. Be careful, nuking dictionaries with wild abandon can lead to disastrous results. For example, if one deletes KS_SHAPEREF* dictionaries one will be in for a world of pain as hundreds of dialogs will be thrown when opening the drawing. tl;dr: Use judiciously.

Code: [Select]
(defun c:NukeDics ( / _GetDicsAsNamesAndEnames dic_data selected )
   
...
            (princ "\nOdd, this dwg appears to be dicless.")
...

)
;D

Windows 10 x64 - AutoCAD /C3D 2020

Custom Build PC

Dan

  • Mosquito
  • Posts: 8
Re: Corrupt database?
« Reply #10 on: June 10, 2016, 09:17:29 AM »
Silly question, since I didn't see you mention it: Did you do a wblock of the entire drawing to see if that cleared it up?