Definitions#

class mhi.pscad.Definition(*, _ctx: Context | None = None, _ident: Dict[str, Any] | None = None)#

Component Definition

property project_name: str#

The project which defines this definition (read-only)

property scope: str#

The project which defines this definition (read-only)

property name: str#

Name of the definition (read-only)

property scoped_name: str#

The scoped definition name is the project and definition names, separated by a colon (read-only)

property instances: int#

Number of live instances of this definition (read-only)

Added in version 2.8.

property xml#

XML for the Definition (read-only)

property form_codec: FormCodec#

The definition’s parameter form codec

is_module() bool#

Check to see if this component has its own canvas, with in turn, can contain additional components.

Returns:

True if the component has an internal canvas, False otherwise.

Return type:

bool

parameters(*, name=None, desc=None, url=None, group=None, tags=None) Dict[str, str] | None#

Set or get the definition’s parameters.

Parameters:
  • name (str) – The definition name. Must be unique, alphanumeric, and a maximum of 30 characters

  • desc (str) – A short description for the definition

  • url (str) – Location if loaded from an external resource

  • group (str) – One or more labels to describe group categorization (Comma separated)

  • tags (str) – One or more tags to help find this definition (Comma separated)

Returns:

A dictionary of parameter values (if no parameters are being set), or None.

compile() None#

Compile this component definition page

navigate_to() Canvas#

Attempt to navigate to the first instance if possible

Returns:

The definition’s canvas

Return type:

Canvas

set_view(view: str | View) None#

Activate the appropriate definition editor tab

Valid view tabs are one of the strings: “Schematic”, “Graphic”, “Parameters”, “Script”, “Fortran”, “Data”, or the equivalent View constant.

Parameters:

view – The desired view tab

canvas() Canvas#

Definition canvas

graphics() GfxCanvas#

Get the graphics canvas

Added in version 2.2.

copy() None#

Copy the definition to the clipboard.

property script#

The definition’s script sections are accessed with this property.

Examples:

checks = defn.script['Checks']       # Get script section
defn.script['Computations'] = "..."  # Add/Change script section
del defn.script['FlyBy']             # Delete script section

Added in version 2.2.