Syntax
SG=SGTrename(SG,Norg,Nnew,[rm]);
Input Parameter
SG : | | Solid geometry |
Norg : | | Original name |
Nnew : | | New name |
rm : | | if true; existing frame Nnew is deleted first; default is false |
Output Parameter
SG : | | Solid geometry with changed frame name |
Examples
B=SGbox
B=SGTrename(B,'B','C')
B=SGTrename(B,'C','B')
B=SGTrename(B,'B','F')
B=SGTrename(B,'B','F',true)
Copyright 2020-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, SGTrename
, is designed to rename a frame within a solid geometry object. It is part of the SG-Library and was introduced in SolidGeometry 5.0.
Input Parameters
- SG: The solid geometry object that contains frames.
- Norg: The original name of the frame that needs to be renamed.
- Nnew: The new name for the frame.
- rm (optional): A boolean parameter. If set to true, any existing frame with the name
Nnew
will be deleted before renaming. The default value is false.
Output
- SG: The solid geometry object with the frame name changed.
Algorithm Steps
- Retrieve the
rm
parameter using getfuncparams
. If not provided, default to false.
- Find the index of the frame with the name
Nnew
in SG.Tname
.
- Find the index of the frame with the name
Norg
in SG.Tname
. If not found, throw an error indicating the frame does not exist.
- Check if a frame with the name
Nnew
already exists:
- If it exists and
rm
is false, throw an error indicating the frame already exists.
- If it exists and
rm
is true, call SGTremove
to remove the existing frame with the name Nnew
.
- Rename the frame by updating
SG.Tname
at the index of Norg
to Nnew
.
- If no output is requested (
nargout==0
), plot the solid geometry using SGfigure
and SGTplotalpha
.
Example Usage
The function can be used as follows:
B = SGbox;
B = SGTrename(B, 'B', 'C');
B = SGTrename(B, 'C', 'B');
B = SGTrename(B, 'B', 'F');
B = SGTrename(B, 'B', 'F', true);
In these examples, a solid geometry object B
is created and its frame names are changed using SGTrename
.
Algorithm explaination created using ChatGPT on 2025-08-19 01:20. (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