Sub CreaCode ' This Routine write a file .NGC from a NURBS in Rhinoceros ' @ E. Lo Valvo - M. Piacentini ' Copyright: released under GPL Version 2 ' Febbraio 2008 'Pick a curve object Dim strObject strObject = Rhino.GetObject("Select NURBS", 4) If IsNull(strObject) Then Exit Sub ' Get the curve's control points Dim arrPoints, intCount arrPoints = Rhino.CurvePoints(strObject) intCount = Rhino.CurvePointCount(strObject) If Not IsArray(arrPoints) Then Exit Sub ' Get the curve's weight values Dim arrWeights arrWeights = Rhino.CurveWeights(strObject) If Not IsArray(arrWeights) Then Exit Sub ' Prompt the user to specify a file name Dim strFilter, strFileName strFilter = " File NGC (*.ngc)|*.ngc|All Files (*.*)|*.*||" strFileName = Rhino.SaveFileName("Save Code NC ", strFilter) If IsNull(strFileName) Then Exit Sub ' Get the file system object Dim objFSO, objStream Set objFSO = CreateObject("Scripting.FileSystemObject") ' Open a text file to write to On Error Resume Next Set objStream = objFSO.CreateTextFile(strFileName, True) If Err Then MsgBox Err.Description Exit Sub End If ' Write each point as text to the file Dim strPoint, strText, dblWeight, Gcode Gcode=Split(Rhino.Pt2Str(arrPoints(0)),",") objStream.WriteLine("G5.2 X"+Gcode(0)+" Y"+Gcode(1)+ " P" + CStr(arrWeights(0))+" L3") For I =1 To intCount-1 Gcode=Split(Rhino.Pt2Str(arrPoints(I)),",") objStream.WriteLine(" X"+Gcode(0)+" Y"+Gcode(1)+ " P" + CStr(arrWeights(0))) 'strText = " X"+Rhino.Pt2Str(arrPoints(I))+ " P" + CStr(arrWeights(I)) 'objStream.WriteLine(strText) Next objStream.WriteLine("G5.3") End Sub