Inside Sabertooth
Learn how Sabertooth uses 3ds Max to create 3D interactive projects, including HBO Go’s Game of Thrones interactive experience
  • 1/3
You are here: Forum Home / Autodesk 3ds® Max® / MaxScript / objects flips after instanceReplace
  RSS 2.0 ATOM  

objects flips after instanceReplace
Rate this thread
 
41644
 
Permlink of this thread  
avatar
  • jedie
  • Posted: 08 April 2010 01:54 AM
  • Total Posts: 419
  • Joined: 06 September 2006 02:53 AM

I use this script http://www.scriptspot.com/3ds-max/scripts/instance-replace
I replace many objects with instanceReplace

The problem: A few objects flips (like mirror). Or the object rotate?

Here a test script:

fn DumpObjInfo obj (
 format 
"____________________________________________\n"
 
format "DumpObjInfo for object: %\n" obj
 
 format 
"%:\t%\n" "transform" obj.transform
 format 
"%:\t%\n" "rotation " obj.rotation
 format 
"%:\t%\n" "pivot " obj.pivot

 format 
"%:\t%\n" "objectoffsetpos " obj.objectoffsetpos
 format 
"%:\t%\n" "objectoffsetrot " obj.objectoffsetrot
 format 
"%:\t%\n" "objectoffsetscale" obj.objectoffsetscale
 format 
"%:\t%\n" "objecttransform " obj.objecttransform
)

obj_x
=$'oben'
obj_y=$'unten'

DumpObjInfo obj_x
DumpObjInfo obj_y

format 
"------------------------------------------------------"
instanceReplace obj_x obj_y
format 
"------------------------------------------------------"

DumpObjInfo obj_x
DumpObjInfo obj_y

The output is:

OK
DumpObjInfo()
ResetAll()
$Editable_Poly:oben @ [0.000000,-0.000011,3.360594]
$Editable_Poly:unten @ [0.000000,-0.000011,1.142553]
____________________________________________
DumpObjInfo for object: $Editable_Poly:oben @ [0.000000,-0.000011,3.360594]
transform: (matrix3 [0,1,0] [1.62921e-007,0,-1] [-1,0,-1.62921e-007] [0,-1.10865e-005,3.36059])
rotation : (quat -0.5 -0.5 0.5 0.5)
pivot : [0,-1.10865e-005,3.36059]
objectoffsetpos : [0,0,0]
objectoffsetrot : (quat 0 0 0 1)
objectoffsetscale: [1,1,1]
objecttransform : (matrix3 [0,1,0] [1.62921e-007,0,-1] [-1,0,-1.62921e-007] [0,-1.10865e-005,3.36059])
OK
____________________________________________
DumpObjInfo for object: $Editable_Poly:unten @ [0.000000,-0.000011,1.142553]
transform: (matrix3 [0,1,0] [1.62921e-007,0,-1] [-1,0,-1.62921e-007] [0,-1.10865e-005,1.14255])
rotation : (quat -0.5 -0.5 0.5 0.5)
pivot : [0,-1.10865e-005,1.14255]
objectoffsetpos : [0,0,0]
objectoffsetrot : (quat 0 0 0 1)
objectoffsetscale: [1,1,1]
objecttransform : (matrix3 [0,1,0] [1.62921e-007,0,-1] [-1,0,-1.62921e-007] [0,-1.10865e-005,1.14255])
OK
------------------------------------------------------OK
$Editable_Poly:oben @ [0.000000,-0.000011,3.360594]
------------------------------------------------------OK
____________________________________________
DumpObjInfo for object: $Editable_Poly:oben @ [0.000000,-0.000011,3.360594]
transform: (matrix3 [0,1,0] [1.62921e-007,0,-1] [-1,0,-1.62921e-007] [0,-1.10865e-005,3.36059])
rotation : (quat -0.5 -0.5 0.5 0.5)
pivot : [0,-1.10865e-005,3.36059]
objectoffsetpos : [0,0,0]
objectoffsetrot : (quat 0 0 0 1)
objectoffsetscale: [1,1,1]
objecttransform : (matrix3 [0,1,0] [1.62921e-007,0,-1] [-1,0,-1.62921e-007] [0,-1.10865e-005,3.36059])
OK
____________________________________________
DumpObjInfo for object: $Editable_Poly:unten @ [0.000000,-0.000011,1.142553]
transform: (matrix3 [0,1,0] [1.62921e-007,0,-1] [-1,0,-1.62921e-007] [0,-1.10865e-005,1.14255])
rotation : (quat -0.5 -0.5 0.5 0.5)
pivot : [0,-1.10865e-005,1.14255]
objectoffsetpos : [0,0,0]
objectoffsetrot : (quat 0 0 0 1)
objectoffsetscale: [1,1,1]
objecttransform : (matrix3 [0,1,0] [1.62921e-007,0,-1] [-1,0,-1.62921e-007] [0,-1.10865e-005,1.14255])
OK



Attachment Attachment
Attachment Attachment
Replies: 1
/img/forum/dark/default_avatar.png

instance_replace_bug_a.jpg is before starting the script.
instance_replace_bug_b.jpg is after the script runs.

btw., ResetTransform or ResetPivot doesn’t do anything.

Author: jedie

Replied: 08 April 2010 01:55 AM  
avatar

It makes sense, notice the transforms for both objects is the same (except the vertical position). When you do instance replace it replaces the object. In this case the object is flipped in the object stack (base object or modifier), and not in the transformation.

-Eric



Eric Craft
“The Evil Monkey hiding in your closet.”

Replies: 0
avatar
  • jedie
  • Posted: 13 April 2010 06:16 AM

Yes. The Problem is, the object geometry is flipped “internal” and not the transformation of the object.

Is there is any changes to handle this in a script???



Replies: 0
avatar

Yeah, I’m interested if you can replace only the mesh, but not affect the nodes transform.  So the mesh is instanced, but it would keep the pos/rot/scale intact.

Right now my make instance of tool sort of does this, but sometimes the object will move from where it was after making it an instance of another object.  Not sure why it only does it sometimes…



Replies: 0