[solved] Creating a new .FCStd from Document.xml

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!
foadsf
Posts: 102
Joined: Fri Mar 06, 2015 10:02 pm
Contact:

[solved] Creating a new .FCStd from Document.xml

Post by foadsf »

Following this discussion, I'm interested to know if I can directly edit the Document.xml file and then generate a .FCStd file as explained here. I followed the instructions Tools → Project utility... Extract to unarchive the .FCStd file:
test.FCStd
(4.43 KiB) Downloaded 107 times
Document.xml
(7.73 KiB) Downloaded 151 times
and then Tools → Project utility... Create project and selecting the Document.xml file to create back the .FCStd file:
project.fcstd
(1011 Bytes) Downloaded 117 times
However the generated .FCStd file has some hidden parts in which their visibility can't be toggled:
Document.xml
(7.73 KiB) Downloaded 151 times
Attachments
Untitled.gif
Untitled.gif (190.56 KiB) Viewed 3122 times
Last edited by foadsf on Fri Oct 11, 2019 8:44 pm, edited 1 time in total.
openBrain
Veteran
Posts: 9034
Joined: Fri Nov 09, 2018 5:38 pm
Contact:

Re: Creating a new .FCStd from Document.xml

Post by openBrain »

Just "Mark to recompute" then F5 the document and everything's fine. ;)
Maybe the BREP aren't created in the FCStd file when generated.
foadsf
Posts: 102
Joined: Fri Mar 06, 2015 10:02 pm
Contact:

Re: Creating a new .FCStd from Document.xml

Post by foadsf »

openBrain wrote: Fri Oct 11, 2019 8:37 pm Just "Mark to recompute" then F5 the document and everything's fine. ;)
That was very quick! tanks a lot 🙂
openBrain wrote: Fri Oct 11, 2019 8:37 pm Maybe the BREP aren't created in the FCStd file when generated.
Is this a bug or expected behavior? should I open a bug report or feature request? 🤔
chrisb
Veteran
Posts: 53943
Joined: Tue Mar 17, 2015 9:14 am

Re: [solved] Creating a new .FCStd from Document.xml

Post by chrisb »

It sure is not a bug. Fumbling in the Document.xml is of course at your own risk.
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
foadsf
Posts: 102
Joined: Fri Mar 06, 2015 10:02 pm
Contact:

Re: [solved] Creating a new .FCStd from Document.xml

Post by foadsf »

chrisb wrote: Fri Oct 11, 2019 8:52 pm It sure is not a bug.
It doesn't seem like an expected behavior to me. I think it should take care of the recompute process upon opening automatically.

chrisb wrote: Fri Oct 11, 2019 8:52 pm Fumbling in the Document.xml is of course at your own risk.
Well, actually it is a very nice thing to fumble [with] 😁 Next step I want to see if I can include/import/nest another XML file inside the Document.xml and see if I can have some general parameters. If these are possible then one can have full code based CAD (AKA programmatic to generative design) using these XMLs 🧐
chrisb
Veteran
Posts: 53943
Joined: Tue Mar 17, 2015 9:14 am

Re: [solved] Creating a new .FCStd from Document.xml

Post by chrisb »

foadsf wrote: Fri Oct 11, 2019 9:01 pm It doesn't seem like an expected behavior to me.
Not everything that doesn't meet your expectations is a bug, see https://forum.freecadweb.org/viewtopic.php?f=3&t=5236.

I think it should take care of the recompute process upon opening automatically.
I would go even one step further: It would be nice if a FreeCAD model could be stored without any BRep information, which would make the file smaller at the cost of longer loading time, just as some kind of ultra compression mode.
That would make a nice feature request.

That having said, I still think your idea of generating a FreeCAD file is the only possibility to transfer a model from another CAD program including the modeling history.
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
User avatar
adrianinsaval
Veteran
Posts: 5541
Joined: Thu Apr 05, 2018 5:15 pm

Re: [solved] Creating a new .FCStd from Document.xml

