Scattered point positions to the nulls (obj level)

   3282   12   2
User Avatar
Member
56 posts
Joined: Sept. 2015
Offline
I have a bunch of scattered points, but I need somehow get Nulls on each point in /obj level.
Is there a way to do that?

Basically, I'm trying to export my scene with Houdini2Ae tool (https://vimeo.com/186204479) into after effects, and it selects object nodes in /obj level. As my points are inside the object, it doesn't read coordinates, but I don't want to do it manually either because I think it would be very stupid.

Is there a way to send each point coordinate up one level, and assign Null node?

If anyone of you is familiar with C4d, I'm trying to get “external compositing” tag and get 3d nulls and camera.

Attachments:
Grids.PNG (733.7 KB)

User Avatar
Member
900 posts
Joined: Feb. 2016
Offline
so you want to create as many new null nodes as your scattered points, and assign them their position?

You could do it in python, but it seems not very efficient to create so many objects..
User Avatar
Member
56 posts
Joined: Sept. 2015
Offline
Andr
so you want to create as many new null nodes as your scattered points, and assign them their position?

You could do it in python, but it seems not very efficient to create so many objects..

Yes. I know it's not very efficient, but there is no other way to get nulls in Ae without doing so. I thought that python should do something similar, will try to look into it, thanks!

I just ditched C4d, and trying to recreate projects with Houdini. In all fairness, Houdini is great, but there are some caveats in Houdini/Ae workflow
User Avatar
Member
900 posts
Joined: Feb. 2016
Offline
Hi, have a look at the attached example.
It's a starting point. It would create at obj level as many nulls as the points in the reference node.
You need to set their position with python, I'll leave that to you

cheers
Edited by Andr - July 11, 2019 06:52:33

Attachments:
createNulls.hiplc (63.1 KB)

User Avatar
Member
56 posts
Joined: Sept. 2015
Offline
Hi, will try to do that! I think it will be a good educational thing for sure! thanks for a script!
User Avatar
Member
8539 posts
Joined: July 2007
Offline
To avoid scripting you can also make your points into packed primitives (by packing and copying something to them)
Then export as alembic and read on the scene level as alembic hierarchy
Tomas Slancik
FX Supervisor
Method Studios, NY
User Avatar
Member
56 posts
Joined: Sept. 2015
Offline
tamte
To avoid scripting you can also make your points into packed primitives (by packing and copying something to them)
Then export as alembic and read on the scene level as alembic hierarchy
Thanks for the reply, but this doesn't work.(or it might. but it is a quite long process to iterate).

Talking about scripts, it might sound funny for some of you but I was able to get a position and print that position of each point.
print(p.attribValue("P"))
Need to find the way to set this position for the points.
Edited by brokenkeyframe - July 14, 2019 15:34:35
User Avatar
Member
731 posts
Joined: Dec. 2006
Offline
Create one null and call it “null0” or similar, and in the translation X, Y, Z, put these expression, (assuming the object with the points you want to have nulls for is called “TARGET”):

point("../TARGET", `opdigits(".")`, "P", 0)
point("../TARGET", `opdigits(".")`, "P", 1)
point("../TARGET", `opdigits(".")`, "P", 2)

Now just Ctrl+C this node and Ctrl+v as many times as you need to. (You can just go into “update never” mode and hold down the paste key combo until you have a jillion nodes).

This extracts the digits from the name of the null, and uses this to look up the equivalent point number in the target object and find its position in X, Y and Z.

Sean
Edited by mrCatfish - July 15, 2019 09:45:41
Sean Lewkiw
CG Supervisor
Machine FX - Cinesite MTL
User Avatar
Member
4 posts
Joined: April 2019
Offline
In the CreateNull hda asset (in the script section) add inside loop

null.setParms({"t":pos})

if you have world transform in main geo (in most cases) add before loop

parent = node.parent()
trn = parent.worldTransform()

and inside loop mult pos with trn
pos = p.position()*trn
Edited by a1ex3d - Feb. 7, 2023 05:17:00
User Avatar
Member
359 posts
Joined: April 2017
Offline
Here's a quick and painless Python script you can run as a shelf tool. Includes orientations (orient attribute only) as well as positions from points.

import hou
import toolutils

def points_to_nulls():
   # prompt for object to convert
   prompt = toolutils.selectionPrompt(hou.sopNodeTypeCategory())
   scene_viewer = toolutils.sceneViewer()
   sel = scene_viewer.selectObjects(prompt)
   
   for index, i in enumerate(sel):
       out = i.displayNode()
       geo = out.geometry()
       name_prefix = i.name()
       # iterate over all points and get position/orientation
       for pt in geo.iterPoints():
           pos = pt.position()
           rot = None
           try:
               rot = pt.attribValue("orient")
           except hou.OperationFailed:
               pass
           # if there's an orient attribute, convert to eulers
           if rot is not None:
               rot = hou.Quaternion(rot).extractEulerRotates()
           # create a new null and apply transforms
           nullname = name_prefix + "_" + str(index+1)
           null = hou.node("/obj").createNode("null", nullname)
           null.parm("tx").set(pos[0])
           null.parm("ty").set(pos[1])
           null.parm("tz").set(pos[2])
           if rot is not None:
               null.parm("rx").set(rot[0])
               null.parm("ry").set(rot[1])
               null.parm("rz").set(rot[2])
               
points_to_nulls()
MOPs (Motion Operators for Houdini): http://www.motionoperators.com [www.motionoperators.com]
User Avatar
Member
143 posts
Joined: July 2015
Offline
toadstorm
Here's a quick and painless Python script you can run as a shelf tool. Includes orientations (orient attribute only) as well as positions from points.

That's brilliant.
I want to do the opposite, I have a bunch of tracked points from 3DEqulizer (obj level) and I want to make a point cloud out of nulls (sop level) in order to generate a mesh properly.
would you please show me how I change the script to do that?

thank youuuuuuu
Edited by MirHadi - Feb. 10, 2023 06:05:33
User Avatar
Member
679 posts
Joined: Feb. 2017
Offline
You can combine all Nulls to a point cloud with the object merge node. Look for the point node in each null and exchange changing parts of the Name with a #. Also make sure to set transform to Into this object.

Cheers
CYTE

edit: a yes of course, its * not #
Edited by CYTE - Feb. 10, 2023 09:51:57
User Avatar
Member
143 posts
Joined: July 2015
Offline
CYTE
You can combine all Nulls to a point cloud with the object merge node. Look for the point node in each null and exchange changing parts of the Name with a #. Also make sure to set transform to Into this object.

Cheers
CYTE

simple and straightforward, thank you.
'*' did the trick.
  • Quick Links