I found this useful script by @Helvetosaur for automated STL export (including meshing with presets).
Is it possible to modify it so that:
a) current document name is assigned as STL name?
b) it skips mesh setting if meshes are selected for export (not to modify existing mesh)?
Option Explicit
'Script by Mitch Heynick
'Version Thursday, 11 February, 2010
Call ExportSTLWithSettings()
Sub ExportSTLWithSettings()
Dim arrObjs,strFileName,strSett
arrObjs = Rhino.GetObjects("Select objects to export as .stl", 8 + 16 + 32,, True)
If Not IsArray(arrObjs) Then Exit Sub
strFileName = Rhino.SaveFileName("Export STL", "STL Files (*.stl)|*.stl||")
If IsNull(strFilename) Then Exit Sub
strSett = STLSettings() 'gets your settings from the function below
If IsNull(strSett) Then
Call Rhino.Print("Unable to get export settings")
Exit Sub
End If
Call Rhino.SelectObjects(arrObjs) 'selects your objects
'runs the export using the file name/path and your settings
Call Rhino.Command("-_Export " & chr(34) & strFileName & chr(34) & " " & strSett)
End Sub
Function STLSettings()
STLSettings = Null
Dim str1,str2,str3,str4,str5,str6,str7,str8,str9,str10
Dim str11,str12,str13,str14,str15,str16,str17,str18
Dim strComb
str1 = "_ExportFileAs=_Binary "
str2 = "_ExportUnfinishedObjects=_Yes "
str3 = "_UseSimpleDialog=_No "
str4 = "_UseSimpleParameters=_No "
str5 = "_Enter _DetailedOptions "
str6 = "_JaggedSeams=_No "
str7 = "_PackTextures=_No "
str8 = "_Refine=_Yes "
str9 = "_SimplePlane=_No "
str10 = "_Weld=_No "
str11 = "_AdvancedOptions "
str12 = "_Angle=15 "
str13 = "_AspectRatio=0 "
str14 = "_Distance=0.01 "
str15 = "_Grid=16 "
str16 = "_MaxEdgeLength=0 "
str17 = "_MinEdgeLength=0.0001 "
str18 = "_Enter _Enter"
strComb = str1 & str2 & str3 & str4 & str5 & str6 & str7 & str8 & str9 & str10
strComb = strComb & str11 & str12 & str13 & str14 & str15 & str16 & str17 & str18
STLSettings = strComb
End Function
This will use the current file name and propose to save the STL to the same directory as the Rhino file as long as it has been saved, otherwise it will ask for a file name/directory.
You can modify the meshing parameters to suit in the lower half of the script. Note that the meshing settings do not affect meshes, as Rhino does not re-mesh mesh objects - simply if there are quads in the mesh object, they will be triangulated on stl export (STL only supports triangles).
If you want to choose the directory independently, I can modify the script, let me know…</del.>
Well, you could try changing the aspect ratio (str13 near the bottom) to something like 3… Or you could put some number in the MaxEdgeLength (str16) - that number is absolute in file units, so all your triangles will have sides no longer than that value…
If you hit Help (F1) while in the Mesh command you will get a good description of what the individual settings do…
Thank you very Much!
I do not understand what has caused but now works
Mitch, I a little altered your script for export to DXF.
Works fine but I do not know how to implement the Function DXFSettings()
Is it possible to exclude export surface and polysurface, export curves only?
! _-Runscript (
Option Explicit
'Script by Mitch Heynick
'Version 21 March 2012
'added current file name and folder default
Call ExportDXF()
Sub ExportDXF()
Dim arrObjs,strCurrDP,strCurrDN,strSaveDN,strFileName,strSett,filt
arrObjs = Rhino.GetObjects("Select objects to export as .DXF")
If Not IsArray(arrObjs) Then Exit Sub
strCurrDP = Rhino.DocumentPath()
strCurrDN = Rhino.DocumentName()
filt = "DXF Files (*.DXF)|*.DXF||"
If Not IsNull(strCurrDN) Then
strSaveDN =Left(strCurrDN,Len(strCurrDN)-3)&"DXF"
strFileName = Rhino.SaveFileName("Export DXF", filt, strCurrDP, strSaveDN)
Else
strFileName = Rhino.SaveFileName("Export DXF", filt)
End If
If IsNull(strFilename) Then Exit Sub
strSett = DXFSettings() 'gets your settings from the function below
If IsNull(strSett) Then
Call Rhino.Print("Unable to get export settings")
Exit Sub
End If
Call Rhino.SelectObjects(arrObjs) 'selects your objects
'runs the export using the file name/path and your settings
Call Rhino.Command("-_Export " & chr(34) & strFileName & chr(34) & " " & strSett, False)
End Sub
This script woks with R64 only
with R32 doesnt work