FCStd file order sensitivity causes problems for me

Here's the place for discussion related to coding in FreeCAD, C++ or Python. Design, interfaces and structures.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Post Reply
User avatar
DeepSOIC
Veteran
Posts: 7896
Joined: Fri Aug 29, 2014 12:45 am
Location: used to be Saint-Petersburg, Russia

FCStd file order sensitivity causes problems for me

Post by DeepSOIC »

Hi!
I'm working on a FCStd-file reader/writer for part-o-magic. And while reading them is fairly straightforward, writing them proves to be quite a challenge.
Particularly, FreeCAD is sensitive to the order the files are written to the zip, and that causes quite some headache for me.

Initially, I thought that only Document.xml is required to be the very first file. Now it turns out, the whole order appears to be important.

For example, I repacked the project with file order changed (see attachment). It does open, but no shapes are loaded. And strangely, I don't notice any errors in console.

Code: Select all

original             |   rewritten
                     |   
Document.xml         |   Document.xml
PartShape.brp        |   GuiDocument.xml
PartShape1.brp       |   PartShape.brp
PartShape2.brp       |   PointColorArray
PartShape3.brp       |   LineColorArray
PartShape4.brp       |   DiffuseColor2
PartShape5.brp       |   PointColorArray5
GuiDocument.xml      |   PointColorArray4
DiffuseColor         |   PointColorArray1
LineColorArray       |   DiffuseColor5
PointColorArray      |   PartShape2.brp
DiffuseColor1        |   DiffuseColor3
LineColorArray1      |   LineColorArray5
PointColorArray1     |   PartShape1.brp
DiffuseColor2        |   DiffuseColor1
LineColorArray2      |   DiffuseColor4
PointColorArray2     |   PointColorArray2
DiffuseColor3        |   PartShape4.brp
LineColorArray3      |   LineColorArray1
PointColorArray3     |   LineColorArray3
DiffuseColor4        |   PointColorArray3
LineColorArray4      |   PartShape3.brp
PointColorArray4     |   PartShape5.brp
DiffuseColor5        |   LineColorArray2
LineColorArray5      |   LineColorArray4
PointColorArray5     |   DiffuseColor
Any chances this can be fixed?

OS: Windows 10
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.18.15518 (Git)
Build type: Release
Branch: master
Hash: e83c44200ab428b753a1e08a2e4d95e03236e481
Python version: 3.6.6
Qt version: 5.6.2
Coin version: 4.0.0a
OCC version: 7.3.0
Locale: Russian/Russia (ru_RU)
Attachments
rewrite.FCStd
(79.06 KiB) Downloaded 10 times
wmayer
Founder
Posts: 20303
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: FCStd file order sensitivity causes problems for me

Post by wmayer »

The order is
  1. Document.xml
  2. All data files of properties of DocumentObjects
  3. GuiDocument.xml
  4. All data files of properties of ViewProviders
The order of the data files in 2. and 4. can be arbitrary. See also: https://github.com/FreeCAD/FreeCAD/blob ... octools.py
User avatar
DeepSOIC
Veteran
Posts: 7896
Joined: Fri Aug 29, 2014 12:45 am
Location: used to be Saint-Petersburg, Russia

Re: FCStd file order sensitivity causes problems for me

Post by DeepSOIC »

wmayer wrote: Sun Jan 13, 2019 2:30 pm The order of the data files in 2. and 4. can be arbitrary
Thanks, that helps very much!
User avatar
wandererfan
Veteran
Posts: 6309
Joined: Tue Nov 06, 2012 5:42 pm
Contact:

Re: FCStd file order sensitivity causes problems for me

Post by wandererfan »

DeepSOIC wrote: Sun Jan 13, 2019 12:57 pm I'm working on a FCStd-file reader/writer for part-o-magic. And while reading them is fairly straightforward, writing them proves to be quite a challenge.
Just FYI, @kbwbe has been doing some work on reading FCStd files for A2plus. Some sharing might be possible.
kbwbe wrote: ping!
kbwbe
Veteran
Posts: 1052
Joined: Tue Apr 10, 2018 3:12 pm
Location: Germany, near Köln (Cologne)

Re: FCStd file order sensitivity causes problems for me

Post by kbwbe »

wandererfan wrote: Sun Jan 13, 2019 5:36 pm
DeepSOIC wrote: Sun Jan 13, 2019 12:57 pm I'm working on a FCStd-file reader/writer for part-o-magic. And while reading them is fairly straightforward, writing them proves to be quite a challenge.
Just FYI, @kbwbe has been doing some work on reading FCStd files for A2plus. Some sharing might be possible.
kbwbe wrote: ping!
Hi,
with A2p, i am only reading out document.xls, for generating partlists and recursive update of parts. There is no writing and repackaging.
KBWBE

https://github.com/kbwbe/A2plus
latest release: v0.4.56, installable via FreeCAD's addon manager
Tutorial: gripper assembly https://www.youtube.com/watch?v=QMxcQ5tssWk
Documentation: https://www.freecadweb.org/wiki/A2plus_Workbench
Post Reply