Element Composite Scripting
The example code below demonstrates how to use FRED's scripting language to perform the following tasks:
- Add an Element Composite node to the object tree
- Add two sphere type Element Primitives as children of the Element Composite node, each offset along the X axis
- Apply a specification string to the Element Composite that defines how the two spheres are combined using boolean solid operators
Sub Main 'Add the element composite node Dim eb As Long Dim tEnt As T_ENTITY InitEntity( tEnt ) tEnt.name = "Element Composite" eb = ElemAddBoolean( tEnt ) Update 'Add some element primitive spheres Dim s1 As Long, s2 As Long InitEntity( tEnt ) tEnt.name = "sphere 1" tEnt.parent = eb s1 = ElemAddSphere( tEnt ) ShiftX( s1, eb, -0.25 ) InitEntity( tEnt ) tEnt.name = "sphere 2" tEnt.parent = eb s2 = ElemAddSphere( tEnt ) ShiftX( s2, eb, 0.25 ) Update 'Combine them into the composite node using the intersection operator 'Spec string = "Geometry.Element Composite.sphere 1" & "Geometry.Element Composite.sphere 2" Dim spec As String spec = Chr(34) & GetFullName( s1 ) & Chr(34) & "&" & Chr(34) & GetFullName(s2) & Chr(34) ElemBooleanSetSpec( eb, spec ) Update End Sub