flexsim_import_shape
Assign a 3D shape file to an existing object by loading, indexing, and applying the model in one step (window backend only).
Instructions
Import a 3D shape file onto an existing object (window backend only).
Receta verificada en Commands.xml local (FlexSim 2026,
help/CommandReference/Commands.xml; usar EXACTAMENTE estos comandos y firmas):
- loadthreedobject(str file, str name)->num "Load a 3D model directly...
recorded in Media List" (el cargador; paths con / simples).
Ejemplo XML: loadthreedobject("c:/myshape.wrl","myshape")
- getshapeindex(str name) con DOBLE backslash obligatorio ("The file path
name used in this command must use double backslashes as shown in the
example"). Ejemplo XML: getshapeindex("fs3d\\Operator\\BasicOperator\\Chest.3ds");
- setobjectshapeindex(obj object, num index) + verificacion
getobjectshapeindex(obj object). Ejemplo XML:
setobjectshapeindex(item,getshapeindex("fs3d\\Processor.3ds"));
ejemplo get: getobjectshapeindex(item);
- truncatemediapath(str path) para reportar como quedo referenciado
("If this file exists relative to the model directory, then the path
will be truncated to be relative to the model directory").
- applyshapefactors(obj object) tras set de o.size.x/y/z ("This command
applies all of the shape factors to the object if it has any").
Ejemplo XML: applyshapefactors(item);
Vecinas leidas antes de escribir: flexsim_create_objects (patron
require_gui + Model.find NULL-check + Object.create/name/setLocation +
check_script_safety por script + format_error), _last_link (helpers de
verificacion por colecciones), fs_string (citado de strings via json.dumps,
que produce el \\ doble en fuente FlexScript a partir de un valor con
\ simple) y require_gui (solo ventana).
Contrato: EXITO devuelve JSON {object, file, copied, shape_name,
shape_index, assigned_index, media_ref, size} (+ "warning" solo cuando
getshapeindex difiere del idx de load). ERRORES son texto plano
"Error:/Not found:/Blocked for safety:" como el resto de tools simples
(NO {"error":...}); el exito es el unico caso JSON.
Flujo: 1) existe objeto (Model.find NULL-check). 2) si
copy_next_to_model: destino = dir(_gui_model_path o _current_model)+nombre;
si el archivo ya esta ahi, no copiar; shutil.copyfile (Python, no
FlexScript) + reporta copied:true/false. 3) loadthreedobject(abs con
slashes, shape_name) -> idx; si idx==0 -> error "no cargo (formato? ver
lagunas)" SIN seguir. 4) getshapeindex(abs con \) debe == idx (si
difiere, warning pero sigue con idx de load). 5) setobjectshapeindex +
getobjectshapeindex de vuelta == idx -> si no, error. 6) set_size_xyz
se IGNORA a propósito (o.size rompe el render de importadas; escalar
el archivo con utility/scale_stl.py).
IMPORTANTE: asignaciones por script son POR SESIÓN (verificado
2026-09-27: tras guardar+reabrir no persisten). Usar manifiesto +
flexsim_apply_shapes al abrir el modelo.
Lagunas: escala real por verificar visual; reset puede revertir
textura (shape no documentado).
Args:
file_path: archivo existente; extension en {.skp,.fbx,.obj,.stl,.dae,
.3ds,.wrl,.x,.blend,.usd,.jt,.igs,.stp,.step,.glb} case-insensitive.
object: debe existir via Model.find, si no Not found.
shape_name: default = stem sanitizado [A-Za-z0-9_].
copy_next_to_model: default True.
set_size_xyz: aceptado pero ignorado (ver arriba).
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| params | Yes |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |