Skip to content

SectionManager

SectionManager

SectionManager(mesh_maker: Model)

Local manager for Section lifecycle and tag assignment.

The manager is intentionally not a singleton. Each instance owns an independent tag space so future model or Model instances can keep their own section collections.

Create an empty manager with tags starting at 1.

Parameters:

Name Type Description Default
mesh_maker Model

The owning Model instance.

required

Raises:

Type Description
TypeError

If mesh_maker is not a Model instance.

RuntimeError

If the Model already owns a SectionManager.

Attributes

_section_types class-attribute instance-attribute

_section_types: Dict[str, Type[Section]] = {}

_builtins_loaded class-attribute instance-attribute

_builtins_loaded = False

_mesh_maker instance-attribute

_mesh_maker = mesh_maker

_sections instance-attribute

_sections: Dict[int, Section] = {}

_names instance-attribute

_names: Dict[str, Section] = {}

_start_tag instance-attribute

_start_tag = 1

_tagging instance-attribute

_tagging = CompactRetagPolicy[Section]()

beam instance-attribute

beam = _BeamSectionNamespace(self)

composite instance-attribute

composite = _CompositeSectionNamespace(self)

fiber instance-attribute

fiber = _FiberSectionNamespace(self)

shell instance-attribute

shell = _ShellSectionNamespace(self)

special instance-attribute

special = _SpecialSectionNamespace(self)

Methods:

add

add(section: Section) -> Section

Add an existing section and assign a tag if needed.

Parameters:

Name Type Description Default
section Section

Unmanaged or already-managed Section instance.

required

Returns:

Type Description
Section

The same section instance after it is stored by this manager.

Raises:

Type Description
TypeError

If section is not a Section instance.

ValueError

If its preassigned tag conflicts or name is duplicate.

get

get(identifier: Union[int, str]) -> Optional[Section]

Return the section with tag or user_name if it exists.

Parameters:

Name Type Description Default
identifier Union[int, str]

Section tag (int) or name (str) to look up.

required

Returns:

Type Description
Optional[Section]

The matching Section instance, or None.

get_all

get_all() -> Dict[int, Section]

Return a shallow copy of all managed sections keyed by tag.

remove

remove(identifier: Union[int, str]) -> None

Remove a managed section and compact the remaining tags.

Parameters:

Name Type Description Default
identifier Union[int, str]

Tag or name of the section to remove. Missing sections are ignored.

required

clear

clear() -> None

Remove all sections and clear their assigned tags.

set_tag_start

set_tag_start(start_tag: int) -> None

Set the first tag used by this manager and retag existing objects.

Parameters:

Name Type Description Default
start_tag int

Positive integer for the first assigned tag.

required

Raises:

Type Description
ValueError

If start_tag is less than 1.

create_section

create_section(section_type: str, user_name: str, **section_params) -> Section

Create and manage a section by type name using the manager factory map.

This is the authoritative creation path for the active runtime. It ensures that the section is context-aware during its initialization so it can resolve materials and other dependencies without global state.

Parameters:

Name Type Description Default
section_type str

Registered section type name.

required
user_name str

Unique name for the section.

required
**section_params

Constructor arguments for the selected concrete class.

{}

Returns:

Type Description
Section

Managed Section instance.

Raises:

Type Description
KeyError

If section_type is not registered.

resolve_material

resolve_material(material_input: Union[int, str, Material, None]) -> Optional[Material]

Resolve a material using the manager's Model context.

_reassign_tags

_reassign_tags() -> None

Retag all managed sections from _start_tag in tag order.

__len__

__len__() -> int

__iter__

__iter__()

register_section_type classmethod

register_section_type(name: str, section_class: Type[Section]) -> None

Register a concrete section type for manager-owned creation.

_ensure_builtin_section_types_loaded classmethod

_ensure_builtin_section_types_loaded() -> None

Load bundled section families once so manager namespaces just work.

get_section_types classmethod

get_section_types() -> list[str]

Return section types registered on the active manager factory map.