0.1.33
Loading...
Searching...
No Matches
pyhelios.PlantArchitecture Namespace Reference

Classes

class  PlantArchitecture
 High-level interface for plant architecture modeling and procedural plant generation. More...
 
class  PlantArchitectureError
 Raised when PlantArchitecture operations fail. More...
 

Functions

 validate_vec3 (value, name, func)
 
 validate_vec2 (value, name, func)
 
 validate_int2 (value, name, func)
 
None _validate_build_parameters (Optional[dict] build_parameters, Optional[str] plant_model)
 Reject build parameter keys the loaded plant model will not read.
 
str _resolve_user_path (Union[str, Path] filepath)
 Convert relative paths to absolute paths before changing working directory.
 
 _plantarchitecture_working_directory ()
 Context manager that temporarily changes working directory to where PlantArchitecture assets are located.
 
 is_plantarchitecture_available ()
 Check if PlantArchitecture plugin is available for use.
 
PlantArchitecture create_plant_architecture (Context context)
 Create PlantArchitecture instance with context.
 

Variables

 logger = logging.getLogger(__name__)
 
dict _BUILD_PARAMETERS_BY_MODEL
 
 _ALL_BUILD_PARAMETERS
 

Function Documentation

◆ _plantarchitecture_working_directory()

pyhelios.PlantArchitecture._plantarchitecture_working_directory ( )
protected

Context manager that temporarily changes working directory to where PlantArchitecture assets are located.

PlantArchitecture C++ code uses hardcoded relative paths like "plugins/plantarchitecture/assets/textures/" expecting assets relative to working directory. This manager temporarily changes to the build directory where assets are actually located.

Exceptions
RuntimeErrorIf build directory or PlantArchitecture assets are not found, indicating a build system error.

Definition at line 179 of file PlantArchitecture.py.

◆ _resolve_user_path()

str pyhelios.PlantArchitecture._resolve_user_path ( Union[str, Path] filepath)
protected

Convert relative paths to absolute paths before changing working directory.

This preserves the user's intended file location when the working directory is temporarily changed for C++ asset access. Absolute paths are returned unchanged.

Parameters
filepathFile path to resolve (string or Path object)
Returns
Absolute path as string

Definition at line 159 of file PlantArchitecture.py.

◆ _validate_build_parameters()

None pyhelios.PlantArchitecture._validate_build_parameters ( Optional[dict] build_parameters,
Optional[str] plant_model )
protected

Reject build parameter keys the loaded plant model will not read.

The native library looks each key up in a map and falls back to a default when it is absent, so an unrecognized key is silently discarded. Raising here instead keeps a misspelled or wrong-species parameter from being mistaken for one that took effect.

Parameters
build_parametersMapping supplied by the caller, or None.
plant_modelLabel of the currently loaded model, or None if no model has been loaded through this instance.
Exceptions
ValueErrorIf build_parameters is not a dict of str -> number, or contains a key the loaded model does not accept.

Definition at line 103 of file PlantArchitecture.py.

◆ create_plant_architecture()

PlantArchitecture pyhelios.PlantArchitecture.create_plant_architecture ( Context context)

Create PlantArchitecture instance with context.

Parameters
contextHelios Context
Returns
PlantArchitecture instance
Example
>>> context = Context() >>> plantarch = create_plant_architecture(context)

Definition at line 5033 of file PlantArchitecture.py.

◆ is_plantarchitecture_available()

pyhelios.PlantArchitecture.is_plantarchitecture_available ( )

Check if PlantArchitecture plugin is available for use.

Returns
bool True if PlantArchitecture can be used, False otherwise

Definition at line 247 of file PlantArchitecture.py.

◆ validate_int2()

pyhelios.PlantArchitecture.validate_int2 ( value,
name,
func )

Definition at line 38 of file PlantArchitecture.py.

◆ validate_vec2()

pyhelios.PlantArchitecture.validate_vec2 ( value,
name,
func )

Definition at line 30 of file PlantArchitecture.py.

◆ validate_vec3()

pyhelios.PlantArchitecture.validate_vec3 ( value,
name,
func )

Definition at line 22 of file PlantArchitecture.py.

Variable Documentation

◆ _ALL_BUILD_PARAMETERS

pyhelios.PlantArchitecture._ALL_BUILD_PARAMETERS
protected

Definition at line 83 of file PlantArchitecture.py.

◆ _BUILD_PARAMETERS_BY_MODEL

dict pyhelios.PlantArchitecture._BUILD_PARAMETERS_BY_MODEL
protected
Initial value:
1= {
2 "almond": frozenset({"trunk_height", "num_scaffolds", "scaffold_angle"}),
3 "almond_aldrich": frozenset({"trunk_height", "num_scaffolds", "scaffold_angle"}),
4 "almond_wood_colony": frozenset({"trunk_height", "num_scaffolds", "scaffold_angle"}),
5 "apple": frozenset({"trunk_height", "num_scaffolds", "scaffold_angle"}),
6 "grapevine_VSP": frozenset({"trunk_height", "vine_spacing"}),
7 "grapevine_wye": frozenset(
8 {"trunk_height", "vine_spacing", "cordon_spacing", "catch_wire_height"}
9 ),
10 "pistachio": frozenset({"trunk_height", "num_scaffolds", "scaffold_angle"}),
11 "walnut": frozenset({"trunk_height", "num_scaffolds", "scaffold_angle"}),
12}

Definition at line 65 of file PlantArchitecture.py.

◆ logger

pyhelios.PlantArchitecture.logger = logging.getLogger(__name__)

Definition at line 57 of file PlantArchitecture.py.