Jump to content

[SOLVED] Python relative reference path inside HDA


LaszloFX

Recommended Posts

Hey Guys!

I have a pretty newbie question about some Python and HDA interaction.

So in a nutshell I'm trying to create an HDA with implemented Python script which does the following:
1. I have an Original Geo, which is object merged in my HDA.
2. I select some primitives on my original geo (or on the HDA).
3. After I selected my primitives, with a press of a button on my HDA, the selected primitives will be added to a group's pattern parameter inside my HDA.
4. And of course it would be great if this could work with a relative reference, so if I copy my HDA multiple times it'll update the groups within the correct HDA.

I have this code so far:

import toolutils
viewer = toolutils.sceneViewer()
geo = viewer.selectGeometry()

s = geo.mergedSelectionString()

# How can I make THIS PATH relative reference?
n = hou.parm('/obj/Colorzied_Geo_Asset_1/Colorized_GEO/group1/pattern')

n.set(s)

I put together a pretty simple example file and the hda, which will hopefully help you guys understand what I'm trying to achieve.
In case my explanation is a little confusing. :)

selectedPrims_python_problem_v001.hip
colorzied_geo_asset.hda
 

Any help or nudge in the right direction would be greatly appreciated!
Thanks in advance!

Best,
Laszlo
 

Edited by LaszloFX
Link to comment
Share on other sites

Hey Guys!

In the mean time, I found the solution.
I realized that if I put my code inside a function, I can recall that function with the HDA Callback Script.
I know this must be pretty basic information to most of you, but for me it opened up many mental doors and windows. :D

And just in case anyone is interested, here is the code that is inside my HDA's Type Properties Scripts Tab:

import toolutils

def sel():


    viewer = toolutils.sceneViewer()
    geo = viewer.selectGeometry()

    s = geo.mergedSelectionString()

    n = hou.parm('./grid/group1/pattern')
    
    n.set(s)
    

And this code goes into my Callback Script under my Button parameter to call back my function defined above:

kwargs['node'].hdaModule().sel()

 

And here are my example files as well:

selectedPrims_python_problem_v002_SOLVED.hip

colorzied_geo_asset.hda


Thanks anyway for taking a look at my problem, and I hope some of you may find it useful as well! :)

Best,
Laszlo

 

 

  • Like 3
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...