assemblyitems.py — Assembly Items Module

Wraps SpinFire.Scripting.API.Utilities.AssemblyItemUtilities. This is the largest module — it covers tree/assembly item queries, selection by path/name/type, appearance changes, and geometric transforms.

Enums

Enum

Values

RenderMode

Wireframe=0, HiddenLines=1, TriangleMesh=2, FlatShaded=3, SmoothShaded=4, SmoothWithEdges=5, Reflective=6, Metallic=7, SurfaceAnalysis=8

TreeItemType

Unknown=0, Scene=1, Model=2, Container=3, Part=4, Surface=5, Solid=6, OpenShell=7, Direction=8, Point=9, Set=10, Polyline=11, Polywire=12, DrawingRoot=13, View=14, Sheet=15

Queries

Function

Parameters

Returns

Description

GetPhysicalProperties()

none

PhysicalPropertiesData

Physical properties of the selected items.

GetProperties()

none

AssemblyItemPropertiesData

Properties of the selected items.

GetSelectedItems()

none

TreeItemsData — Items, Message

Info about the currently selected items. Prints as a numbered list, e.g. 0. Filter (Model).

GetChildren()

none

TreeParentItemsData — Items, Message

Children of the selected tree items. Prints as parent and children, e.g. Filter (Model): [Filter (Container)].

Selection & Naming

Function

Parameters

Returns

Description

RenameSelectedItem(name)

name (str)

ResultData

Renames the selected item.

SelectItem(path, clearSelection=True)

path (list[int]); clearSelection (bool)

str — the item name, or an error message

Selects an item by tree path. [0] is the model. A bad path doesn’t raise; it returns e.g. Failed to get child item with index ‘999’ at level ‘1’.

SelectItems(paths, clearSelection=True)

paths (list of list[int]); clearSelection (bool)

Collection of names/error messages

Selects multiple items by tree path.

SelectItemsByName(name, clearSelection=True)

name (str); clearSelection (bool)

Result message

Selects items matching a name.

SelectItemsByNames(names, clearSelection=True)

names (list[str]); clearSelection (bool)

Result message

Selects items matching several names.

SelectItemsByType(itemType, clearSelection=True)

itemType (TreeItemType); clearSelection (bool)

Result message

Selects items of a given type.

SelectItemsByTypes(itemTypes, clearSelection=True)

itemTypes (list[TreeItemType]); clearSelection (bool)

Result message

Selects items of several types.

SelectParentItemsByName(name, clearSelection=True)

name (str); clearSelection (bool)

Result message

Selects the parents of items matching a name.

SelectParentItemsByNames(names, clearSelection=True)

names (list[str]); clearSelection (bool)

Result message

Selects the parents of items matching several names.

ClearSelectedItems()

none

Result message (str)

Clears the current selection.

SelectItemsByName, SelectItemsByNames, SelectItemsByType and SelectItemsByTypes all call the same underlying AssemblyItemUtilities.SelectItems. They differ only in what they pass to it: one name, a list of names, one type, or a list of types.

Appearance

Function

Parameters

Returns

Description

SetFrontAndBackColors(colorText)

colorText (str ARGB, e.g. '#FFAABBCC')

Result message

Sets both front and back color.

SetFrontColor(colorText)

colorText (str ARGB)

Result message

Sets front color only.

SetBackColor(colorText)

colorText (str ARGB)

Result message

Sets back color only.

SetRenderMode(renderMode)

renderMode (RenderMode)

Result message

Sets the render mode of the selected items.

SetTransparency(transparency)

transparency (int)

Result message

Sets transparency of the selected items.

Transforms

Function

Parameters

Returns

Description

MoveSelectedAssemblyItems(x, y, z, coordinateSystem=0)

x,``y``,``z`` (float); coordinateSystem (str/int)

Result message

Translates the selected items.

RotateSelectedAssemblyItems(axis, directedAngle, coordinateSystem=0)

axis (Axis); directedAngle (float, degrees); coordinateSystem (str/int)

Result message

Rotates the selected items.

ScaleSelectedAssemblyItems(x, y, z, coordinateSystem=0)

x,``y``,``z`` (float, per-axis factors); coordinateSystem (str/int)

Result message

Non-uniform scaling.

UniformScaleSelectedAssemblyItems(uniformScaling, coordinateSystem=0)

uniformScaling (float); coordinateSystem (str/int)

Result message

Uniform scaling.

FromToSelectedAssemblyItems(fromCoordinateSystem, toCoordinateSystem)

both str/int

Result message

Transforms selected items from one coordinate system to another.

MirrorSelectedAssemblyItems(plane, coordinateSystem=0)

plane (Plane); coordinateSystem (str/int)

Result message

Mirrors the selected items through a plane.

Points & Bounding Box

Function

Parameters

Returns

Description

ExportAllPoints(path=None)

path (str, optional)

Result message

Exports all points.

ExportSelectedPoints(path=None)

path (str, optional)

Result message

Exports the selected points.

CreateAxisAlignedBoundingBox(showPanel=False)

showPanel (bool) — shows the measurement panel

ResultData

Creates an axis-aligned bounding box around the selected item(s).

Usage

 1import spinfirescript as sfs
 2
 3sfs.SelectItemsByType(sfs.TreeItemType.Surface)
 4print(sfs.GetSelectedItems())
 5
 6sfs.SetRenderMode(sfs.RenderMode.Metallic)
 7sfs.SetTransparency(50)
 8sfs.MoveSelectedAssemblyItems(10.0, 10.0, 10.0)
 9sfs.RotateSelectedAssemblyItems(sfs.Axis.Y, 20.0)
10print(sfs.CreateAxisAlignedBoundingBox())