Post by adrianinsaval »

foadsf wrote: Fri Oct 11, 2019 9:01 pm If these are possible then one can have full code based CAD (AKA programmatic to generative design) using these XMLs 🧐
Aren't most things achievable through macros? my understanding is that freecad macros are just python scripts so you can go wild with them, someone correct me if I'm wrong
foadsf
Posts: 102
Joined: Fri Mar 06, 2015 10:02 pm
Contact:

Re: [solved] Creating a new .FCStd from Document.xml

Post by foadsf »

chrisb wrote: Fri Oct 11, 2019 9:43 pm I would go even one step further: It would be nice if a FreeCAD model could be stored without any BRep information, which would make the file smaller at the cost of longer loading time, just as some kind of ultra compression mode.
That would make a nice feature request.
hmmm, 🤔 both have their own benefits. The current version is fast to load, especially if your design is really big and complicated. But the XML version is small. I wouldn't consider it as a form of compression or a huge advantage though. The main advantage IMO is the fact that one can use conventional version control such a git, mercurial, subversion ... which seems to be a huge feature lacking in the FC ecosystem at the moment. besides if there is any possibility to import/include/nest XMLs recursively into one another and if there are any possibilities to define parameters across the scop of an XML file, then theoretically one should be able to achieve full programmatic CAD using just XMLs.

I would say there should be an option in the FreeCAD settings to save files as it is right now or pure XML format. Also, this should be added to the import-export instead of the peculiar Tools → Project utility.

The way I see it is that the Document.xml represents geometry and GuiDocument.xml their graphical representation within the FreeCAD GUI. Somewhat similar, but not entirely accurate, to how HTML and CSS work.

chrisb wrote: Fri Oct 11, 2019 9:43 pm That having said, I still think your idea of generating a FreeCAD file is the only possibility to transfer a model from another CAD program including the modeling history.
Not sure what you mean by this. Would you please elaborate?
foadsf
Posts: 102
Joined: Fri Mar 06, 2015 10:02 pm
Contact:

Re: [solved] Creating a new .FCStd from Document.xml

Post by foadsf »

adrianinsaval wrote: Fri Oct 11, 2019 9:55 pm Aren't most things achievable through macros? my understanding is that freecad macros are just python scripts so you can go wild with them, someone correct me if I'm wrong
Well despite my love for Python, designing in FreeCAD using just its Python API has its own limitations. See my workflow for designing a new concept is first pen and paper (I would love to have something like Blender's Grease Pencil, but we yet to have that). Then I will start designing in the GUI putting values intuitively. while the design matures I will create a spreadsheet and add all the values in the spreadsheet to make the design parametric as much as possible. Now I could save the entire procedure as a Python macro but due to the many trials and errors, you would end up with a crazy amount of spaghetti Python code which requires psychic powers to decrypt and organize. And there is no guarantee that it works all the time (e.g., here). Plus being a scripting interpreted language comes with its own limitations. especially if you want to solve systems of algebraic ordinary or partial differential equations.

This discussion with Matt Keeter, the creator of libfive which uses Guile, and this discussion with whitequark, the maintainer of SolveSpace who envisions a Lua integration, might also be interesting.
chrisb
Veteran
Posts: 53943
Joined: Tue Mar 17, 2015 9:14 am

Re: [solved] Creating a new .FCStd from Document.xml

Post by chrisb »

foadsf wrote: Sat Oct 12, 2019 10:20 am
chrisb wrote: Fri Oct 11, 2019 9:43 pm your idea of generating a FreeCAD file is the only possibility to transfer a model from another CAD program including the modeling history.
Not sure what you mean by this. Would you please elaborate?
There is already a possibility to transfer models from Catia, SolidWorks, ... to FreeCAD and vice versa: STEP files. But these STEP models don't know anything about their modeling history, they have no sketches, no pads, no pockets. If you want to preserve this information you have to rebuild it in the target system.
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
Post Reply