Syntax
text=SGread3MF(fname)
Input Parameter
Output Parameter
Copyright 2021-2025 Tim C. Lueth. All rights reserved. The code is the property of Tim C. Lueth and may not be redistributed or modified without explicit written permission. This software may be used free of charge for academic research and teaching purposes only. Commercial use, redistribution, modification, or reverse engineering is strictly prohibited. Access to source code is restricted and granted only under specific agreements. For licensing inquiries or commercial use, please contact: Tim C. Lueth
Algorithm (Workflow)
This function, SGread3MF
, is designed to read a 3MF file, which is a zip file containing a directory named "3D" with an XML file called "3dmodel.model". The function extracts and interprets this XML file.
Input Parameters
- fname: The filename of the 3MF file to be read.
Output Results
- text: The XML text extracted from the 3MF file.
Algorithm Steps
- Retrieve the filename using
getfuncparams
with a default value of an empty string.
- Use
tryuigetfile
to prompt the user to select a file if fname
is not provided.
- Ensure the filename ends with ".3mf". If not, append ".3mf" to the filename.
- Check if the file exists. If not, attempt to locate it in the desktop directory using
desktopdir
.
- If the file still cannot be found, raise an error indicating "file not found".
- Create a temporary directory named "SGread3MF_tmp" using
mkdir
and change the current directory to this temporary directory.
- Unzip the 3MF file into the temporary directory.
- Construct the path to the "3dmodel.model" file within the unzipped contents.
- Read the XML text from "3dmodel.model" using
readtextfile
.
- Return to the original directory and remove the temporary directory using
rmdir
.
- Convert the XML text to a Solid Geometry class object using
ms3Dmodel2SG
.
- If the output is a single cell, extract the content from the cell.
- If no output arguments are specified, plot the geometry using
SGfigure
and SGplotcell
.
Algorithm explaination created using ChatGPT on 2025-08-19 06:47. (Please note: No guarantee for the correctness of this explanation)
Last html export of this page out of FM database by TL: 2025-09-21