Welcome to SimplyMaya

SimplyMaya.com has been teaching Maya for eleven years. We believe in teaching the fundamental principles of 3D by example. In our online library you will find more than 500 hours of video training.
You are here > Home > SimplyMaya Community Forums

Welcome to Simply Maya

Please Sign in or Sign up for an account

Member Login

Lost your password?

Not a member yet? Sign Up!

Old 16-02-2012, 01:12 PM   #1
Registered User
Join Date: Jan 2012
Posts: 6
Thanks: 5
Thanked 4 Times in 4 Posts
Default Straighten imported model (STEP file)


I'm receiving STEP files of objects that we're rendering for a client (I don't normally work in Maya), but it seems they end up standing on edge somehow. My suspicion is that the pivot point is not reset angle-wise to 0 degrees. I have been able to get the client to at least get the pivot point to XYZ zeroed, which means that the object (imagine a 1x1x3 box, regardless of unit) is standing at zero XYZ but on its edge basically.

I have still been unable to get the client to "fix" this problem (I believe they're working in Inventor, but they're located in Poland and not fluent in English either, so I can't pay them a visit), so I'm wondering if there is any way or script I can use to "straighten" the model based on a known straight part of the model?

Ideally, if I could select a single nurbshape (a plane) in the model that I know should be aligned along X and Z axis (i.e. flat on the ground) and run a script that either a) straightens the whole model (it's grouped in root) or b) gives me the X, Y and Z rotation to use to straighten it I would be eternally greatful.

Ask away if there's anything else you might need to know.

Oh, it's Maya 2012 on OS X btw.
Bornhall is offline   Reply With Quote
Old 18-02-2012, 09:50 AM   #2
Registered User
Join Date: Jan 2012
Posts: 6
Thanks: 5
Thanked 4 Times in 4 Posts

Alright, seems no one here could be bothered to point me to "Snap Align Object" -> "3 Points to 3 Points", but luckily I found the answer elsewhere...

Anywho, I ended up writing a small script (works for me at least) that may be of help for someone else, here goes:

// this finds the name of the group the selected object belongs to
string $p[] = `listRelatives -fullPath` ;
$p = stringToStringArray( $p[0], "|") ;
$gOriginal = $p[0] ;

// duplicate the selected object and move it to root
duplicate -rr -n refOrig ;
parent -w refOrig ;

// move the object to the root of GROUP the selected object belongs to
parent refOrig $gOriginal ;

// you may or may not want this, I had a subgroup inside the group
// and wanted the duplicated object to be the first object in it
reorder -relative -1 refOrig ;

// create a new reference plane at 0, 0, 0. 100 units wide/deep
nurbsPlane -p 0 0 0 -ax 0 1 0 -w 100 -lr 1 -d 1 -u 1 -v 1 -ch 1 -n refPlan ;

// you may want to change this, I wanted the corner to be at 0, 0
// so X and Y goes -50. for my purpose I also moved it up 75 units.
setAttr "refPlan.translateX" -50 ;
setAttr "refPlan.translateZ" -50 ;
setAttr "refPlan.translateY" 75 ;

// select 3 vertices on the original object
select -r refOrig.cv[0][0] ;
select -tgl refOrig.cv[0][1] ;
select -tgl refOrig.cv[1][1] ;

// select 3 vertices on the reference plane
select -tgl refPlan.cv[1][0] ;
select -tgl refPlan.cv[1][1] ;
select -tgl refPlan.cv[0][1] ;
Basically, what I do is this; I select a single part/plane on the group that needs to be straightened that I know is supposed to be straight (flat on the ground). Then I run the above script which creates a duplicate of the selected object + a reference plane at 0, 0, 0 (I move it in X, Y and Z axis with setAttr above, you may want to get rid of or change those). The script also selects 3 points from the duplicate of the original object and then 3 points on the newly created reference plane. After that I only need to select "3 Points to 3 Points", select "Parent" from the dialog (the script moves the duplicate to the root of the group the original is part of).

Depending on the model, you may have to rotate it anyways, but it should now be a question of 90 degree angles only.

After the straightening is done you should remove the "leftover" refOrig and refPlan objects.

I will not provide any further support for this script, but it may be of help to someone out there
Bornhall is offline   Reply With Quote
Old 18-02-2012, 11:37 AM   #3
ctbram's Avatar
Join Date: Jan 2004
Location: Michigan, USA
Posts: 2,969
Thanks: 41
Thanked 569 Times in 521 Posts

The reason your imported files are rotated by 90 degrees is that inventor, like many true engineering CAD apps, uses the Z-axis as the up axis. Maya uses the Y-axis as the up axis by default.

You can fix this in three ways.

1. change the up axis in maya by going to windows > settings / preferences > settings and making the up axis the Z-axis for your clients files.

2. Have your client set the up axis in Inventor or his CAD surfacing app to be the Y-axis. I cannot recall where this is done in Inventor but I know it can be done.

3. create a mel as you have to rotate all imported objects about the X-axis by 90 degrees and freeze their transforms effectively making the Y-axis the up axis. I am not a mel guy so I cannot really comment on your script.
"If I have seen farther, it is by standing on the shoulders of giants." Sir Isaac Newton, 1675

Last edited by ctbram : 18-02-2012 at 06:01 PM.
ctbram is offline   Reply With Quote
Old 18-02-2012, 12:42 PM   #4
Senior Modeler - Framestore
Jay's Avatar
Join Date: Feb 2003
Location: UK
Posts: 6,185
Thanks: 39
Thanked 424 Times in 380 Posts


Its not a case of anyone being bothered. People may not actually know hence, no answers.

As CTBram says.......

for the record MAX uses Z up I believe.

If Dave or NextDesign are around they may be able to help with the script


A lion is silent, yet feared and respected, a yapping dog is despised and ignored
Jay is offline   Reply With Quote

Similar Threads
Thread Thread Starter Forum Replies Last Post
Model all black or new artifacts showing?? Lost all my painting and texuring!!! mayaday Maya Basics & Newbie Lounge 13 06-07-2013 04:37 PM
Urgent help needed Lee Perkins Technical Issues 5 14-10-2011 01:36 PM
Preparing a model before texturing... goggles Members Lounge 7 09-09-2011 09:46 PM
Maya scene files and rendered .iff files disappearing from HDD on file load priimate Technical Issues 3 06-05-2011 09:34 AM
Bump map distortions from an imported model rockit Maya Basics & Newbie Lounge 5 24-12-2010 09:55 AM

Thread Tools

A little bit about who we are
Links you might find useful
Catch up with SimplyMaya
SimplyMaya specialises in Maya tutorials. We offer over 1,000 individual Maya training videos, ranging from basic Maya tutorials through to intermediate Maya tutorials. Our tutorials are created by instructors with industry experience and are designed to get you up and running in Maya quickly without making it seem like hard work.

Copyright © 1999-2014 SimplyMaya - vBulletin® Copyright © 2000-2014, Jelsoft Enterprises Ltd.