Merge Objects into new Geometry

Hey! long time no post. But, now it’s time to post some stuff again. The first small script I want to share is a script, that has been handy during the last productions. It merges a geo object selection to an new geo and adds it’s material as primitive material. Maybe you were asking, why we sometimes are working like this. Houdini doesn’t display instanced subnets in the viewport and redshift doesn’t render instanced subnets. This is a workaround to fully instance subnet/objects in the viewport and at rendertime. Sure this is just a workflow for small assets, but for smaller products that need to be instanced this can be a solution. Also If you have to do some multi object editing. :).

import hou

#Get Houdini Selection
oSelection = hou.selectedItems()
#Create an empty List
oAllObjsforSubnet = []
#Create an empty Counter
counter = 0

#Check if the selection is empty
if oSelection:
    #The the obj context to the variable obj
    obj = hou.node("/obj")
    #create a new Geo Node on /obj level
    newNode = obj.createNode("geo", str("merged_geo"))
    #Delete the build in File node of the new Geo
    newNode.children()[0].destroy()
    #Create the hero merge node
    oMergeNode = newNode.createNode("merge")
    #Loop over the selected node
    for oNode in oSelection:
        #Check if the type is geo
        if oNode.type().name() == "geo":
            #Create an Obeject Merge node
            currentOBJMerge = newNode.createNode("object_merge")
            #Set the path to the base obj
            currentOBJMerge.parm("objpath1").set(oNode.path())
            #Check if there is an Material assigned
            if(oNode.evalParm("shop_materialpath") != ""):
                #Create a SOP materail node
                currentMaterial = newNode.createNode("material")
                #Convert relative Pathes to absolute pathes
                relPath = oNode.evalParm("shop_materialpath")
                relNode = oNode.node(relPath)
                fullpath = relNode.path()
                #Fill in the right materail path
                currentMaterial.parm("shop_materialpath1").set(fullpath)
                #Connect the current obj merge node the the materail node
                currentMaterial.setInput(0,currentOBJMerge)
                #Connect the material node the the hero merge node
                oMergeNode.setInput(counter,currentMaterial)     
            #If there is no Material assigned
            else:
                #Connect the Object Merge to the 
                oMergeNode.setInput(counter,currentOBJMerge)     
            #Increase the ounter, for the next merge node port
            counter +=1
    #Set the diplay Flag
    oMergeNode.setDisplayFlag(True)

 

Rename Group Materials

Hey!

A common workflow for us is to assign materials in softimage with the help of groups. All objects in a group share the same material, which makes material assigning and overriding easy. During the last days I had to select tons of meshes, to group them and to assign a new material to it. Lazy as I am, I have written a script that renames the group material with the groups name. This saves a lot of keyboard write work. Btw, this script works also with partitions – Some people prefer sorting Materials on the top level of SI’s hierarchy.

xsi = Application
collSel = xsi.Selection
log = xsi.LogMessage
for x in range(0,len(collSel)):
	#log(collSel(x).Type)
	oType = str(collSel(x).Type)
	oType2 = oType.replace("#","")
	log(oType2)
	if(oType2 == "Partition") or (oType2 == "Group"):
		log("Group Name: " + str(collSel(x).FullName) + " | Material: " + str(collSel(x).Material))
		if(collSel(x).Material == "None"):
			log("sftools.debug: There is no Material applied to the group")
		else:
			oObject = collSel(x).Name
			oObjectPath = collSel(x).FullName
			oMaterial = collSel(x).Material
			
			oMatLib = collSel(x).Material.Library
			log(oMatLib)
			oMat = oMaterial.Name
			log(oMat)
			xsi.SetValue(str(oMatLib) + "." + str(oMat) + ".Name", str(collSel(x).Name) , "")

Match transfroms in Maya

Currently we are switching our workflows from Softimage to Maya. One small, but essential feature we miss, is the good old match all transforms functionality. This function matches the translation, rotation and transforms from one object to another.

Read More

Make Reset-Nulls

Hey!

How many times a day do you make reset nulls, to zero out the local values? To me it fells that I’m doing it >30 times a day – So automating this process is essential to speed-up working. Here is a small python script, that makes your day more comfortable.

Usage: Select a Object and run the script. The code will generate a new parent of the object you have selected. With this approach you have zero out all local transforms.

Read More

Getting your cameras right

Hey,

when we’re animating cameras it’s most of the time needed to change the timing of the camera-move without changing it’s movement. So our approach is to link curves to others. In Softimage this is called link-with, in Maya set-driven-key and in Houdini we can use the function chf. In this tutorial I’ll explain the concept of animating cameras with this principle and how to setup the cameras in the different DCC.

Read More