Formato dei file FCStd

From FreeCAD Documentation
Revision as of 18:59, 2 October 2020 by Renatorivo (talk | contribs) (Replaced content with "===Document.xml===")

Introduzione

Il Formato nativo dei file di FreeCAD (FreeCAD Standard file format) .FCStd è il formato principale dei file di FreeCAD. Si tratta di un formato composto che supporta la compressione e l'incorporamento di diversi tipi di dati.

Contenuto di un file .FCStd

FCStd è un file zip standard contenente uno o più file in una determinata struttura. Come tale, è possibile decomprimere un file .FCStd utilizzando un normale strumento di decompressione zip, mentre invece si deve stare attenti a impacchettare il contenuto di un file .FCStd. FreeCAD contiene una "Project Utility" per 'ripacchettare' i file .FCStd, il suo uso è descritto nel paragrafo sootttostante Modificare il codice sorgente del file .FCStd.

Document.xml

Questo è il file .xml principale che descrive tutti gli oggetti contenuti in un documento di FreeCAD. Descrive solo la definizione geometrica e parametrica degli oggetti, ma non la loro rappresentazione visiva. Se FreeCAD viene eseguito in modalità console (senza GUI), viene utilizzato solo questo Document.xml.

Esempio di Document.xml

<?xml version='1.0' encoding='utf-8'?>
 <Document SchemaVersion="4">
    <Properties Count="9">
       <Property name="Comment" type="App::PropertyString">
          <String value=""/>
       </Property>
       <Property name="Company" type="App::PropertyString">
          <String value=""/>
       </Property>
       <Property name="CreatedBy" type="App::PropertyString">
          <String value=""/>
       </Property>
       <Property name="CreationDate" type="App::PropertyString">
          <String value="Fri Jan 29 15:14:38 2010 "/>
       </Property>
       <Property name="FileName" type="App::PropertyString">
          <String value="/tmp/test.FCStd"/>
       </Property>
       <Property name="Id" type="App::PropertyString">
          <String value="201b746f-a1ed-4297-bf3d-65d5ec11abe0"/>
       </Property>
       <Property name="Label" type="App::PropertyString">
          <String value="names"/>
       </Property>
       <Property name="LastModifiedBy" type="App::PropertyString">
          <String value=""/>
       </Property>
       <Property name="LastModifiedDate" type="App::PropertyString">
          <String value="Fri Jan 29 15:15:21 2010 "/>
       </Property>
    </Properties>
    <Objects Count="2">
       <Object type="Mesh::Cube" name="Cube" />
       <Object type="Part::Box" name="Box" />
    </Objects>
    <ObjectData Count="2">
       <Object name="Cube">
          <Properties Count="7">
             <Property name="Height" type="App::PropertyFloatConstraint">
                <Float value="10"/>
             </Property>
             <Property name="Label" type="App::PropertyString">
                <String value="Cube"/>
             </Property>
             <Property name="Length" type="App::PropertyFloatConstraint">
                <Float value="10"/>
             </Property>
             <Property name="Mesh" type="Mesh::PropertyMeshKernel">
                <Mesh file="MeshKernel.bms"/>
             </Property>
             <Property name="Placement" type="App::PropertyPlacement">
                <PropertyPlacement Px="0" Py="0" Pz="0" Q0="0" Q1="0" Q2="0" Q3="1"/>
             </Property>
             <Property name="Pos" type="App::PropertyPlacementLink">
                <Link value=""/>
             </Property>
             <Property name="Width" type="App::PropertyFloatConstraint">
                <Float value="10"/>
             </Property>
          </Properties>
       </Object>
       <Object name="Box">
          <Properties Count="7">
             <Property name="Height" type="App::PropertyLength">
                <Float value="10"/>
             </Property>
             <Property name="Label" type="App::PropertyString">
                <String value="Box2"/>
             </Property>
             <Property name="Length" type="App::PropertyLength">
                <Float value="10"/>
             </Property>
             <Property name="Placement" type="App::PropertyPlacement">
                <PropertyPlacement Px="0" Py="0" Pz="0" Q0="0" Q1="0" Q2="0" Q3="1"/>
             </Property>
             <Property name="Pos" type="App::PropertyPlacementLink">
                <Link value=""/>
             </Property>
             <Property name="Shape" type="Part::PropertyPartShape">
                <Part file="PartShape.brp2"/>
             </Property>
             <Property name="Width" type="App::PropertyLength">
                <Float value="10"/>
             </Property>
          </Properties>
       </Object>
    </ObjectData>
 </Document>

