STPZ import error
Forum rules
and Helpful information
and Helpful information
IMPORTANT: Please click here and read this first, before asking for help
Also, be nice to others! Read the FreeCAD code of conduct!
Also, be nice to others! Read the FreeCAD code of conduct!
STPZ import error
Hi,
I'm trying to open in FreeCAD some STPZ files created on Autodesk Inventor.
When I open the STPZ file I get this error in the report window:
stpZ version 1.3.2
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "C:\Program Files\FreeCAD 0.18\Mod\Import\stepZ.py", line 78, in open
file_content = f.read()
File "C:\Program Files\FreeCAD 0.18\bin\lib\gzip.py", line 276, in read
return self._buffer.read(size)
File "C:\Program Files\FreeCAD 0.18\bin\lib\gzip.py", line 463, in read
if not self._read_gzip_header():
File "C:\Program Files\FreeCAD 0.18\bin\lib\gzip.py", line 411, in _read_gzip_header
raise OSError('Not a gzipped file (%r)' % magic)
<class 'OSError'>: Not a gzipped file (b'PK')
I attached a test file brick.stpz (a simple 30x40x10mm brick) that shows the problem.
I also attached a .stp version of the same model (brick.stp), that works well.
Is it a bug? If yes, is it a FreeCAD or an Inventor bug?
My FreeCAD informations:
OS: Windows 10
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.18.16117 (Git)
Build type: Release
Branch: releases/FreeCAD-0-18
Hash: dbb4cc6415bac848a294f03b80f65e888d531742
Python version: 3.6.6
Qt version: 5.6.2
Coin version: 4.0.0a
OCC version: 7.3.0
Locale: Italian/Italy (it_IT)
Thank you.
Best regards,
MarcoA
I'm trying to open in FreeCAD some STPZ files created on Autodesk Inventor.
When I open the STPZ file I get this error in the report window:
stpZ version 1.3.2
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "C:\Program Files\FreeCAD 0.18\Mod\Import\stepZ.py", line 78, in open
file_content = f.read()
File "C:\Program Files\FreeCAD 0.18\bin\lib\gzip.py", line 276, in read
return self._buffer.read(size)
File "C:\Program Files\FreeCAD 0.18\bin\lib\gzip.py", line 463, in read
if not self._read_gzip_header():
File "C:\Program Files\FreeCAD 0.18\bin\lib\gzip.py", line 411, in _read_gzip_header
raise OSError('Not a gzipped file (%r)' % magic)
<class 'OSError'>: Not a gzipped file (b'PK')
I attached a test file brick.stpz (a simple 30x40x10mm brick) that shows the problem.
I also attached a .stp version of the same model (brick.stp), that works well.
Is it a bug? If yes, is it a FreeCAD or an Inventor bug?
My FreeCAD informations:
OS: Windows 10
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.18.16117 (Git)
Build type: Release
Branch: releases/FreeCAD-0-18
Hash: dbb4cc6415bac848a294f03b80f65e888d531742
Python version: 3.6.6
Qt version: 5.6.2
Coin version: 4.0.0a
OCC version: 7.3.0
Locale: Italian/Italy (it_IT)
Thank you.
Best regards,
MarcoA
- Attachments
-
- brick.stp
- (9.07 KiB) Downloaded 32 times
-
- brick.stpz
- (2.81 KiB) Downloaded 36 times
Re: STPZ import error
Obviously the file is compressed in ZIP format while for STPZ files FreeCAD expects GZ compression. So, if the STPZ format specification doesn't allow the ZIP compression then it's an Inventor bug.Is it a bug? If yes, is it a FreeCAD or an Inventor bug?
Re: STPZ import error
After a quick search I found this document https://www.cax-if.org/documents/rec_pr ... on_v11.pdf and it says ZIP is the compression format and doesn't even mention GZ (aka GZIP).
But according to the above PDF file the stpZ file created by Inventor violates the rule 3.2:
Any idea if both compression formats are allowed?easyw-fc wrote: ping @easyw-fc
But according to the above PDF file the stpZ file created by Inventor violates the rule 3.2:
The file inside brick.stpz is called ISO-10303-21.txt instead of brick.stpThe most important rules for the STEP file compression concept are:
- There shall be only a single STEP file in each compressed file.
- The name of the STEP file,and the name of the STEP compressed file shallbe the same,i.e. “sample_123.stp” will be compressed in “sample_123.stpZ”
Re: STPZ import error
AFAIK, StpZ format is specified by PKWare, which (smartly) states that un/-compression is PKZIP.
PKZIP can uncompress GZIP, but I doubt the opposite is true.
As a side note, GZIP stands for GnuZIP and is basically the Deflate ZIP implementation for the Gnu world.
PKZIP can uncompress GZIP, but I doubt the opposite is true.
As a side note, GZIP stands for GnuZIP and is basically the Deflate ZIP implementation for the Gnu world.
Re: STPZ import error
Thank you for your reply!
Here I found that the document used as reference should be this.
Chapter 3.1 says:
3.1 Compression Algorithm
All compressed STEP files shall be written using the ZIP compression algorithm according to PKZI Pversion 2.05. The ZIP file format is being developed by PKWARE, who release the file format specification in the public domain (see [2] ). This compression format is well-established and widely used. It is, among others, compatible with:
- pkzip/pkunzip
- Windows Compressed Folders
- winzip,
- info-zip
- zlib
- Mac OS X (10.3 and higher)
This algorithm is used in Part 21 Edition 3, as well as by the IFC format in the building industry.
The same compression mechanism shall be used for the compression of Part 21 as well as Business Object Model XML files.
Many CAx-IF members however use GZip / Zlib for compression. PKZip libraries can read GZip files; the differences are only in the file header. Both shall be supported on import. PKZip allows for additional features such as folder/file structures (see section 3.2 below). Note that in accordance with Part 21 Edition 3 AnnexA.4 ,the compressed file shall not be encrypted.
It seems that both gzip and zip should be supported on import. Maybe that's why Inventor can read stpz file generated by FreeCAD, but not vice versa?
Thank you.
Best regards,
MarcoA
Re: STPZ import error
@wmayer, I was going to reply but you were faster
As from the 'stpz' recommendations
'STEP file compression documentation rec_prac_file_compression_v12.pdf'
@page 4 both gzip & zlib should be supported...
in FC we have gzip and zlib as python libraries...Many CAx-IF membershoweveruse GZip / Zlib for compression. PKZip libraries can read GZip files;the differences are only in the file header. Both shall be supported on import. PKZip allows for additional features such as folder/file structures (see section 3.2below).
Then the importer should/could be improved...
@wmayer, you were faster again
Anyway we could try to improve compatibility with other CAD sw allowing this style of compression and data format...
Hi @MarcoA would you mind to post here some .stpz quite complex Inventor generated files?
I had no many examples to test the importer when I developed...
Last edited by easyw-fc on Wed Jul 03, 2019 4:45 pm, edited 1 time in total.
Re: STPZ import error
According to https://en.wikipedia.org/wiki/PKZIP the following formats are supported since PKZIP 7.0:
PKZIP 7.0 changed SES to use non-OAEP key wrapping for compatibility with smart cards and USB tokens. Support of creating AV authenticity verification archives was dropped. PKZIP could now create archives of the following types: ZIP, bzip2, GZIP, tar, UUEncoded, XXEncoded.
Re: STPZ import error
According the Cax-If document, StpZ shall be compressed with PKZIP 2.05.
Re: STPZ import error
Weird... Linux gzip manpage tells that gunzip can uncompress files generated with zip (with automatic recognition), and zip manpage tells it's compatible with PKZIP 2.04...
Re: STPZ import error
Hi @MarcoA
would you mind to test with this modified importer?
EDIT: check the next post...
You need to close FC and copy stepZ.py (after having renamed the previous file) to:
i.e. C:\Program Files\FreeCAD\Mod\Import folder
This version should work with your file and allows to read also more than a single file inside the stpz archive
EDIT
zipfile doesn't work with this Bracket.stpZ.zip Catia zipped file I used as a sample to build my importer...
(The file 'Bracket.stpZ.zip' has to be unzipped to 'Bracket.stpZ' to test the Importing.)
I need to improve the importer
Last edited by easyw-fc on Thu Jul 04, 2019 7:59 am, edited 1 time in total.