Author Topic: bzip yoiur dwg's  (Read 3830 times)

0 Members and 1 Guest are viewing this topic.

Mark

  • Custom Title
  • Seagull
  • Posts: 28762
bzip yoiur dwg's
« on: July 20, 2004, 09:30:15 AM »
You can get much better compression using bzip2 than with zip.
Code: [Select]

(defun bzip-dwg (/ arg_fn)
  (cond
((= (getvar 'dwgtitled) 1)
(setq arg_fn (strcat "-k " (getvar 'dwgprefix) (getvar 'dwgname)))
(startapp "bzip2" arg_fn)
)
)
  )


This will create a copy of the current dwg and compress it using bzip2. The compressed file is located next to the current dwg.

You can find bzip2 here:
http://gnuwin32.sourceforge.net/packages/bzip2.htm
TheSwamp.org  (serving the CAD community since 2003)

Mark

  • Custom Title
  • Seagull
  • Posts: 28762
bzip yoiur dwg's
« Reply #1 on: July 20, 2004, 10:08:57 AM »
You can un-bzip them with this.
Code: [Select]

(defun unbzip-dwg (/ bzip_fn dwg_fn)
  (cond
((setq bzip_fn (getfiled "Select bz2 file" "" "bz2" 8))
(setq dwg_fn
(strcat
 (vl-filename-directory bzip_fn)
 "\\"
 (vl-filename-base bzip_fn)
 )
  )
(if (not (findfile dwg_fn))
  (startapp "bzip2" (strcat "-d " bzip_fn))
  (alert "File exists..... ")
  )
)
)
  )
TheSwamp.org  (serving the CAD community since 2003)

JohnK

  • Administrator
  • Seagull
  • Posts: 10634
bzip yoiur dwg's
« Reply #2 on: July 20, 2004, 10:16:19 AM »
Cool. I did the same thing with my Vim Backup files. :D
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

SPDCad

  • Bull Frog
  • Posts: 453
bzip yoiur dwg's
« Reply #3 on: July 20, 2004, 11:55:25 AM »
You can get higher compression rates with any zip programme. Just adjust the compression rate from normal to best.
Most zip programmes (ie. Winzip) default to normal compression rate, for speed and size.  Higher compression rates take longer.

I use WinRar to compress my files. WinRar hanldes most compression files (ie. Rar, Ace, Iso, Zip, etc.)  and it has a higher compression rates then that of  a zip file.  It also allows you to split a large compressed file into smaller chunks for emailing and archiving. You can also adjust the rar compression rate too, but the remember the higher the comprssion rate the longer it takes.

A Rar file is like the jpeg to the Gif file.
:D
AutoCAD 2010, w/ OpenDCL

visit: http://reachme.at/spd_designs

JohnK

  • Administrator
  • Seagull
  • Posts: 10634
bzip yoiur dwg's
« Reply #4 on: July 20, 2004, 12:53:19 PM »
Bzip2 has the best compression ive seen todate. (And thats at default compression level.) You should give it a try.

I use WinRAR too. (Its better then winZIP, but not better then Bzip2.)

My order is: (Worst -> Best)

Winzip
Gzip
WinRAR
Bzip2
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

Mark

  • Custom Title
  • Seagull
  • Posts: 28762
bzip yoiur dwg's
« Reply #5 on: July 20, 2004, 01:17:02 PM »
True, rar does have better compression. The only draw back that I can see is the fact that it's shareware.
Code: [Select]

size (in bytes)                 size/type        size/type        size/type
57,435,478 (2005 version dwg)   49,113,643/.rar  49,975,267/.bz2  51,453,701/.zip
 2,312,632 (ascii file)         679,646/.rar     780,115/.bz2     690,110/.zip


Commands used
rar a <file>.rar <file>.ext (didn't see a compression level switch)
bzip2 --best <file>
zip -p <file>.zip <file>.ext


Software used:
RAR 3.30  Copyright (c) 1993-2004 Eugene Roshal 22 Jan 2004 Shareware version

bzip2 Copyright (C) 1996-2002 by Julian Seward. Version 1.0.2, 30-Dec-2001.

Zip 2.3 Copyright (C) 1990-1999 Info-ZIP (November 29th 1999).


Original output of 'dir'

 Volume in drive C has no label.
 Volume Serial Number is 3447-42B5

 Directory of C:\Temp\zip_test

07/20/2004  12:56 PM    <DIR>          .
07/20/2004  12:56 PM    <DIR>          ..
05/26/2004  07:47 AM        57,435,478 dwg.dwg
05/26/2004  07:47 AM        49,975,267 dwg.dwg.bz2
07/20/2004  12:21 PM        49,113,643 dwg.rar
07/20/2004  12:28 PM        51,453,701 dwg.zip
11/01/2002  06:54 AM         2,312,632 Unabr.dict
11/01/2002  06:54 AM           780,115 Unabr.dict.bz2
07/20/2004  12:18 PM           679,646 Unabr.rar
07/20/2004  12:29 PM           690,110 Unabr.zip
              11 File(s)    310,896,691 bytes
               2 Dir(s)  26,925,305,856 bytes free


Original output of 'ls -lh'

total 297M
-rw-rw-rw-    1 pw2n     0            2.2M Nov  1  2002 Unabr.dict
-rw-rw-rw-    1 pw2n     0            762k Nov  1  2002 Unabr.dict.bz2
-rw-rw-rw-    1 pw2n     0            664k Jul 20 12:18 Unabr.rar
-rw-rw-rw-    1 pw2n     0            674k Jul 20 12:29 Unabr.zip
-rw-rw-rw-    1 pw2n     0             55M May 26 07:47 dwg.dwg
-rw-rw-rw-    1 pw2n     0             48M May 26 07:47 dwg.dwg.bz2
-rw-rw-rw-    1 pw2n     0             47M Jul 20 12:21 dwg.rar

-rw-rw-rw-    1 pw2n     0             49M Jul 20 12:28 dwg.zip
TheSwamp.org  (serving the CAD community since 2003)

nivuahc

  • Guest
bzip yoiur dwg's
« Reply #6 on: July 21, 2004, 03:18:47 PM »
The only problem with your routine, Mark, is that if the user should have (heaven forbid) spaces in their directory or file name it will fail without warning.