Home Technical Talk

3ds Macro Script Help

I have a process which i really want to automate as its a fair few clicks and i do it everyday when exporting models into our engine from max:

The process is this:

center pivot to the object,
move the pivot down to the base of the model
move the object to 0,0,0 so its on the origin (this sould mean the base of the object is at 0 on Z axis)
reset transform
reset scale
reset xform
convert to editable mesh
file > export

The problem is i cant align the pivot to the lowest point on the model and then move the whole model to 0,0,0. I currently have this:

CenterPivot $;

*this is where i need to add the "move pivot to base of object stuff"*

resettransform $;

resetscale$;

resetxform $;

macros.run "Modifier Stack" "Convert_to_Mesh"

actionMan.executeAction 0 "40011" -- File: Export File

Any help with this would be appreciated as all those unneccesary clicks is driving me mad! I know its not exactly mind boggling code but it would help me out a lot.

Thanks in advance.

Replies

  • FicWill
    Options
    Offline / Send Message
    FicWill polycounter lvl 17
    You can probably do something like $.pivot.z = $.min.z
  • Mark Dygert
    Options
    Offline / Send Message
    frubes wrote: »
    The problem is i cant align the pivot to the lowest point on the model and then move the whole model to 0,0,0.
    A while back I wrote a simple script that does most of what you need. You could tack in the few extra things you need and call it done =)
    macroScript ToWorldZero
    category:"VigTools"
    toolTip:"To World Zero"
    buttonText:"Zero"
    (--Sets the pivot to the lowest point in a mesh, then center the object to world zero
    if $ != undefined then    
        (
            ResetPivot $
            CenterPivot $
            for i in selection do 
                (
                    i.pivot = [i.pivot.x, i.pivot.y, i.min.z]
                )         
            $.pos = [0,0,0]
        )
    else
        (
            messageBox "Select an object then run this script again." title:"Selection Error" beep:true
        )
    )
    
  • frubes
    Options
    Offline / Send Message
    Vig, your a genius. Cheers mate.
  • frubes
    Options
    Offline / Send Message
    CenterPivot $;

    (--Sets the pivot to the lowest point in a mesh, then center the object to world zero
    if $ != undefined then
    (
    ResetPivot $
    CenterPivot $
    for i in selection do
    (
    i.pivot = [i.pivot.x, i.pivot.y, i.min.z]
    )
    $.pos = [0,0,0]
    )
    else
    (
    messageBox "Select an object then run this script again." title:"Selection Error" beep:true
    )
    )

    resettransform $;

    resetscale$;

    resetxform $;

    macros.run "Modifier Stack" "Convert_to_Mesh"

    actionMan.executeAction 0 "40011" -- File: Export File

    --Thanks go out to Vig from Polycount

    (final thing if anyone is interested)
  • darthwilson
    Options
    Offline / Send Message
    I was just wondering, what actual part of this script tells it to move the pivot to the lowest point? I was trying to make a similar script to do all of this but the only thing I can't seem to do is get the pivot to move to the most bottom point of an object..
  • haiddasalami
    Options
    Offline / Send Message
    haiddasalami polycounter lvl 14
    I was just wondering, what actual part of this script tells it to move the pivot to the lowest point? I was trying to make a similar script to do all of this but the only thing I can't seem to do is get the pivot to move to the most bottom point of an object..

    dont know maxscript but looks like the min.z part in the for loop.
  • r_fletch_r
    Options
    Offline / Send Message
    r_fletch_r polycounter lvl 9
    i.pivot = [i.pivot.x, i.pivot.y, i.min.z]
Sign In or Register to comment.