CNC Toolkit

CNC Toolkit - Multi-Axis Creative Machining

Here are some MaxScripts which I developed.
Some of these are incorporated into my CNC Toolkit
These scripts can be downloaded here: MaxScripts

MAXScript is a simple, object orientated programming language which runs within Discreet's 3D Studio MAX, GMAX and Autodesk VIZ, utilizing and extending their existing functionality.


Wrapper

Wraps one object around another.

Example: Wrapper Mesh, Test Text (Red object) has been extruded and placed above a squashed GeoSphere. 'Straight Projection' on left, 'Curve to Surface' on right with an offset.

See details of Wrapper

 

Contour Creator

Creates a series of contours from a selected mesh.
Has the option of combining all contours and welding any vertices within the Threshold amount which although slow, gives a far better end result as otherwise the contours are composed of many small splines with coincident vertices.
If "Weld all Contours ?" is left unchecked, a selection set of contour lines will be created. You can always use the weld function in the next script to add and weld these together.


Fuse n' Weld

Takes all vertices in a shape, compares them to their closest neighbor and moves them to an average position if within the threshold.
"Fuse" moves only, "Weld" moves and welds.
If many vertices are within the threshold, it only operates on the closest so it may be necessary to run the script a couple of times.
If multiple shapes are selected then all shapes are combined.

 

Refine Spline

Adaptively adds extra points to a shape while retaining the shape's existing points and curvature. Most useful if a curve's vertices are converted to corner, or if in our case you're doing point to point machining.
In the example to the left, the top test curve is the original, the middle is the same curve with its vertices converted to corners, the bottom curve has had Refine Spline applied to it prior to the vertices being converted to corners.

 

Optimize Spline

Adaptively removes points from a curve while retaining the shape's existing curvature.
In the example on left, compare the top and bottom test curves, while the lower curve contains around a third less vertices, it still retains the original shape. Experiment with the variables to get the best results.

 

 

Project Spline

Projects a spline onto the surface of a mesh.

 

Spline Intersection

Finds where a spline crosses over itself or another spline. Adds vertexes to intersection points.

 

Preview Toolpath

Previews finished CNC cut for a given path, tool and material block
Can be very important for checking how a design will machine.
This version uses Boolean operation which is too slow for production use.

Status: Under Development.


WRAPPER

Wraps one object around the surface of another while retaining the depth or body of the wrapping object.
Wraps either Splines or Meshes and incorporates my previous scripts, Mesh Drape and Project Spline


Interface:

Source Object: This is the object that gets wrapped. Press the 'Pick' button then click on the object that you want to wrap.

Target Surface: The object whose surface curvature you want to wrap the Source Object to. Press the 'Pick' button then click on the object that you want to wrap onto.

Operation: Pick Source Object and Target Surface, place Source Object on top of Target Surface, ensure that the base of the Source Object is at or above height Z=0, adjust offset by increasing height above 0.
When 'Use UVW mapping' is chosen a flat proxy representation of the Target Surface is first created, place this proxy beneath the Source Object.
Choose method and press Go (can be slow on complex meshes)


Examples:

Create an object in the top viewport, this can be a spline as in the text seen here, or a mesh object ( just add an extrude modifier to the text example to see this )
If the object has too few vertexes then it will not wrap smoothly, too many vertexes makes operation slow.


Source Object, in red is extruded text
place above a NURBS Sphere
'Curve to Surface' results in Blue object

Curve to Surface:


Curve to Surface: Projects the Source Object down onto the Target Surface, but offsets the Source relative to the surface of the Target

Straight Projection: Projects the Source Object down onto the Target Surface.

Conform to Surface: Flattens the Source Object onto the Target Surface. Similar to the 'Conform Compound Object' in MAX.

 

Use UVW Mapping:

A two-stage process that takes a Target Surface (the torus on left) and unwraps it when the 'Use UVW Mapping' option is chosen into a flat mesh representation or proxy for use as a reference to position the Source Object


Top: Mesh formed from extruded red text

Bottom: White Helix spline shape

 

Show Normals:

Creates a Spline which shows the Normal vectors or direction of the Target Surface used for UVW Mapping.

Red Helix has been wrapped to the Sphere resulting in a White Wrapped Helix and a Blue Spline showing the relative Normals.

Limitations of Wrapper:

All of Source Object must be above height Z=0
Source Object must fit within bounds of unwrapped mesh.
The script will still work if these conditions arn't met, but the result will be untidy.

Acknowlegements:

Thanks to Jared Keller and Swami Lama for their help and pointers on the Barycentric Coords stuff
The script uses snippets of functions by John Burnett for getting to the unwrapped mesh.
I'd also like to thank and acknowledge the help and encouragement of Doug McNabb who wrote an HPGL import function which showed me how useful but relatively straightforward maxscript could be.


Links to other sites you may find of interest.

MAX 3D - Info and news on 3D Studio MAX
Scriptspot - Great site with database of MAXScripts along with info and links
Bobo's Page - MAXScript site
Paul Bourke - Explanations and code examples of many graphic concepts
Geometry in Action
Algorithm Archive
Computational Geometry Resources
comp.graphics.algorithms FAQs
Directory of Computational Geometry Software
CGAL
Graphic Gems - Great source of example code
Computational Geometry Pages
The Geometry Junkyard