Thank you for your reply.microelly2 wrote: ↑Thu Oct 25, 2018 8:38 amThe better way ist to use a separate database file.
there is a way to hold data in excel files und get access with
the openpyxl module.
the execle files can be modified with libre office too, so you need not the uso of proprietary software.
Code: Select all
import zipfile import xml.etree.ElementTree as ET file = App.ActiveDocument.FileName file = file[:file.rfind("/")] #Then, I open the imported source part in the assembly document. file = zipfile.ZipFile(file+App.ActiveDocument.Ca__o_30x40x665_001.sourceFile, 'r') xml = file.read('Document.xml') tree = ET.ElementTree(ET.fromstring(xml)) file.close() root = tree.getroot() Objects = root.findall('ObjectData/Object') #List of all objects in the FreeCAD document #I look for the value of the property Length and print its value Property = Objects.findall("Properties/Property/Float") value = Property .get("value") #I get the property value of the source file Print value
I'm glad you can be of service.
In any case, this is an interesting approach. I will do some experiments too. Perhaps we can generate at minimum a partsList/BOM by this way.dcapeletti wrote: ↑Thu Oct 25, 2018 2:34 pmLook what I have done. In this video https://peertube.video/videos/watch/685 ... 35cd9263a9 I consult information about a FreeCAD model used in an assembly, without opening the source file. Directly using python and the path provided by A2Plus, I consult the length of the pad.
While what I have done for a very quick test, I think it might be a valid method to consult directly in the Document.xml.
What do you think?