christopher hanson

chanson78

About Me

Expertise
Freelancer
Location
Germany
Website

Connect

Recent Forum Posts

Python Startup Script Help July 11, 2020, 5:03 a.m.

Hello

Just took a crash course in some simple startup script using python, basically a cut and paste job with some minor tweaks. When I install my script and open Houdini the camera node and geo node open up on top of each other, making it that I have to move them around every time I open a new file. I want them to open up like the Redshift ROP and IPR using “moveToGoodPosition” but I am not sure how to do this. I do what I think makes sense but then get an error when opening Houdini. Again, I know very little of python.

#!/usr/bin/env python

# Create Camera - 1920
def create_camera():
node = hou.node('/obj').createNode('cam', ‘cam_1920’)
node.setParms({'resx': 1920, ‘resy’: 1080})
node.setDisplayFlag(False)

# Create Geo Node - Geo
obj = hou.node(“/obj”)
geo = obj.createNode(“geo”, node_name=“Geo”)

# Create Mantra - PBR driver
def mantra_driver():
node = hou.node('/out')
out = node.createNode('ifd')
out.setParms({'vm_renderengine': ‘pbrraytrace’, ‘override_camerares’: True, ‘camera’: ‘/obj/cam_1920’})

def redshift_driver():
node = hou.node('/out')
node.createNode('Redshift_ROP').moveToGoodPosition()
node.createNode('Redshift_IPR').moveToGoodPosition()

def main():
# Check for camera node
nodes = hou.node('/obj').glob('*')
cam_exists = False

for node in nodes:
if node.type().name() == ‘cam’:
cam_exists = True
break

if not cam_exists:
create_camera()

# Check for Mantra or Redshift ROPS
rops = hou.node('/out').glob('*')
rrop_exists = False
mrop_exists = False

for node in rops:
if node.type().name() == ‘ifd’:
mrop_exists = True

if node.type().name() == ‘Redshift_ROP’:
rrop_exists = True

try:
if not rrop_exists:
redshift_driver()
except:
hou.ui.displayMessage('Oops! Something went wrong. Unable to create Redshift ROP.')
if not mrop_exists:
mantra_driver()

Saving Presets On Opening New Files July 11, 2020, 1:05 a.m.

Ok so I've dug around and chosen to use 123.py or 456.py script to execute this startup script but where should this .py file be saved to? In my C:\Users\****\Documents\houdini18.0 folder and create a “scripts” folder? or C:\Program Files\Side Effects Software\Houdini 18.0.416\python27\Scripts folder? In my .env file it doesn't show a path for either, so I think. Should a path be defined in the .env file?

My current .env file

#
# Houdini Environment Settings
#
# The contents of this file are read into the environment
# at startup. They will override any existing entries in
# the environment.
#
# The syntax is one entry per line as follows:
# VAR = VALUE
#
# Values may be quoted
# VAR = “VALUE”
#
# Values may be empty
# VAR =
#

# Example:
#
# HOUDINI_NO_SPLASH = 1

HOUDINI_OCL_VENDOR=NVIDIA Corporation

HOUDINI_OCL_DEVICENUMBER=0

# —- REDSHIFT —-
HOUDINI_DSO_ERROR = 2
PATH = “C:/ProgramData/Redshift/bin;$PATH”
HOUDINI_PATH = “C:/ProgramData/Redshift/Plugins/Houdini/18.0.416;&”

I also noticed that I already have some .py scripts in my C:\Program Files\Side Effects Software\Houdini 18.0.416\python27 folder, should they go here?

I found some useful infoformation regarding this here https://houdinitricks.com/automatically-create-redshift-rops-when-starting-houdini/ [houdinitricks.com] and would like to replicate this script somewhat.

Saving Presets On Opening New Files July 10, 2020, 12:07 p.m.

mrCatfish
The 123.cmd file stores everything that is in the default new scene. You can add what you want to this file… you will want it to be in your $HOME/houdini18.0/houdini/scripts folder.

Thanks for the response but I can't open the 123.cmd file. It opens for half a second and then closes.