Visual LISP, AutoLISP and General Customization

Reply
Valued Contributor
Posts: 52
Registered: ‎03-11-2013
Message 1 of 39 (2,114 Views)

Remove Hidden Data and Reduce File Size

2114 Views, 38 Replies
03-27-2013 12:25 PM

I am trying to reduce the drawing file size.  This is for uploading the drawings to AutoCAD WS.  AutoCAD WS doesn't display or edit a drawing that is over 15MB.  Unfortunately some of our drawings are over 15MB even after I have removed the background and others and have purged.  I believe the reason why a drawing can be so big has to do with each object (grouped object) has a ton of information on it.  For example, the properties of a typical object is like this:

 

(
   (-1  . <Entity name: 7ffffbece60>)
   (0   . "PRCD_FITTING")
   (5   . "145B6")
   (102 . "{ACAD_XDICTIONARY")
   (360 . <Entity name: 7ffffbece70>)
   (102 . "}")
   (330 . <Entity name: 7ffffbf59f0>)
   (100 . "AcDbEntity")
   (67  . 0)
   (410 . "Model")
   (8   . "BON-SupplyMP-3.0-4.0 RECT")
   (62  . 1)
   (100 . "CPrcdEntity")
   (280 . 10)
   (90  . 601861454)
   (70  . 24058)
   (70  . 4567)
   (280 . -65)
   .
   . Skip 3000 lines here for clarity
   .
   (90  . 0)
   (90  . 0)
   (90  . 0)
)

You can see from above that the list of properties are huge.  All I really need are the visible parts of the object.  This means most of the info above are junk.

 

I try to reduce the size of object by exploding all the objects on the drawing.  This sort of work in the sense that the file size of a test drawing is reduced from something like 8MB down to 6MB.  But I am expecting far more reduction than this.  The reason why I expect far more reduction is that the total number of lines of the exploded items of the same object mentioned above is reduced from 3000+ lines to only 300 lines as shown below:

 

(
   (-1  . <Entity name: 7fffe8654f0>)
   (0   . "LINE")
   (330 . <Entity name: 7ffffa1b9f0>)
   (5   . "3B11F")
   (100 . "AcDbEntity")
   (67  . 0)
   (410 . "Model") 
   (8   . "BON-SupplyMP-3.0-4.0 RECT")
   (62  . 1)
   (100 . "AcDbLine") (10 4188.87 -423.095 156.0) (11 4188.87 -387.095 156.0) (210 0.0 0.0 1.0)
)
(
   (-1  . <Entity name: 7fffe8655f0>)
   (0   . "LINE")
   (330 . <Entity name: 7ffffa1b9f0>)
   (5   . "3B12F")
   (100 . "AcDbEntity")
   (67  . 0)
   (410 . "Model")
   (8   . "BON-SupplyMP-3.0-4.0 RECT")
   (62  . 1)
   (100 . "AcDbLine") (10 4248.87 -453.095 156.0) (11 4212.87 -453.095 156.0) (210 0.0 0.0 1.0)
)
.
. Skip 250 lines here for clarity
.
(
   (-1  . <Entity name: 7fffe865260>)
   (0   . "MTEXT")
   (330 . <Entity name: 7ffffa1b9f0>)
   (5   . "3B0F6")
   (100 . "AcDbEntity")
   (67  . 0)
   (410 . "Model")
   (8   . "BON-SupplyMP-3.0-4.0 RECT-ANNO")
   (62  . 1)
   (100 . "AcDbMText") (10 4193.39 -418.589 150.0)
   (40  . 3.0)
   (41  . 19.8)
   (46  . 0.0)
   (71  . 1)
   (72  . 1)
   (1   . "\\Fdim.shx;\\W0.7000000000;\\T1.0000000000;\\o\\l24X30THRT")
   (7   . "BonDuctTXT") (210 0.0 0.0 1.0) (11 1.0 1.46161e-017 0.0)
   (42  . 17.5)
   (43  . 3.0)
   (50  . 1.46161e-017)
   (73  . 1)
   (44  . 1.0)
)

Therefore, I am expecting a 10-to-1 reduction, not just a 1/4 reduction.

 

I am wondering there may be hidden data on the drawing that are left behind after I have exploded the objects.  Unfortunately, purging the drawing doesn't help because there is nothing to be purged.

 

Would you please tell me if there is a way to get rid of the hidden data?  If there is a better alternative, please also let me know.

 

Jay Chan

*Expert Elite*
Kent1Cooper
Posts: 4,968
Registered: ‎09-13-2004
Message 2 of 39 (2,099 Views)

Re: Remove Hidden Data and Reduce File Size

03-27-2013 01:15 PM in reply to: jchan

jchan wrote:

I am trying to reduce the drawing file size.  This is for uploading the drawings to AutoCAD WS.  ....  Unfortunately some of our drawings are over 15MB even after I have removed the background and others and have purged.  I believe the reason why a drawing can be so big has to do with each object (grouped object) has a ton of information on it.  .... 

