pyoptools.misc.plist package

Submodules

Module contents

class pyoptools.misc.plist.plist

Bases: dict

Class representing a surface or component list.

This class is designed to facilitate access to the internals of a system or component using a dictionary-like interface. It functions as a hybrid between a list and a dictionary, primarily operating as a dictionary but with an append method similar to a list. Each item must be a tuple (O, P, D), where:

  • O is an object (limited to Surfaces, Components, or Systems in pyoptools).

  • P is a position vector (array, tuple, or list).

  • D is a direction vector (array, tuple, or list).

When creating the list from a list or tuple, as no key is provided, the class automatically generates a key using S# for Surfaces or C# for Components and Systems, where # is an incrementing number. When created from a dictionary or another plist, the same keys from the original data are used.

Parameters:

items (list, tuple, dict, or plist, optional) – A collection of (O, P, D) tuples or (O, P, D, Key) tuples/lists. This can be provided as a list, tuple, dictionary, or plist.

Notes

This class uses the dict interface, allowing the use of string keys. It inherits from dict but adds additional functionality like automatic key generation and an append method.

append(item)

Append an item to the plist, similar to how items are appended to a list.

The key is auto-generated based on the type of the object.

Parameters:

item (tuple) – A tuple containing the object, position, and rotation. The object must be an instance of Surface, Component, or System.

Raises:

TypeError – If the object is not an instance of Surface, Component, or System.