SOP_xformMatch Transforms object tool

Match the world-space transforms of an object to another object.

Info
Date 01/12/2011
Compatibility Houdini 9.0
Change Log Added the Match Transforms shelf tool.
Tool Info
Submenu Modify
Viewer OBJ
#
# Produced by:
#       Graham Thompson
#       captainhammy@gmail.com
#       www.captainhammy.com
#
# Name:         object_match_xform.shelf
#
# Comments:     Copy the world transform of one object to another.
#
# Version:      1.0
# 
# Compatibility: Houdini 9.0
#
 
import toolutils
 
activepane = toolutils.activePane(kwargs)
 
if not isinstance(activepane, hou.SceneViewer):
    raise hou.OperationFailed("No scene viewer detected.")
 
# Prompt for the object to get the transforms from.
source_prompt = "Select the object to copy transformations from and press Enter to complete."
selected_objects = activepane.selectObjects(source_prompt, allow_multisel = False)
 
if len(selected_objects) is 0:  
    raise hou.OperationFailed("No source object selected.") 
 
source = selected_objects[0]
source.setSelected(False)
 
# Prompt for the object to set the transforms on.
target_prompt = "Select the object to copy transformations to and press Enter to complete."
selected_objects = activepane.selectObjects(target_prompt, allow_multisel=False)
 
if len(selected_objects) is 0:  
    raise hou.OperationFailed("No target object selected.") 
 
target = selected_objects[0]
 
# Get the world transform and set it to the target object.
world_xform = source.worldTransform()
target.setWorldTransform(world_xform)
 
# Enter the current node state (most likely the Transform state).
activepane.enterCurrentNodeState()

Valid XHTML 1.0 Strict