.... 

I try to reduce the size of object by exploding all the objects on the drawing.  This sort of work ....  But I am expecting far more reduction than this.  .... 

Therefore, I am expecting a 10-to-1 reduction, not just a 1/4 reduction.

 

I am wondering there may be hidden data on the drawing that are left behind after I have exploded the objects.  Unfortunately, purging the drawing doesn't help because there is nothing to be purged.

....


Not having AutoCAD WS [or even knowing what it is -- there doesn't seem to be a sub-forum devoted to it as there are for so many other AutoCAD variants and overlaid programs], nor knowing what a "PRCD_FITTING" object is, I can't say for sure.  But try Searching these Discussion Groups, or even the internet, for things like "purge hidden data", "purge dictionaries", "purge extended data", similar wordings with "remove" or "delete" or "eliminate" in place of "purge", and "Superpurge".  There are things out there, though you'll have to try some of them to see whether they'll work in your particular situation.

 

If not for the file size you describe, I might also suggest posting a drawing that others with the same software can experiment on.  But maybe such a drawing with only one of those overloaded objects in it would serve the purpose without being too much of a burden on the website.

Kent Cooper
*Expert Elite*
dgorsman
Posts: 4,710
Registered: ‎10-12-2006
Message 3 of 39 (2,094 Views)

Re: Remove Hidden Data and Reduce File Size

03-27-2013 01:28 PM in reply to: Kent1Cooper

FYI - AutoCAD WS is an online/"software as a service" version of AutoCAD, accessible over the internet via both computers and some portable devices.  Naturally, the features are quite limited.

----------------------------------
If you are going to fly by the seat of your pants, expect friction burns.
Adopt. Adapt. Overcome. Or be overcome.
A good question will be halfway to a good answer.


Mentor
Posts: 253
Registered: ‎11-05-2008
Message 4 of 39 (2,085 Views)

Re: Remove Hidden Data and Reduce File Size

03-27-2013 05:31 PM in reply to: jchan

the size of drawings depends on who or which software created the drawings!

 

if a human created drawings, so he/she should draw as a professional.

for example using blocks instead of group of same objects and so on.

 

if a software created a drawing (for example pdf 2 dwg) be sure about:

hatch objects may be exploded to tens or hundreds of line/plines.

many lines are overlapped

.....

 

so, it's better to use OVERKILL command.

 

as I said, the size of drawing defined by drawer/creator!

 

Abbas

 

*Expert Elite*
braudpat
Posts: 1,594
Registered: ‎12-15-2006
Message 5 of 39 (2,065 Views)

Re: Remove Hidden Data and Reduce File Size

03-28-2013 04:16 AM in reply to: aqdam1978

 

Hello from France

 

You could have a lot of hidden Infos in a DWG !  For example :

 

--- Registered Applications

Command :  -PURGE  with option R

 

--- XDATA - You need a Lisp/VLisp routine to erase ALL XDatas

I join a fabulous Lisp Routine from Gilles which counts Entities with XDATAs

and propose to delete ALL XDATAs ...

Routine :  XD_CNT_DEL

I have translated the minimum ...

 

--- Dictionnaries

You need a very special Lisp/VLisp routine to ERASE ALL Dictionnaries ...

Could be very dangerous !?

 

Don't forget that if you PURGE too much (Registered Applics, XDatas, Dictionnaries, etc)

yours vertical applicatiosn will not run / recognize special objets : AA, MEP, CIVIL, etc ...

 

So you have to Save the DWG with a NEW Filename !

 

Bye, Pat

 

Bye, Pat

*Expert Elite*
Hallex
Posts: 1,558
Registered: ‎10-08-2008
Message 6 of 39 (2,050 Views)

Re: Remove Hidden Data and Reduce File Size

03-28-2013 10:08 AM in reply to: jchan

Create copy of this drawing then load this routine

;; written by VK
(defun all_filters_del (/ doc ltb xdic fd f rec)
  (vl-load-com)
(setq doc (vla-get-activedocument (vlax-get-acad-object)))
(setq ltb (vlax-vla-object->ename (vla-get-layers doc))) ; коллекция LAYERS
(if (and (setq xdic (cdadr (member '(102 . "{ACAD_XDICTIONARY") (entget ltb)))) ; расширенный словарь
(setq fd (cdadr (member '(3 . "ACAD_LAYERFILTERS") (entget xdic)))) ; словарь фильтров
(assoc 3 (setq f (entget fd))) ;_ имеются фильтры
) ;_ and
(progn
;; выделение списка записей
(while (/= 3 (caar f))
(setq f (cdr f))
) ;_ остался список (3 . имя_фильтра) (360 . ename_XRECORD)...
;; удаление записей словаря
(while (setq xrec (cdadr f))
(entdel xrec)
(setq f (cddr f))
) ;_ while
;; удаление словаря фильтров
(dictremove xdic "ACAD_LAYERFILTERS")
(princ "\nФильтры из рисунка удалены.")
) ;_ progn
(princ "\nФильтров в рисунке не обнаружено.")
) ;_ if
) ;_ defun
(vl-load-com)
(all_filters_del) ;_ autoload

 This will delete layer filters from there,

then see how the size is reduced

_____________________________________
C6309D9E0751D165D0934D0621DFF27919
Valued Contributor
Posts: 52
Registered: ‎03-11-2013
Message 7 of 39 (2,042 Views)

Re: Remove Hidden Data and Reduce File Size

03-28-2013 11:12 AM in reply to: jchan

Thanks for the many helpful suggestions that I have received here.  Unfortunately, I still cannot reduce the file size.

 

Some background info:  I am using a third party software to help me to draw ductwork using AutoCAD.  Each object on the drawing represents a piece of pipe or fitting.  Visually they are shown as 2-D boxes with some descriptive texts inside them.  But the object contains more info than what is shown on the screen.  The object also has info about how it is supposed to be constructed, the kind of accessories that should be mounted on it, the number of stiffeners,...etc.  That's probably the reason why each object is so big.  Here, I want to generate a simplified drawing based on the master copy.  The simplified drawing only needs all the visible elements.  It doesn't need all those additional properties about the object.  I need to figure out where those additional properties are stored, and I want to know how to remove those properties in order to reduct the file size.

 

I have checked the drawing, and I am sure that it doesn't contain any XDATA because the objects don't have any -3 group code or 1000-or-above group code.

 

I have tried PURGE using the R option to remove registered applications.  It helps very little.

 

I indeed can find a long list of dictionaries related to the third party software.  Seem like the third party software may store their info as dictionaries.  I used (dictremove) command to remove all the dictionaries that are related to the third party software.  Unfortunately, the drawing file size actually INCREASED instead of reduced.  This is very puzzling.

 

I have also used the (all_filters_del) LISP program that a forum member has offered.  It can reduce the drawing file size in a tiny test drawing.  But running this on a large drawing actually increases the file size.

 

I have attached a small drawing that has only one piece of duct in it.  When you use (entget (car (entsel))) to check the properties of that single piece of duct, you will see that it has a very long list of properites.  The visual part of it should be only 1/10 of this size.  Please note that you need to use LOGFILEON / LOGFILEOFF to log the long list of properties.  Otherwise, you will only see a small subset in the command window.

 

I will greatly appreciate if people can tell me what I should do to shrink the object size and the file size.  Thanks in advance.

 

Jay Chan

*Expert Elite*
dgorsman
Posts: 4,710
Registered: ‎10-12-2006
Message 8 of 39 (2,038 Views)

Re: Remove Hidden Data and Reduce File Size

03-28-2013 11:46 AM in reply to: jchan

Thats an AEC custom object.  It can be converted to "pure" AutoCAD objects via AECTOACAD but as noted it will make the file bigger.  Its one of the reasons for creating custom objects in the first place - they can do a lot, and be prevented from doing other things, while having a smaller file size than an AutoCAD-entity equivalent (data as opposed to entities).

----------------------------------
If you are going to fly by the seat of your pants, expect friction burns.
Adopt. Adapt. Overcome. Or be overcome.
A good question will be halfway to a good answer.


Valued Contributor
Posts: 52
Registered: ‎03-11-2013
Message 9 of 39 (2,027 Views)

Re: Remove Hidden Data and Reduce File Size

03-28-2013 12:49 PM in reply to: dgorsman

Thanks for pointing out that the objects are AEC Custom Objects.  I didn't know this name until today.

 

Is there a way to remove AEC info from the drawing and only keep the visual items?  If I explode the object and leave with the basic visual items, the total object size should be smaller, not bigger, right?  I would think that if the file size ends up bigger, this means AEC info are still in the drawing; but they are in broken links that no one can refer to them, and no one can clean them.  I tested this theory by copying and pasting only the visual items from the drawing to another drawing.  Unfortunately, the end result is even bigger than the original drawing.

 

If you know how to shrink the file size, please let me know.  Thanks.

 

Jay Chan

*Expert Elite*
braudpat
Posts: 1,594
Registered: ‎12-15-2006
Message 10 of 39 (2,027 Views)

Re: Remove Hidden Data and Reduce File Size

03-28-2013 12:50 PM in reply to: dgorsman

 

Hello from France

 

I have used a very special Routine to "wipe out" unnecessary things ...

I lost some colors ...  I was to "strict" maybe !?

 

What do you think of the result ?

 

Is it possible to get a DWG with more special objects ?

 

Bye, Pat

 

Bye, Pat

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Announcements
Welcome to the new Autodesk Community!
If this is your first visit, click here to get started and make the most of the Community. Let us know what you think of the new experience in the Community Feedback Forum.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community