How to quickly move pivot to object center in LOP?

   3614   13   6
User Avatar
Member
75 posts
Joined: Dec. 2017
Offline

How to quickly move pivot to object center in LOP?
$CEX $CEY $CEZ and centroid() don't work, do I need to use the usd python api to access the current object bbx to calculate?

Attachments:
transform_LOP.jpg (32.7 KB)

User Avatar
Member
75 posts
Joined: Dec. 2017
Offline
Didn't find useful information in the documentation, does LOP currently not support this kind of operation?
User Avatar
Member
46 posts
Joined: Jan. 2016
Offline
Hi, I would love to know more about this too!

I got a component that is part of a product. (please see image attached) I would love to rotate it around a very specific pivot location, preferably without the use of sop_modify.


Isn’t There a way to define a pivot attribute before importing into lops?

Thanks in advance!
Best
Chris

Attachments:
1FD578FC-7E91-4CA1-BDD1-B47AC94C5C2A.jpeg (797.2 KB)

User Avatar
Member
75 posts
Joined: Dec. 2017
Offline
CV
Hi, I would love to know more about this too!

I got a component that is part of a product. (please see image attached) I would love to rotate it around a very specific pivot location, preferably without the use of sop_modify.


Isn’t There a way to define a pivot attribute before importing into lops?

Thanks in advance!
Best
Chris

I have an idea: calculate the position of the center point by querying the bbx of the current prim through USD's python API, but this seems extremely cumbersome and troublesome.
User Avatar
Member
122 posts
Joined: June 2019
Offline
Yeah, I think the only way is python api (or vex, but you still need to pull somehow values to parameter).

I have a little example for Transform LOP. Something similar to pivot tool in omniverse.
It's just setting pivot relative to bounding box with exposed controls.

(It's just an example, would be better to package it to little hda to avoid complicated expressions)
Edited by elovikov - Sept. 27, 2022 05:28:19

Attachments:
lop_pivot.gif (1.3 MB)
xform_pivot.hiplc (83.6 KB)

User Avatar
Member
75 posts
Joined: Dec. 2017
Offline
elovikov
Yeah, I think the only way is python api (or vex, but you still need to pull somehow values to parameter).

I have a little example for Transform LOP. Something similar to pivot tool in omniverse.
It's just setting pivot relative to bounding box with exposed controls.

(It's just an example, would be better to package it to little hda to avoid complicated expressions)
That's why I love community!Talented people communicate with each other.
Thank you so much for sharing, I was diving for the API in the USD documentation, you saved me a lot.
Edited by ysysimon - Sept. 27, 2022 10:55:07
User Avatar
Member
240 posts
Joined: Oct. 2014
Offline
With your object selected in the Scenegraph, if your cursor is over the Scene Viewer when you drop down the Transform LOP, it will auto-set this pivot to center on the object.
- Tim Crowson
Technical/CG Supervisor
User Avatar
Member
46 posts
Joined: Jan. 2016
Offline
Thanks a lot from me as well! These informations are very useful!

But how would you center the pivot inside the circular opening of the strap model I posted above?

Neither center pivot or bbox will work in this case :-)
In the image, I positioned the pivot in Sops with the help of selections and the construction plane. But how do I get the pivot into lops?

Or is this a sop_modify thing?


All the best
Christian
User Avatar
Member
75 posts
Joined: Dec. 2017
Offline
CV
Thanks a lot from me as well! These informations are very useful!

But how would you center the pivot inside the circular opening of the strap model I posted above?

Neither center pivot or bbox will work in this case :-)
In the image, I positioned the pivot in Sops with the help of selections and the construction plane. But how do I get the pivot into lops?

Or is this a sop_modify thing?


All the best
Christian

use the ch function reference them from SOP to move the pivot inside the LOP transform.

This is the way I can think of, because USD seems to store 4*4 transformation matrices directly, and does not store pivot information separately, of course you can author a pivot attribute and use USD pyhton API to access them.
Edited by ysysimon - Sept. 28, 2022 07:23:04
User Avatar
Member
10 posts
Joined: Nov. 2018
Offline
Tim Crowson
With your object selected in the Scenegraph, if your cursor is over the Scene Viewer when you drop down the Transform LOP, it will auto-set this pivot to center on the object.



I have not been able to get this technique to work in H20.
User Avatar
Member
9 posts
Joined: Jan. 2024
Offline
For me - whenever I use a Transform LOP whenever you customize the `primpattern` parm (Primitive Pattern) at the top then it automatically adjusts the pivot point to the center of the selected primitives.

Note that this occurs when you CTRL+CLICK on the right hand side arrow next to the Prim Pattern field and then select objects in there, and click apply.

I've reported that as a bug since it's really annoying that if you've already done transformations and just want to include an extra primitive that suddenly the pivot changes. However, it does mean that for now that's an easy 'hack' to force the pivot point to bounding box center.

In my bug I've basically requested to implement something like the LOP transforms, so that there are explicit buttons in the UI to "Set the Pivot Point to center" (instead of dynamic evals, etc.)
User Avatar
Member
3 posts
Joined: June 2020
Offline
I'd really like to see a procedural way of addressing this, e.g. "$CEX $CEY $CEZ".

For me, I have a use case where I use PDG to create a collection of USD's that will be referenced into another USD. Within each, the primpath and transforms vary. Requiring manual clicks by the user or hardcoding anything isn't an option.
Edited by LIL01 - Feb. 16, 2024 11:01:28
User Avatar
Member
52 posts
Joined: June 2017
Offline
This definitely seems a bit cumbersome, but for the example of a transform node pivot specifically, the following python function placed in the "px" parm will set the pivot to the center of a selected primitive (py and pz too).
Note that I haven't tested it with multiple prims selected, but it at least fits a few use cases.
I may add a variation of it to a right-click menu just for easy setting vs worrying about adding a python script directly to a parm expression.
from pxr import UsdGeom
node = hou.pwd()
# Get the stage of the input node to avoid recursion
stage = node.input(0).stage()
if stage is not None:
        # Other nodes might need "primpath", but you could functionally add any prim path you want here
        focusprim = stage.GetPrimAtPath(node.evalParm("primpattern"))
        if focusprim is not None:
                cache = UsdGeom.BBoxCache(1.0, ['default', 'proxy', 'render', 'guide'])
                bounds = cache.ComputeLocalBound(focusprim).ComputeCentroid()
                # node.parmTuple("p").set(bounds) crashed Houdini via recursion, but this seems to work.
                node.parm("py").set(bounds[1])
                node.parm("pz").set(bounds[2])
                return bounds[0]
Edited by EJaworenko - April 26, 2024 17:33:02
Houdini TD, I focus on tools for procedural asset creation.

www.jaworenko.design
User Avatar
Member
171 posts
Joined: Nov. 2013
Offline
In a pinch you can hit the 'insert' key on your keyboard and move the pivot manually. It's not procedural, I know but may help someone.
  • Quick Links