GuiDocument.xml

Questa è la controparte GUI del file Document.xml. Per ogni oggetto descritto nel Document.xml, c'è un corrispondente oggetto in GuiDocument.xml il quale descrive la rappresentazione visiva di quell'oggetto (colore, larghezza di riga, ecc.)

Questa è la controparte GUI del file Document.xml. Per ogni oggetto descritto nel Document.xml, c'è un corrispondente oggetto in GuiDocument.xml il quale descrive la rappresentazione visiva di quell'oggetto (colore, larghezza di linea, ecc.)

Thumbnails/thumbnail.png

Si tratta di un'immagine di anteprima di 128x128 pixel del documento, che è uno screenshot della vista 3D in fase di salvataggio.

Le miniature vengono generate solo quando, nelle preferenze di FreeCAD, è attivata la corrispondente opzione.

Si tratta di un'immagine di anteprima di 128x128 pixel del documento, che è uno screenshot della vista 3D in fase di salvataggio. Le miniature vengono generate solo quando, nelle preferenze di FreeCAD, è attivata la corrispondente opzione.

Templates/*.svg

Nella cartella Templates vengono memorizzati i file dei modelli svg utilizzati nelle pagine di Disegno.

Nella cartella Templates vengono memorizzati i file dei modelli svg utilizzati nelle pagine di Disegno tecnico.

*.brep

Queste sono le forme B-rep di tutti gli oggetti che hanno una forma Parte in Document.xml. Ogni oggetto, anche se è parametrico, ha la sua forma memorizzata in un file .brep individuale, in modo che si può accedere ai suoi componenti senza la necessità di ricalcolarne la forma.

Queste sono le forme B-rep di tutti gli oggetti che hanno una forma Parte in Document.xml. Ogni oggetto, anche se è parametrico, ha la sua forma memorizzata in un file .brep individuale, in modo che si può accedere ai suoi componenti senza la necessità di ricalcolarne la forma.

Struttura

Struttura di un tipico file FCStd:

Structure of a typical .FCStd file. The extension can be changed to .zip to explore it like a normal directory. The Document.xml and GuiDocument.xml are at the root of the archive, together with any number of .brp (BREP) files. One subdirectory may hold the thumbnail, and another the SVG templates used by TechDraw.

File.FCStd (File.zip)
  |
  :--thumbnails/
     |
     :--Thumbnail.png
  |
  :--Templates/
     |
     :--MyPage.svg
  |
  :--Document.xml
  :--GuiDocument.xml
  :--Shape1.brp
  :--Shape2.brp
  :--etc.

Embedding other files

In order to embed other file types inside a FCStd file, you must first create a scripted object from the Python console, and give it an App::PropertyFileIncluded property.

Then in the property editor you can go to the added property and choose a file in the computer. Once the FCStd file is saved, the file assigned to the DatiPropertyFileIncluded property will be packed inside the .FCStd. When the document is restored, the same file will be restored with the DatiPropertyFileIncluded property.

custom_obj = App.ActiveDocument.addObject("App::FeaturePython", "CustomObject")
custom_obj.addProperty("App::PropertyFileIncluded", "AttachedFile")

See the forum thread, PDF inside the project.

Modificare il codice sorgente del file .FCStd

ATTENZIONE LAVORARE SEMPRE SU UNA COPIA DEL PROGETTO !

È possibile modificare un file originale FCStd, ma la procedura non è senza rischi, perciò si deve sempre lavorare su una copia.

Altri link

Un utile programma convertitore: ImageConv.