SGdimofFilename

by Tim C. Lueth, SG-Lib Toolbox: SolidGeometry 5.6 - Auxiliary function
Introduced first in SolidGeometry 4.8, Creation date: 2019-10-25, Last change: 2025-09-14

returns the volume and size sorted dimensions from a SGarchivefilename

Description

Filenames mut fullfi the format:

'VOL=49540.5[54.5x45.0x20.2]V=1978F=4000'

See Also: SGarchivefilename , SGwriteSTLarchive , SGsizeofFilename

Example Illustration

 missing image of SGdimofFilename(fn)

Syntax

nvf=SGdimofFilename(fn)

Input Parameter

fn: filename in directory found by search

Output Parameter

nvf: returns the volume and size sorted dimensions is containing this information

Examples


fn=SGarchivefilename(SGservosample(3))
SGdimofFilename(fn), a=ans; a(2:end)




Copyright 2019-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, SGdimofFilename, is designed to extract volume and dimension information from a specific filename format used in the SolidGeometry library. The function processes filenames that adhere to a particular structure and returns the relevant numerical data.

Input Parameters

Output

Algorithm Steps

  1. The function begins by splitting the input filename fn using specific delimiters: 'VOL=', '[', 'x', and ']'. This is done using the split function, which breaks the string into parts based on these delimiters.
  2. The resulting parts are then converted to numerical values using str2double. This function attempts to convert each part of the split string into a double-precision number.
  3. Any non-numeric parts (which result in NaN values) are removed from the array b using logical indexing. This step ensures that only valid numbers are retained.
  4. The function checks the number of elements in the array b. If there are exactly four elements, it assigns these to nvf. These four elements represent the volume and the three dimensions extracted from the filename.
  5. If the number of elements is not four, the function returns false, indicating that the filename did not match the expected format.

This function is useful for parsing filenames that encode geometric information, allowing for easy extraction and use of this data in further processing or analysis.

Algorithm explaination created using ChatGPT on 2025-08-18 23:41. (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