Attributes

class pcsg.tree.Attributes(attributes=None)

Bases: pcsg.immutable.DataObject

Attributes are immutable dictionaries describing rendering attributes of a csg Item.

cameraAttributes()

Get camera settings from Attributes object. See camera attributes for more details.

static defaults()

Returns a default attribute set.

get(key)

Get attribute by key. Returns None if the attribute is not set.

getAttribute(key, defaultValue=None, typeAssert=None)

Reads a value from the attributes map, may returns a default value.

merge(childAttributes)

Merges this attribute set with the child attributes and retruns a new instance.

override(assignments: dict)

Creates a copy of this attributes object with altered values.

rasterizingAttributes()

Returns the resolved rasterizing attributes as tuple: (minAngle, minSize, fixedCount, minSlices). Note: not all values may be returned, None is also acceptable for undefined values. See rasterizing attributes for more details.

renderAttributes()

Returns the resolved render attributes from an Attributes object. See render attributes for more details.

Rasterizing Attributes

Rasterizing attributes are used by the materializers and renderers when a geometry gets converted into a Polygon or Polyhedron. Rasterizing attributes are evaluted for each Item.

{
    # Minimum angular accuracy for rasterizing in degree.
    # Data type: positive float.
    'rasterize.minAngle':       1,

    # Maximum size error in units.
    # Data type: positive float.
    'rasterize.minSize':        0.01,

    # Rasterize with fixed number of segments.
    # Data type: positive integer.
    'rasterize.fixedCount':     None,

    # Number of slices for rasterizing LinearExtrude's.
    # Data type: positive integer.
    'rasterize.fixedSlices':    None
}

Render Attributes

Render attributes are used when rendering images. The renderer will get the rendering attributes from the root csg tree Node.

{
    # Size of rendered image.
    # Data type: positive integer.
    'render.width':             800,
    'render.height':            600,

    # Rendering quality. Higher values mean better quality.
    # Data type: integer in range 1 to 12.
    'render.quality':           1,
    'render.antialias':         1,

    # OpenScad rendering decoration attributes.
    # Data type: boolean.
    'render.view.axis':         False,
    'render.view.scales':       False,
    'render.view.crosshairs':   False,

    # Color scheme for OpenScad.
    # Data type: string.
    'render.colorScheme':       "PcsgTheme"
}

Camera Attributes

Camera attributes are used when rendering images. The renderer will get the camera attributes from the root csg tree Node.

{
    # Camera view vector.
    # Data type:
    #
    # tuple (
    #     eyeX,
    #     eyeY,
    #     eyeZ,
    #     centerX,
    #     centerY,
    #     centerZ
    # )
    #
    # or:
    #
    # tuple (
    #     translateX,
    #     translateY,
    #     translateZ,
    #     rotateX,
    #     rotateY,
    #     rotateZ,
    #     distance
    # )
    'camera.view':              None,

    # Camera projection type:
    # Data type: string-option:
    #     "orthogonal",
    #     "perspective"
    'camera.projection':        "perspective"
}