Quantcast
Channel: Scripting - McNeel Forum
Viewing all articles
Browse latest Browse all 5745

Export (object name to file name) & Import (file name to object name)

$
0
0

@leex wrote:

Hi all
For STL export I use script by @Helvetosaur

! _-Runscript (
Option Explicit
'Script by Mitch Heynick
'Version 21 March 2012
'added current file name and folder default

Call ExportSTL()

Sub ExportSTL()
	
	Dim arrObjs,strCurrDP,strCurrDN,strSaveDN,strFileName,strSett,filt	
	
	arrObjs = Rhino.GetObjects("Select objects to export as .stl", 8 + 16 + 32,, True)
	If Not IsArray(arrObjs) Then Exit Sub
	
	strCurrDP = Rhino.DocumentPath()
	strCurrDN = Rhino.DocumentName()
	filt = "STL Files (*.stl)|*.stl||"
	
	If Not IsNull(strCurrDN) Then
		strSaveDN =Left(strCurrDN,Len(strCurrDN)-3)&"stl"
		strFileName = Rhino.SaveFileName("Export STL", filt, strCurrDP, strSaveDN)
	Else
		strFileName = Rhino.SaveFileName("Export STL", filt)
	End If
	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, False)
	
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.001 "
	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

))

Hide

It works beautifully, but at the moment important wishes have ripened. In my work for each project I get a lot scans in STL format, each file has its own name. I need to import all this mass to Rhino and write the names manually. It is too long. Then, having slightly adjusted the models, I have to export each of them to a separate OBJ file and save its name as file name, and this also takes a lot of time. I would like to receive help in writing a script for automation this proces.

Is it possible to modify this script so that take and assign name from properties and save it name as name STL file

And another script for import STL.
So that to take the name of the imported STL and assign this name to properties

Thanks

2020-03-11_3-03-49

Posts: 2

Participants: 2

Read full topic


Viewing all articles
Browse latest Browse all 5745

Trending Articles