Syntax
smbSetPosition(BName,[P,O,s])
Input Parameter
BName : | | Block name or gcs |
P : | | Position |
O : | | orientation('right','up','left','down'; default is is unchanged |
s : | | size; default is unchanged |
Examples
smbSetPosition(gcs,smbNewGridPos,'up')
Copyright 2016-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, smbSetPosition
, is designed to set the position, size, and orientation of blocks in a Simulink model. It is part of the SolidGeometry library and was introduced in version 3.0.
Input Parameters
- BName: The name of the block or the current system (gcs) in Simulink.
- P: The position of the block, specified as a two-element vector [x, y]. Default is [100, 100].
- O: The orientation of the block. Possible values are 'right', 'up', 'left', 'down'. The default is to leave it unchanged.
- s: The size of the block, specified as a two-element vector [width, height]. Default is [50, 40].
Algorithm Steps
- Initialize default values for position
P
, orientation O
, and size s
.
- Check if the user has provided a position. If so, update
P
with the provided value.
- Check if the user has provided an orientation. If so, update
O
with the provided value.
- Check if the user has provided a size. If so, update
s
with the provided value.
- If the size is not provided, calculate it based on the current block's position using
get_param
.
- If the orientation is not provided, retrieve the current orientation using
get_param
.
- Set the block's orientation using
set_param
with the updated or default orientation O
.
- Set the block's position using
set_param
with the updated or default position P
and size s
.
The function is designed to be flexible, allowing users to specify only the parameters they wish to change, while leaving others unchanged.
Algorithm explaination created using ChatGPT on 2025-08-19 00:15. (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