Version 0.60.0

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
}

The result of the package part created multiple times.

In this example, four instances of the main object of the part package are created in a loop. The open parameter h is set to a different value for each instance, resulting in three different objects.

🗙

Search results for