Jump to content

Set Channel Ref Expression Via Hscript


RickWork

Recommended Posts

Hello,

I'm trying to set an object's min&max bounds under the render tab to reference an attribute that I create inside the sop network.

Right now I'm using opparm

echo "getting bounds file now for $object"
                        # /-----------------------------------------
                        # Min Bounds
                        set xmin = `bbox($outName, D_XMIN)`
                        set ymin = `bbox($outName, D_YMIN)`
                        set zmin = `bbox($outName, D_ZMIN)`
                        # Max Bounds
                        set xmax = `bbox($outName, D_XMAX)`
                        set ymax = `bbox($outName, D_YMAX)`
                        set zmax = `bbox($outName, D_ZMAX)`

                        # Now set the bounds and archive source
                        echo "setting bounds for $object"

                        # /-------------------------------------
                        # We should really use ch refs as the geo might
                        # be deforming and/or changing size per frame!


                        # Min Bounds
                        opparm -C `oppwf()` detail_minx $xmin
                        opparm -C `oppwf()` detail_miny $ymin
                        opparm -C `oppwf()` detail_minz $zmin

                        # Max Bounds
                        opparm -C `oppwf()` detail_maxx $xmax
                        opparm -C `oppwf()` detail_maxy $ymax
                        opparm -C `oppwf()` detail_maxz $zmax

While the above works ok, I don't think this will work if the object is scaling or deforming drastically in sops.

I was thinking of creating 2 attribute sops, 1 for min and 1 for max. I would channel reference these sops so that the values for the File min/max bounds would update per frame.

The problem is, I can't opparm a channel reference. I also tried chsraw, but that didn't work.

A quick search on here turned up with a post using chkey but I don't want to key my channel reference.

Cheers,

/Rick

Link to comment
Share on other sites

To do this so it updates with any changes you need to put your bbox expression straight into the parameter. To do that you need to add a channel. So the answer is yes you will need chkey.

The easiest thing to do in these situations is to put the expression in manually once then use opscript on the node to see what hscript commands you need to recreate it.

Link to comment
Share on other sites

To do this so it updates with any changes you need to put your bbox expression straight into the parameter. To do that you need to add a channel. So the answer is yes you will need chkey.

The easiest thing to do in these situations is to put the expression in manually once then use opscript on the node to see what hscript commands you need to recreate it.

25578[/snapback]

very cool. I forgot that houdini will output the hscript command in opscript.

Thanks!

Link to comment
Share on other sites

Sure does work now but looks a bit sloppy..

# /-----------------------------------------
# Min Bounds
# /-----------------------------------------
chadd -t 0 0 $object detail_minx
chkey -t 0 -v -1 -m 0 -A 0 -F "bbox(\"$object/$outName\", D_XMIN)" $object/detail_minx

chadd -t 0 0 $object detail_miny
chkey -t 0 -v -1 -m 0 -A 0 -F "bbox(\"$object/$outName\", D_YMIN)" $object/detail_miny

chadd -t 0 0 $object detail_minz
chkey -t 0 -v -1 -m 0 -A 0 -F "bbox(\"$object/$outName\", D_ZMIN)" $object/detail_minz

# /-----------------------------------------
# Max Bounds
# /-----------------------------------------
chadd -t 0 0 $object detail_maxx
chkey -t 0 -v -1 -m 0 -A 0 -F "bbox(\"$object/$outName\", D_XMAX)" $object/detail_maxx

chadd -t 0 0 $object detail_maxy
chkey -t 0 -v -1 -m 0 -A 0 -F "bbox(\"$object/$outName\", D_YMAX)" $object/detail_maxy

chadd -t 0 0 $object detail_maxz
chkey -t 0 -v -1 -m 0 -A 0 -F "bbox(\"$object/$outName\", D_ZMAX)" $object/detail_maxz

Thanks

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...