'************************************************** ' This script takes a joined polysurface in Rhino ' and cuts it up into flat sections, which are then ' exported as Illustrator paths. These paths can be ' sent to a laser cutter and cut from flat material, ' then glued together to form a mock-up of your 3D ' model. ' ' The script creates a folder on the base of ' C:\ drive and exports the files there. A text file ' with the total number of contour curves is saved in ' the same directory. ' ' Cobbled together by Chris Reilly [creilly 4T saic D0T edu] in 2007. ' This script is distributed under a Creative Commons ' Attribution-Noncommercial-Share Alike 3.0 License ' see http://creativecommons.org/licenses/by-nc-sa/3.0/ ' for details '************************************************** Dim strObjects Dim intCount Dim strObj Dim strCmd Dim strFilenm Dim strLayerName Dim strLayerReturn Dim strUserDefinedFolder Dim objFileSys Dim strNewFolder Dim strNewPath Dim objFSO Dim objFolder Dim strDirectory Dim strTxtFile '************************************************** Sub createContours Rhino.Command "Contour" isolateObjectsToNewLayer("Working Surfaces") End Sub '************************************************** Function isolateObjectsToNewLayer(strLayername) Rhino.AddLayer(strLayername) Rhino.Currentlayer(strLayername) Rhino.Command "ChangeToCurrentLayer" Rhino.Command "-OneLayerOn Enter" End Function '************************************************** Function exportCurves(strDirectory) intCount = 0 Rhino.Command "SelNone" Rhino.Command "SelCrv" Rhino.Command "-SetActiveViewport Top" Rhino.Command "PlanarSrf Enter" Rhino.Command "SelNone" Rhino.Command "SelSrf" strObjects = Rhino.SelectedObjects() For Each strObj In strObjects Rhino.Command ("SelNone") strCmd = "SelID " & strObj Rhino.Command strCmd Rhino.Command "UnrollSrf Enter" Rhino.Command "SelNone" Rhino.Command "SelLast" Rhino.Command "-Make2D Enter" Rhino.Command "SelNone" Rhino.Command "SelLast" strFilenm = strDirectory & "\" & intCount & ".ai" strCmd = "-Export " & strFilenm & " PreserveUnits=Yes,AIScale=72,Unit=points,RhinoScale=1 Enter" Rhino.Command strCmd intCount = intCount + 1 Next Set objFSO = CreateObject("Scripting.FileSystemObject") Set strTxtFile = objFSO.CreateTextFile(strDirectory & "\" & "Curve_Count.txt", vbTrue) intCrvCount = UBound(strObjects) + 1 strTxtFile.WriteLine intCrvCount strTxtFile.Close End Function '************************************************* Sub doEverything strLayerReturn = Rhino.CurrentLayer createContours strUserDefinedFolder = Rhino.GetString("Enter a name for the output folder (ALPHANUMERIC, NO SPACES)") strDirectory = "C:\" & strUserDefinedFolder Set objFSO = CreateObject("Scripting.FileSystemObject") If objFSO.FolderExists(strDirectory) Then Set objFolder = objFSO.GetFolder(strDirectory) WScript.Echo strDirectory & " already created " Else Set objFolder = objFSO.CreateFolder(strDirectory) msgbox "Illustrator curves will be exported to : " & strDirectory End If exportCurves(strDirectory) Rhino.CurrentLayer strLayerReturn Rhino.Command "-OneLayerOn Enter" End Sub '************************************************* doEverything