Scripting Geometry from Curves and Surfaces
Scripting can be used to efficiently create geometry from curves and surfaces, such as a pipe with a hexagonally packed array of holes in it:
The script to create this geometry is included as an embedded script within the following sample file:
Or as a standalone script:
This script features many core components of scripting, including local and global variables, arrays, re-dimensioning arrays, logical tests, loops, calling functions; as well as many FRED specific functions such as defining subassemblies, custom elements, curves and surfaces, positioning objects, in addition to setting volume trimming, trimming specifications, visualization settings, raytrace controls and coatings.
The flow of the script is as follows:
- Variables are defined and set for the number of rings in the hexagonal packing, hole radius, gap between holes, the overall pipe semi-diameter and length
- A subassembly for the object is created
- Within a loop the location of each hole is calculated, for each location a function is called where a custom element is added within the subassembly featuring a circular curve, and a surface which extrudes the circular curve into a pipe (the hole)
- After the loop another custom Element is added to define the pipe object that the holes are inside of. Within this Custom Element:
- Another circular curve is defined for the edge of the pipe
- Two aperture curve collections are created for the holes and the pipe edge
- An extruded surface is formed with the edge curve to form the outer edge of the pipe
- Front and Back Plane surfaces are defined, and then trimmed with the holes and edge aperture collections and the surface tessellations are increased
- Finally, all surfaces within the "holey pipe" subassembly are made reflective.
Note that after running the script the object may take some time to render due to the increased tessellation.