Getting Started

Short Example

The following is a short example demonstrating a complete Scan&Solve stress simulation using calls to SnSScript from RhinoScript. The example includes:

For conciseness, this example contains minimal error checking.

Option Explicit
Call Main()
Sub Main()
	Dim objSnSPlugIn , strObject
	On Error Resume Next

	Set objSnSPlugIn = Rhino.GetPluginObject("SnSScript")
	If Err Then 
		MsgBox Err.Description
		Exit Sub
	End If

	strObject = Rhino.GetObject("Select a solid")
	'reset the SnS data attached to the object
	objSnSPlugIn.Reset strObject
	'set the material for simulation
	objSnSPlugIn.SetMaterial strObject, "Acrylic, Cast"
	'add a face restraint
	objSnSPlugIn.AddFaceRestraint strObject, "Restraint Face 1", 1, "xyz"
	'add a vector load on a face
	Dim vecLoad(3)
	vecLoad(0) = 10
	vecLoad(1) = 20
	vecLoad(2) = 30
	objSnSPlugIn.AddFaceVectorLoad strObject, "Vector Load Face 2", 2, vecLoad, True
	'compute the stress solution
	objSnSPlugIn.Solve strObject, 10000
	'turn on display of solution
	objSnSPlugIn.SolutionDisplayEnable strObject, "DSPT", 100
End Sub
Line #Description
1Only scripts with Option Explicit specified can be debugged in the RhinoScript editor (Monkey).
4Declare variables before use.
7-11Obtain a reference to the SnSScript plug-in, exit if an error occurs.
13Prompt the user to select a solid from the Rhino document. The solid is identified by its GUID stored in strObject.
15Clear the Scan&Solve data attached to the object.
17Set the material for the solid, "Acrylic, Cast" in this case.
19Add a restraint named "Restraint Face 1" to face 1. Restrain in x, y, and z.
21-24Declare and define an array to use as vector load.
25Add a vector load named "Vector Load Face 2" to face 2. True indicates load is applied per face.
27Compute the solution using 10000 elements.
29Display the total displacement "DSPT" and magnify the deflection by 100. To disable the display of the solution, call objSnSPlugIn.SolutionDisplayDisable strObject.