Scripting Examples
Here are a few simple examples that you can demonstrate on your licensed copy of SpinFire Insight.
Acquire full scripting help from within SpinFire Insighte using the Documentation menu item from the script menu.

The following shows simple examples of some scripting primitives
Get the Physical Properties of Items
The following demonstrates getting the physical properties of the assembly and printing to the console through scripting.
Usage
GetPhysicalProperties()
Parameters
none
List physical properties for model
1# First open a 3D model to execute this script
2# Open the python.NET console panel
3import spinfirescript as sfs
4
5sfs.SelectItem([])
6propertiesData = sfs.GetPhysicalProperties()
7print(propertiesData)
8print(propertiesData.Message)
Rotate the Entire Assembly
The following demonstrates selecting and rotating an assembly through scripting.
Usage
RotaeSelectedAssemblyItems(axis, degrees)
Parameters
axis: selectd the x, y, or z axis
degrees: amount to rotate in degrees
List physical properties for model
1# First open a 3D model to execute this script
2import spinfirescript as sfs
3
4for i in range(0,10):
5sfs.SelectItem([])
6sfs.RotateSelectedAssemblyItems(sfs.Axis.X, 30)
7sfs.RotateSelectedAssemblyItems(sfs.Axis.Y, 20)
8sfs.RotateSelectedAssemblyItems(sfs.Axis.Z, 45)
9sfs.ClearSelectedItems()
Insert a 2D Line
The following demonstrates creating 2D lines through scripting.
Usage
InsertLine(x-coord, y-coord, color, thickness)
Parameters
x-coord: starting x-coordinate.
y-coord: starting y-coordinate.
color: color as a string in the form “#AARRGGBB”
where AA is the alpha channel
RR is the red channel
GG is the green channel
BB is the blue channel
thickness: line thickness number > 0
2D Line Example code
1# First open a 2D workspace to execute this script
2import spinfirescript as sfs
3import random
4
5for i in range(1,10):
6newColor = "#FF"+''.join([random.choice('0123456789ABCDEF') for j in range(6)])
7sfs.InsertLine([0, (i+(i*4))*-1], [50, (i+(i*4))*-1], "#FF000000", i)
8sfs.InsertLine([100, (i+(i*4))*-1], [150, (i+(i*4))*-1], newColor, i)
Insert a 3D Polyline
The following demonstrates creating a 3D polyline through scripting.
Usage
InsertPolyline([x-coord 1, y-coord 1, z-coord 1], [x-coord 2, y-coord 2, z-coord 2], [x-coord n, y-coord n, z-coord n], color, thickness)
Parameters
x-coord: Starting x-coordinate.
y-coord: Starting y-coordinate.
z-coord: Starting z-coordinate.
color: color as a string in the form “#AARRGGBB”,
thickness: lne thickness number > 0
3D Polyline Example code
1# First open a 3D workspace to execute this script
2import spinfirescript as sfs
3
4print(sfs.InsertPolyline([[00, 00, 00], [50, 50.5, -70], [100, 75, 83.7]], "#FFAA0000", 2))
Import a Model
The following demonstrates saving the workspace to an ACT3D file through scripting.
Usage
ImportFile(filename path)
Parameters
filename path: filename path of the file to import.
Import a File Example code
1# First open a 2D or 3D workspace to execute this script
2import spinfirescript as sfs
3
4print(sfs.ImportFile("C:/temp/TestCube.CATPart"))
Save to an ACT3D File
The following demonstrates saving the workspace to an ACT3D file through scripting.
Usage
SaveFile(filename path)
Parameters
filename path: filename path of the ACT3D file.
Save ACT3D File Example code
1# First open a 2D or 3D workspace to execute this script
2import spinfirescript as sfs
3
4print(sfs.SaveFile("c:/temp/new.ACT3D"))
See also