Hey guys,
I've been working on a small script to make my workflow a little faster at work.
It's a multi .CNT (custom format) exporter.
I want it to export to the defined path using the model name as file name.
eg, C\Users\Greentooth\Desktop\Box001.CNT
and repeat this for every selected model in the scene.
I've been playing around for a few days trying to link up the path and file name but haven't had much luck with it. Hopefully someone can clear this up for me.
I've opened other scripts to see how they do it and they use '+' to add names together, but mine doesn't seem to like it.
Here's the dialog box:
Here's the error I get:
If someone could have a look over my code to see if I'm doing something incorrectly, that'd be a huge help
Thanks!
rollout exporter "Multi .CNT Exporter" width:350 height:140
(
--rollout ui
editText edt_path "Export Location:" labelOnTop:true
button btn_browse "Browse..." width:100 height:20 pos:[13,45]
button btn_export "Export!" width:100 height:45 pos:[235,78]
GroupBox grp_info "Info" width:200 height:60 pos:[13,70]
--end rollout ui
on edt_path entered newText do
(
savePath = newText
)
on btn_browse pressed do
(
folderPath = getSavePath()
edt_path.text = folderPath
)--end do
on btn_export pressed do
(
objName = $.name
exportPath = folderPath + objName
for obj in ( selection as array ) do
(
sel = selection as array
i=1
For i = i to sel.count do
(
Select sel[i]
objname = $.name
exportfile exportPath #noprompt selectedOnly:true using:ExporterPlugin.Classes[13]
)--end selcount do
)--end array do
)--end pressed do
)--end rollout
createDialog exporter
Replies
If you have multiple objects selected, $ returns an array of all those objects. Hence you can't access the name with $.name.
Also there is a scope issue, as you define folderpath under "on btn_browse pressed"
folderpath is local variable, so it is undefined under on btn_export pressed. You have to redefine it.
But I'm still getting the same error when I try to run the script
-- No ""+"" function for undefined <<
What format do you want to save to? Iges ?
We could simply define the extension.
Other scripts don't define the names as strings so I don't understand why mine isn't working :P
Thank you very much for helping me out man, sorry to pull you from your LoL game :P
Here's the final script in case anyone wants to use it (you will have to change the exporter plugin class)
To see the list of classes you have type "exporterPlugin.classes" into the listener window to see what you have installed.
Here's the final script: