3D Model Parts
An intended use of the scripts/packages mechanism is that scripts can server as 3d model parts that can be imported into other bigger models. This allows to build up libraries of parts that can be reused in multiple scopes and projects.
Packages that contain open parameters can be handled as described in section Open Parameters in Packages .
The main Solid Object
If a 3D model is generated within a package, this solid can be accessed via the main member of the package.
File "part.sps":
Example
make rgb(255,0,0) >> sphere(2.0)
Main script file:
Example
#import ( "part.sps" )
solid myObject = part::main
make myObject
Multiple Instances of a Package's Object
In some scenarios, you may need to create multiple instances of an object created from an imported package. Due to the automatic package reset procedure this can be achieved in a direct manner. The following example demonstrates how to create multiple instances of an object from an imported package in a loop and set different values for each instance.
File "part.sps":
Example
open int h
{
name = "Height"
descr = "Height of the part."
value = 0
}
make cylinder( h, 1 )
Main script file:
Example
#import ( "part.sps" )
for( int i = 1; i < 5; ++i )
{
part::h = i
make translation( <[0, 2*i]> ) >> part::main
}