selection.py — Selection Module

Wraps SpinFire.Scripting.API.Utilities.SelectionUtilities. Provides interactive, prompt-driven selection of geometry from the active SpinFire view.

Function

Parameters

Returns

Description

SelectPoint(message='')

message (str, optional) — dialog prompt

The selected point, or None. Its type hasn’t been confirmed yet.

Prompts the user to pick a point.

SelectEdge(message='')

message (str, optional) — dialog prompt

Edge — Points — or None

Prompts the user to pick an edge.

SelectSurface(message='')

message (str, optional) — dialog prompt

A surface with Points and VertexNormals, or None

Prompts the user to pick a surface.

What the Results Hold

  • Edge (SpinFire.Scripting.API.Geometry.Edge). Its only data member is Points, the points along the edge in order. It prints as a list such as [14.48, -26.51, 5.45] mm. This was confirmed by the probe. Sample 15 uses it.

  • Surface. Points holds the vertices and VertexNormals the normal at each vertex, in the same order. Each point and normal has .X, .Y, .Z. This is used by Sample 06 and Sample 08, and by the built-in Calculate Cylindrical Radius sample. The surface’s type name and any other members haven’t been probed.

  • Point. Not yet probed. Sample 05 reads it by trying .X/.Y/.Z, then a Point, Position or Location member, then indexing.

Coordinates are in the model’s units (mm for Filter.CATPart).

Usage

 1import spinfirescript as sfs
 2
 3point = sfs.SelectPoint('Select a point.')
 4edge = sfs.SelectEdge('Select an edge.')
 5surface = sfs.SelectSurface('Select a surface.')
 6
 7if edge is not None:
 8    print(f"Edge has {len(list(edge.Points))} points")
 9if surface is not None:
10    print(f"Surface has {len(list(surface.Points))} vertices")

Each function returns None if the user cancels the selection dialog without picking anything. Check for this before using the result, as the samples do.