Created
December 21, 2016 10:45
-
-
Save roberthein/98fcfb7a8820bd7f9c0e1dedd0065920 to your computer and use it in GitHub Desktop.
An exporter for 3DsMax that exports a 3D scene to a .xyz format.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| --maxscript by Robert-Hein Hooijmans, 2004 | |
| rollout scene_export "Scene to XYZ" | |
| ( | |
| group "Animation Range:" | |
| ( | |
| spinner anim_start "From:" fieldwidth:45 range:[animationrange.start,animationrange.end,0] type:#integer across:2 | |
| spinner anim_end "To:" fieldwidth:45 range:[1,animationrange.end,animationrange.end] type:#integer | |
| spinner anim_step "Step:" fieldwidth:45 range:[1,100,1] type:#integer across:2 | |
| button btn_upd "Update" width:70 height:20 align:#right offset:[0,-2] | |
| ) | |
| group "Specify File:" | |
| ( | |
| button get_path "Choose File Path" width:150 height:20 align:#center | |
| edittext et_file fieldwidth:150 align:#center | |
| ) | |
| group "Hidden Objects Handling:" | |
| ( | |
| checkbutton chk_hid "Ignore hidden obj" checked:true highlightcolor:(color 180 100 180) width:150 height:20 align:#center | |
| ) | |
| group "" | |
| ( | |
| button exp "EXPORT" width:150 height:20 align:#center | |
| progressbar write_bar color:[180,100,180] orient:#horizontal width:150 height:20 align:#center | |
| ) | |
| label lab_frame "" | |
| on btn_upd pressed do | |
| ( | |
| anim_start.range = [animationrange.start,animationrange.end,0] | |
| anim_end.range = [1,animationrange.end,animationrange.end] | |
| ) | |
| on get_path pressed do | |
| ( | |
| out_path = getSavefilename caption: "Path for mesh file:"\ | |
| types: "coordinates(*.xyz)|*.xyz|" | |
| if out_path != undefined then | |
| ( | |
| et_file.text = out_path | |
| ) | |
| ) | |
| on get_obj picked obj do | |
| ( | |
| master = obj | |
| et_1.text= obj.name | |
| ) | |
| -- exporting start.. | |
| on exp pressed do | |
| ( | |
| escapeEnable=false | |
| for obj in geometry where NOT obj.category==#Particle_Systems do addmodifier obj (mesh_Select()) | |
| objsToProcess = for obj in objects where | |
| ( | |
| (iskindof obj editable_mesh OR obj.category==#Particle_Systems)\ | |
| AND obj.isHidden == false\ | |
| ) | |
| collect obj | |
| If chk_hid.state == off then | |
| ( | |
| hiddenObjs = for obj in objects where obj.ishidden == true collect obj | |
| join objsToProcess hiddenObjs | |
| ) | |
| -- checking if scene got exportable objects.. | |
| if (NOT objsToProcess.count > 0) OR (et_file.text==undefined) OR (et_file.text=="") then | |
| messagebox "Your scene does not include any exportable objects\n or you have not specified a file to save to" | |
| else | |
| ( | |
| mesh_file = createFile (et_file.text+".") | |
| local start=anim_start.value | |
| local end=anim_end.value | |
| local step=anim_Step.value | |
| local delta=(end-start) as float | |
| for t = start to end by step do at time t | |
| ( | |
| format "F[%,%,%]\n" t t t to:mesh_file | |
| for obj in objsToProcess do | |
| ( | |
| -- exporting objects and particles.. | |
| case of | |
| ( | |
| -- exporting objects.. | |
| (classof obj==editable_mesh): | |
| ( | |
| for v = 1 to obj.numverts do | |
| ( | |
| if NOT obj.ishidden AND obj.visibility then | |
| format "P%\n" (getVert obj v) to:mesh_file | |
| else( | |
| --do nothing | |
| ) | |
| ) | |
| ) | |
| -- exporting particles.. | |
| (obj.category==#Particle_Systems): | |
| ( | |
| for p = 1 to particleCount obj do | |
| ( | |
| pPos=particlePos obj p | |
| if pPos!=undefined then | |
| ( | |
| if NOT obj.ishidden AND obj.visibility then | |
| ( | |
| format "P%" (particlepos obj p) to:mesh_file | |
| format "\n" to:mesh_file | |
| ) | |
| else | |
| ( | |
| ) | |
| ) | |
| else | |
| ( | |
| ) | |
| ) | |
| ) | |
| ) | |
| -- export progress.. | |
| local percentProgress=100*((t-start)/delta) | |
| format "percentProgress=%\n" percentProgress | |
| write_Bar.value=percentProgress | |
| lab_frame.text = "Exporting frame:" + t as string | |
| ) | |
| ) | |
| ) | |
| close mesh_file | |
| write_bar.value = 0 | |
| for obj in geometry where NOT obj.category==#Particle_Systems do deleteModifier obj 1 | |
| lab_frame.text = "Scene Exported to XYZ" | |
| escapeEnable=true | |
| ) | |
| ) | |
| rollout About2 "About this script.." rolledUp:true | |
| ( | |
| label l1 "XYZ Scene Exporter" | |
| label l2 "" | |
| label l3 "Exports all available coordinates" | |
| label l4 "to a .xyz file." | |
| label l5 "(supports objects and particles)" | |
| ) | |
| if TR != undefined then (closeRolloutFloater TR) | |
| global TR = newrolloutfloater "Export scene to XYZ" 230 350 | |
| addrollout scene_export TR | |
| addrollout About2 TR |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment