[Li...] Posted February 25 Share Posted February 25 Hello everyone ! I am currently stuck with an issue: I need to export dimensional data, such as the average, max, min etc... as an XML. I want to do it through a script. The real issue is that I need to have that file written in a particular way so that it can be understood by a third party software. It does not seem possible by using the script recorder in GOM. Any idea ? It has to look something like the attached file. Thank you. Link to comment Share on other sites More sharing options...
[Ma...] Posted February 26 Share Posted February 26 (edited) Hi, You create an XML file like this with the following Python script: import xml.etree.ElementTree as ET from xml.dom import minidom # Step 1: Create the root element root = ET.Element("ListOfMeas") # Step 2: Create child elements meas = ET.SubElement(root, "Meas") charac = ET.SubElement(meas, "Charac") charac.text = "THE CHARACTERISTIC I WANT TO EXPORT" val = ET.SubElement(meas, "Val") val.text = "777" # Step 3: Create an ElementTree object tree = ET.ElementTree(root) # Step 4: Convert to string and pretty-print xml_str = ET.tostring(root, encoding='utf-8', method='xml') parsed_xml = minidom.parseString(xml_str) pretty_xml_str = parsed_xml.toprettyxml(indent=" ") # Step 4: Write to an XML file with open("my_data.xml", "w", encoding='utf-8') as fh: fh.write(pretty_xml_str) You find the required elements using Selecting elements in scripts — App Development Documentation and then selecting the desired element properties (ZEISS INSPECT Python API Introduction — App Development Documentation - Access element properties). Instead of using a fixed filename as in the example above, you use Selecting a file or folder — App Development Documentation (ZEISS INSPECT 2025) or you create a dialog. Hope this helps! Best regards Matthias Edited February 26 Link to comment Share on other sites More sharing options...
[Li...] Posted February 27 Author Share Posted February 27 Thank you so much, I will try that ! Link to comment Share on other sites More sharing options...
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in