Home Technical Talk

modo LXMacro "Command Disabled"

interpolator
Offline / Send Message
Revel interpolator
Hi guys, recently I try to teach myself about cryengine and found out that modo and cryengine have different up axis that give a slight problem here (even though I know UDK also have different up axis then modo, but the exported geometry fbx seems fine and not lie on d ground like cryengine did).

Wasn't able to find an official export option for modo-cryengine, what I did was record a modo's macro to rotate the object along x axis 90deg>export fbx>re-rotate object on x -90deg all in one button press, like so;
#LXMacro#
tool.set actr.origin on
select.typeFrom polygon;edge;vertex;item;pivot;center;ptag true
tool.set TransformRotate on
tool.noChange
tool.attr xfrm.transform RX 90.0
tool.doApply
tool.set TransformRotate off 0
export.selected 7 false false true
select.typeFrom polygon;edge;vertex;item;pivot;center;ptag true
tool.set TransformRotate on
tool.noChange
tool.attr xfrm.transform RX -90.0
tool.doApply
tool.set TransformRotate off 0
tool.set actr.origin off
select.typeFrom vertex;edge;polygon;item;pivot;center;ptag true

Well, it is working but somehow when I run this script first thing before doing anything after load the object it throw me "Command Disabled" for the line 6: tool.attr but if I activate transform tool before I run the script and it will work as expected. I know it's not a major problem but does anyone know what causing this? and what's the problem with that line 6?

Or anyone got a better solution for the modo-cryengine workflow?

Replies

  • Owers
    Options
    Offline / Send Message
    Owers polycounter lvl 10
    Kind of strange it doesn't work. As an alternative have you tried changing Modo's up axis? Not sure what version you're using, but if you go into preferences and select the 'Units' tab, you can change the up axis where it says 'Coordinate System'. If you set it to X that'll hopefully reduce the need for a script.
  • Revel
    Options
    Offline / Send Message
    Revel interpolator
    Yeah I know about change the preference setting, but the ylaz or seneca script to drop object into the "ground" is still take Y as the up axis, therefore instead of drop to the ground along the Z axis (cryengine use Z as the up axis), the object will move to the left/right along the Y axis.
  • Farfarer
    Options
    Offline / Send Message
    You might be better off using the axis rotate tool. I've found it gives more predictable results when run via macros/scripts...

    I've also turned this into a Python script rather than a macro. Just easier in my eyes.
    #python
    
    import lx
    
    lx.eval('tool.set actr.origin on')
    lx.eval('tool.setAttr axis.origin axis 0')
    
    lx.eval('select.type polygon')
    lx.eval('tool.set xfrm.rotate on')
    lx.eval('tool.noChange')
    lx.eval('tool.doApply')
    lx.eval('tool.setAttr xfrm.rotate angle 90.0')
    lx.eval('tool.doApply')
    lx.eval('tool.set xfrm.rotate flush 0')
    
    lx.eval('export.selected 7 false false true')
    
    lx.eval('select.type polygon')
    lx.eval('tool.set xfrm.rotate on')
    lx.eval('tool.noChange')
    lx.eval('tool.doApply')
    lx.eval('tool.setAttr xfrm.rotate angle -90.0')
    lx.eval('tool.doApply')
    lx.eval('tool.set xfrm.rotate flush 0')
    
    lx.eval('select.type vertex')
    
    lx.eval('tool.set actr.origin off')
    


    However, MODO has a native "export selected" for FBX now. It's in your FBX preferences - System > Preferences > File I/O > FBX I/O > set "Export type" to "Export selection with hierarchy" or "Export selection".

    So you should be able to just rotate your mesh, export to fbx and then undo the rotation, rather than using Gwynne's script - which copies all of the selected mesh items over to a new scene and then saves that, before closing the scene and returning to the one you were just in.
  • Revel
    Options
    Offline / Send Message
    Revel interpolator
    Hi James, thanks for the code but does it work as expected on your end? cus I've tried it here and after the initial rotate 90deg>export dialog box come up>it didn't rotate back to the -90deg. Also the thing I notice about axis rotate is depends on workplane which is can't be force, hard-coded to be rotated on X axis, am I correct?
  • Revel
    Options
    Offline / Send Message
    Revel interpolator
    Alright! after playing with copy/ paste/ type/ re-type/ etc. finally I realise what is the thing that cause problem with James' code, on line 11 and line 21 somehow create a problem and modo don't really like them, so I remove those 2 lines and all work perfect now! no more "Command Disabled" error anymore haha!

    My previous statement about axis rotate is wrong; it did however rotate along X axis no matter what position the workplace is when I run the script, so all good!

    Thanks James on helping me on this! :)
  • Farfarer
    Options
    Offline / Send Message
    For the axis, the number at the end of the second line line

    lx.eval('tool.setAttr axis.origin axis 0')

    will change what axis it rotates on.

    0 is X, 1 is Y and 2 is Z
Sign In or Register to comment.