TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started by: Amsterdammed on May 01, 2016, 07:46:51 AM
-
I generate shopdrawings out of a drawing for my technical equipment rooms. work great 9 times here and now at the 10 building in this project it doesn't.
i create for each shop drawing a wblock that later will be inserted in a m"mother" shop drawing and layout are created in there. this all worked. but now it stops working after the 5th (no matter what 5 i select wblocks inserted in the mother drawing . block does load in the drawing but not show, so all lisp that works further with that block comes to an halt.
no matter what i do a wblock out of that particular drawing becomes 4mb, even for a single line. also with copy/paste in to template. if i draw the line in the template it is 68kb. even a wblock out of the wblock is 4mb.
i know that wblock are using the source drawing as a template, so there's clearly 4mb on BS getting past on . What could that be????
i purges everything including regapps.
i need to generate 160 shop drawings and time is running out fast.
What can i try to repair that ???
Thanks folks
Bernd
-
Challenging narrative. Odds are it's dictionary pollution, likely from a vertical (Civil 3D, Prosteel, yada), AEC pollution etc.
Run AnalyzeThis on the sickly drawings and share the reports:
(progn
;; Trivial code but nonetheless ... Copyright © 2007-2016 Michael Puckett
;;
;; Do note that the count values are not absolute. They reflect what is
;; found by sweeping thru all collections without applying instancing.
;;
;; For example, if Block "A" hosts 4 lines, and there are 10 instances of
;; said block the reported count will NOT be 40 — it will be 4. A future
;; version may address this issue.
(defun _AnalyzeThis ( this / _IndexThisEx _IndexThis _ImNotDead _LSet _RSet _GetChildrenAux _GetChildren _MakeReport _ExportReport _Main )
(defun _IndexThisEx ( this / objectname pair )
;; index is a lexical global declared in _Main
(setq index
(if
(setq pair
(assoc
(setq objectname
(vlax-get this 'Objectname)
)
index
)
)
(subst
(list
(car pair)
(1+ (cadr pair))
)
pair
index
)
(cons
(list objectname 1)
index
)
)
)
;; not strictly needed but
;; return the index to the caller
)
(defun _ImNotDead ( )
;; Admittedly takes longer to execute but operator
;; knows AutoCAD is alive; doing something.
;;
;; Note: Variable count is a lexical global (int).
(if (zerop (rem (setq count (1+ count)) 100 ))
(progn
(command ".delay" 0)
(princ (strcat "\rIndexed [" (itoa count) "] objects."))
(princ)
)
)
)
(defun _LSet ( text len )
(while (< (strlen text) len)
(setq text (strcat text " "))
)
(substr text 1 len)
)
(defun _RSet ( text len )
(while (< (strlen text) len)
(setq text (strcat " " text))
)
(substr text (- (strlen text) len -1))
)
(defun _IndexThis ( this )
;; _IndexThis is a wrapper for IndexEx.
;; don't get it? Too bad, so sad.
;; let 'em know we haven't died
(_ImNotDead)
(_IndexThisEx this)
;; this is not a robust example of programming,
;; but in the interests of time and ascii economy
;; I'm using a simplistic recursive sledge hammer
;; technique
(vl-catch-all-apply
(function
(lambda ( )
;; force an error if the 'this'
;; object is not a collection
(vlax-get this 'Count)
;; 'kay, let's roll
(vlax-for object this
(_IndexThis object)
)
)
)
)
(if (eq :vlax-true (vla-get-hasextensiondictionary this))
(_IndexThis (vla-getextensiondictionary this))
)
(foreach brat (_GetChildren this)
(_IndexThis brat)
)
)
(defun _GetChildrenAux ( ename / result )
(while (and ename (/= "SEQEND" (cdr (assoc 0 (entget ename)))))
(setq
result (cons ename result)
ename (entnext ename)
)
)
(mapcar 'vlax-ename->vla-object (reverse result))
)
(defun _GetChildren ( object / foo )
( (lambda ( ename )
(if (eq 1 (cdr (assoc 66 (entget ename))))
(_GetChildrenAux (entnext ename))
)
)
(vlax-vla-object->ename object)
)
)
(defun _MakeReport ( data / sum len1 len2 len3 val div val )
(setq
data (vl-sort data '(lambda (a b) (> (cadr a) (cadr b))))
data (cons (list "TOTAL COUNT:" (setq sum (apply '+ (mapcar 'cadr data)))) data)
len1 (1+ (apply 'max (mapcar 'strlen (mapcar 'car data))))
len2 (strlen (itoa sum))
len3 (1+ (strlen "[100.0%]"))
div (/ sum 100.0)
)
(cons
(list
(strcat
(apply 'strcat (mapcar 'getvar '(dwgprefix dwgname)))
"\n"
)
)
(mapcar
(function
(lambda ( pair )
(list
(_LSet (car pair) len1)
(_RSet (itoa (setq val (cadr pair))) len2)
(_Rset (strcat " [" (rtos (/ val div) 2 1) "%]") len3)
)
)
)
data
)
)
)
(defun _ExportReport ( report / name handle )
(setq
name (vl-filename-mktemp "analyzethis.txt")
handle (open name "w")
)
(foreach lst report
(foreach x lst (princ x handle))
(princ "\n" handle)
)
(close handle)
(startapp "notepad.exe" name)
)
(defun _Main ( this / count index report handle )
;; Variables 'index' and 'count' are lexical globals
;; accessed by lexical global function _IndexEx,
;; _IndexThis and _ImOk.
(setq count 0)
(_IndexThis (vlax-get this 'Blocks))
(_IndexThis (vlax-get this 'Dictionaries))
(_IndexThis (vlax-get this 'DimStyles))
;; (_IndexThis (vlax-get this 'FileDependencies))
(_IndexThis (vlax-get this 'Groups))
(_IndexThis (vlax-get this 'Layers))
(_IndexThis (vlax-get this 'Layouts))
(_IndexThis (vlax-get this 'Linetypes))
(_IndexThis (vlax-get this 'Materials))
(_IndexThis (vlax-get this 'PlotConfigurations))
(_IndexThis (vlax-get this 'RegisteredApplications))
(_IndexThis (vlax-get this 'TextStyles))
(_IndexThis (vlax-get this 'UserCoordinateSystems))
(_IndexThis (vlax-get this 'Viewports))
(foreach lst (setq report (_MakeReport index))
(foreach x lst (princ x))
(princ "\n")
)
(_ExportReport report)
(princ)
)
(_Main this)
)
(defun C:AnalyzeThis ( / dimzin cmdecho )
(setq
cmdecho (getvar 'cmdecho)
dimzin (getvar 'dimzin)
)
(setvar 'cmdecho 0)
(setvar 'dimzin 0)
(_AnalyzeThis (vla-get-activedocument (vlax-get-acad-object)))
(setvar 'dimzin dimzin)
(setvar 'cmdecho cmdecho)
(princ)
)
(c:AnalyzeThis)
)
Edit: Revised program to show what percentage an individual tally represents.
Edit: Revised program to indicate it's busy (for larger drawings).
Edit: Revised ImNotDead function.
-
Michael,
thanks, i am running the code, but it is a pretty big drawing, so i seems to take a while. I have some detail in the drawing from the architect, so that might be the source. but just deleting and purge isn't doing it, i tried that in one of the wblocks and then made a wblock out of that and it still was 4mb.
I will share the result when available.
Thanks Bernd
-
Hope you grabbed the latest version of the utility. An interim version had a bug. Apologies if the one you grabbed crashes.
-
("AcDbLine" 166374)
("AcDbBlockTableRecord" 18974)
("AcDbEllipse" 14668)
("AcDbLSStrokePatternComponent" 11710)
("AcDb2dVertex" 11149)
("AcDbLSSymbolComponent" 7440)
("AcDbPolyline" 5397)
("AcDbPoint" 4922)
("AcDbLSPointComponent" 4257)
("AcDbLSCompoundComponent" 4255)
("AcDbBlockReference" 4192)
("AcDbLinetypeTableRecord" 3195)
("AcDbHatch" 3190)
("AcDbDictionary" 3060)
("AcDb3dSolid" 3054)
("AcDbSpline" 2480)
("AcDbMText" 2390)
("AcDbLayerTableRecord" 2336)
("AcDbLSDefinition" 2266)
("AcDbText" 1314)
("AcDbLSInternalComponent" 1082)
("AcDbAttribute" 753)
("AcDbArc" 599)
("AcDbXrecord" 595)
("AcDb2dPolyline" 272)
("AcDbAttributeDefinition" 173)
("AcDbRegion" 144)
("AcDbBody" 124)
("AcDbCircle" 115)
("AcDbViewport" 110)
("AcDbScale" 83)
("AcDbTextStyleTableRecord" 66)
("AcDbRegAppTableRecord" 59)
("AcDbSortentsTable" 59)
("AcDbSection" 56)
("AcDbField" 45)
("AcDbLayout" 44)
("AcDbVisualStyle" 26)
("AcDbSolid" 19)
("AcDbMaterial" 14)
("AcDbDictionaryVar" 12)
("AcDbZombieObject" 12)
("vlo_VL" 11)
("AcDbDimStyleTableRecord" 10)
("AcDbRotatedDimension" 8)
("AcDbWipeout" 6)
("AcDbMLeaderStyle" 4)
("AcDbAssocNetwork" 2)
("AcDbViewportTableRecord" 1)
("AcDbViewportTable" 1)
("AcDbUCSTable" 1)
("AcDbTextStyleTable" 1)
("AcDbRegAppTable" 1)
("AcDbLinetypeTable" 1)
("AcDbLayerTable" 1)
("AcDbDimStyleTable" 1)
("AcDbWipeoutVariables" 1)
("AcDbTableStyle" 1)
("AcDbSectionManager" 1)
("AcDbPlaceHolder" 1)
("AcDbDictionaryWithDefault" 1)
("AcDbMlineStyle" 1)
("AcDbFieldList" 1)
("AcDbSolidBackground" 1)
("AcDbDimAssoc" 1)
("AcDbDynamicBlockPurgePreventer" 1)
("AcDbEvalGraph" 1)
("AcDbMLeader" 1)
("AcDbBlockTable" 1)
Total object count: 281147
what now?
-
missed that in my post:
RG-07-50-00-250.dwg
Object tally:
-
Perform the analysis on a drawing from the same series that isn't bloated.
-
AcDbLSStrokePatternComponent ... Ergo: 'Classic' DGN linetypes problem?
See:
https://www.theswamp.org/index.php?topic=48574.msg536490#msg536490
-
are you using the standard "wblock" command, or "-wblock"? I've had better results when using the -w command.
I generate shopdrawings out of a drawing for my technical equipment rooms. work great 9 times here and now at the 10 building in this project it doesn't.
i create for each shop drawing a wblock that later will be inserted in a m"mother" shop drawing and layout are created in there. this all worked. but now it stops working after the 5th (no matter what 5 i select wblocks inserted in the mother drawing . block does load in the drawing but not show, so all lisp that works further with that block comes to an halt.
no matter what i do a wblock out of that particular drawing becomes 4mb, even for a single line. also with copy/paste in to template. if i draw the line in the template it is 68kb. even a wblock out of the wblock is 4mb.
i know that wblock are using the source drawing as a template, so there's clearly 4mb on BS getting past on . What could that be????
i purges everything including regapps.
i need to generate 160 shop drawings and time is running out fast.
What can i try to repair that ???
Thanks folks
Bernd
-
Michael,
you are great!! Thank you. took the dgnfix lsp and changed the alert to princ so i could run it as a script, and repaired my 160 dwgs.
now i insert them in my "mother shop drawing and it seems to work, no more hick-ups.
You saved my butt(again)!!
Thanks,
Bernd
-
Roy,
forgot to thank you too for your help!
It was the dgn linetype problem!
all fixed with swamp posts!
Thanks
Bernd
-
... Let's not forget alanjt (Alan J. Thompson) the author of DGNFix.
-
Iindeed!
-
AcDbLSStrokePatternComponent ... Ergo: 'Classic' DGN linetypes problem?
See:
https://www.theswamp.org/index.php?topic=48574.msg536490#msg536490
Thanks for stepping in with this info Roy. I should have recognized same -- our company was hit with this rather massively a couple years ago with drawings from another consulting firm. The result was rather traumatic -- it crippled our system for a couple days as scores of drawings infected other drawings ad infinitum. To this day our fix is named after the other company. In my defense I was on my phone and hadn't read the analysis dump, I figured the culprit(s) would be plain enough comparing the report from a diseased file and non diseased file.
Michael,
you are great!! Thank you. took the dgnfix lsp and changed the alert to princ so i could run it as a script, and repaired my 160 dwgs.
now i insert them in my "mother shop drawing and it seems to work, no more hick-ups.
You saved my butt(again)!!
Thanks,
Bernd
My pleasure, thanks for the thanks.
... Let's not forget alanjt (Alan J. Thompson) the author of DGNFix.
This x 2.
-
Note: AnalyzeThis proggy updated.