Home Technical Talk

MODO batch fbx exporter - does it exist?

Tzur_H
polycounter lvl 9
Offline / Send Message
Tzur_H polycounter lvl 9
Hey MODOers,

I'm looking for something similar to 3DS Max TsTools by Tom Shannon - anyone know if something of that sort exists?

Also, this for Maya ProductivityPlugin
[ame="https://www.youtube.com/watch?v=TcbSW4icYV4"]https://www.youtube.com/watch?v=TcbSW4icYV4[/ame]

Replies

  • Farfarer
    Options
    Offline / Send Message
    Your link is broken.

    Give this a go, I wrote it for someone as a favour;
    #!/usr/bin/env python
    
    import lx
    import os
    
    # Check if the scene has been saved.
    scene_changed = lx.eval1 ('query sceneservice scene.changed ? current')
    lx.eval ('dialog.setup saveOK')
    lx.eval ('dialog.title "Scene Unsaved"')
    lx.eval ('dialog.msg "The scene has not been saved. Any errors might result in unsaved work being lost. Save before exporting?"')
    try:
    	lx.eval ('dialog.open')
    except:
    	pass
    save_result = lx.eval1 ('dialog.result ?')
    
    # User didn't hit cancel.
    if save_result != 'cancel':
    
    	# User asked to save the scene first.
    	if save_result == 'ok':
    		lx.eval ('!scene.save')
    
    	# Get the directory to export to.
    	lx.eval ('dialog.setup dir')
    	lx.eval ('dialog.title "Export Path"')
    	lx.eval ('dialog.msg "Select path to export to."')
    	try:
    		lx.eval ('dialog.open')
    	except:
    		pass
    	else:
    		output_dir = lx.eval1 ('dialog.result ?')
    
    		# Get the current FBX Export setting.
    		fbx_export_setting = lx.eval1 ('user.value sceneio.fbx.save.exportType ?')
    
    		# Set the FBX Export setting to export selection.
    		lx.eval ('user.value sceneio.fbx.save.exportType FBXExportSelection')
    		# Replace the above line with this if you want selection & hierarchy.
    		# lx.eval ('user.value sceneio.fbx.save.exportType FBXExportSelectionWithHierarchy')
    
    		# Grab the IDs of each foreground layer.
    		layers = lx.evalN ('query layerservice layer.id ? fg')
    
    		# Export each layer separately.
    		for layer in layers:
    			# Get the layer name.
    			layer_name = lx.eval1 ('query layerservice layer.name ? %s' % layer)
    			# Work out the export path from the name.
    			output_path = os.path.join (output_dir, layer_name + '.fbx')
    			# Select only the mesh item.
    			lx.eval ('select.subItem %s set mesh' % layer)
    			# Export to FBX.
    			lx.eval ('!scene.saveAs "%s" fbx true' % output_path)
    
    		# Reselect the layers the user had selected.
    		lx.eval ('select.subItem %s set mesh' % layer)
    		for layer in layers:
    			lx.eval ('select.subItem %s add mesh' % layer)
    
    		# Put the user's original FBX Export setting back.
    		lx.eval ('user.value sceneio.fbx.save.exportType %s' % fbx_export_setting)
    
  • Tzur_H
    Options
    Offline / Send Message
    Tzur_H polycounter lvl 9
    Thanks Farfarer, I'll give it a go!

    Fixed the links in the 1st post.
  • Tzur_H
    Options
    Offline / Send Message
    Tzur_H polycounter lvl 9
    Hi James, I've been using this script for a while now, it saves me so much time!
    For some reasons though sometimes it will fail to place the meshes on 0,0,0 when it's doing the 'export every mesh item' line (I think), any clue as to why?
    For example, I have 3 mesh items here with item centers snapped to place for the pivot (using another script from you :]).  But When I batch FBX export I get undesired result in engine.

    Here's the properties of the wall only (white mesh item above)


    I'm not sure what I did to cause this to happen, I've tried freezing everything, re-setting the centers and export again, but I'm still getting the same result in engine.

    *EDIT: I copied the polygons of each mesh item and placed into newly created item layers and behold, it's working now!  I've absolutely no idea what I did to the meshes so it didn't work, maybe there is a way to ensure it won't happen in the script?
  • Farfarer
    Options
    Offline / Send Message
    It's possible you zeroed the transforms on the items?
  • Tzur_H
    Options
    Offline / Send Message
    Tzur_H polycounter lvl 9
    I've never ever used zero to be honest :D  But I do use freeze from time to time (freeze all), would that break it?
Sign In or Register to comment.