Jump to content

python expression in group name field


photex

Recommended Posts

Hello,

I'm trying to use a python expression to convert a point group into a string that can tell the polybevel sop to bevel edges instead of points.

If I select the edges manually and polybevel things work as normal.

But when I try to use this expression:

`"p%s" % "-".join(hou.hscriptExpression("pointlist(\"../bevel_group\",\"bevel_group\")").split())`

and I get an error that the group name is invalid. I'm guessing that it has something to do with the quotes that get returned since if I paste the evaluated string into an identical sop I get the bevel as expected.

Any advice would rock. I know that I still need work out how to append the first point to the end of that list, but I need this expression to at least evaluate before I spend more time on that.

Cheers!

Link to comment
Share on other sites

AHA!

My familiarity with Hscript damned me as I try to do fancy things.

The trick is to alt-e the field and then just treat the expression as a python function body:

list = hou.hscriptExpression("pointlist(\"../bevel_group\",\"bevel_group\")").split()

return "p%s-%s" % ("-".join(list),list[0])

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