Integrating 3D models with photography
Interested in integrating your 3D work with the real world? This might help
# 1 16-02-2012 , 02:12 PM
Registered User
Join Date: Jan 2012
Posts: 6

Straighten imported model (STEP file)

Hiya,

user added image
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. user added image

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

Oh, it's Maya 2012 on OS X btw.

# 2 18-02-2012 , 10:50 AM
Registered User
Join Date: Jan 2012
Posts: 6
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:

Code:
// 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 user added image

# 3 18-02-2012 , 12:37 PM
ctbram's Avatar
Moderator
Join Date: Jan 2004
Location: Michigan, USA
Posts: 2,998
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 further it is by standing on the shoulders of giants." Sir Isaac Newton, 1675

Last edited by ctbram; 18-02-2012 at 07:01 PM.
# 4 18-02-2012 , 01:42 PM
Jay's Avatar
Lead Modeler - Framestore
Join Date: Feb 2003
Location: UK
Posts: 6,287
Bornhall

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

J

Posting Rules Forum Rules
You may not post new threads | You may not post replies | You may not post attachments | You may not edit your posts | BB code is On | Smilies are On | [IMG] code is On | HTML code is Off

Similar Threads