Oriented point cloud

I’m struggling to code something and I was hoping this community could give me a hand.

Let’s say I have a box which is not aligned to the world axis, and I want to create a 3D point cloud grid inside of it that is aligned with the box’s axis (and not the world axis). It seems like a simple thing but all methods from the API seem to align stuff to the world axis.

If someone could just point me to the right direction I would appreciate.

PS: I know how to do this in the gui and in the grasshopper, but I need to code it in python as this would be part of a bigger script that I’m working on.

Hi @robneto.eng ,
Hope everything is good, I really like your efforts.
So, here’s how I’d do it:

  1. Select the face that you are interested in
  2. Convert to brep
  3. Set as plane
  4. Generate the pointcloud
  5. Generate a plane along the Z axis XX mm from the OG face
  6. Intersect the brep and your shape (can be irregular)
  7. Fill the defined domain (for simplicity, you can create a brep defined by the intersection between your plane and boundary shape, and fill it with points) with points and filter the ones outside

Repeat until the plane is no longer intersecting the shape.
The grid we are creating here satisfies your requirements (being aligned with the box face).

You will now have a new problem, having the grid be meaningful for computing optimal pathing or any sort of task, so the grid that you generate one each plane must be meaningful as in being aligned with the previews grid, otherwise you just have a lot of points shattered on multiple planes.

To do that you’d need to define rules for the grid generation, but that is way beyond the scope of your question.

Hope this gives you a clear path forward, pretty sure you can chatgpt your way out of this having a solid plan,
Farouk

Hi @robneto.eng
There are methods in the API to transform points from world axis to any custom orientation: XformWorldToCPlane and the other way round.
For any geometry you can calculate a transformation matrix XformRotation1 and use TransformObject
Jess

Thank you for your comment. A couple follow-up questions:

" 1. Select the face that you are interested in"
I’m assuming you are talking about one of the faces of the box?

" 4. Generate the pointcloud"
Is this a 2d pointcloud, on the created plane, aligned with the plane’s axis? If yes then the problem is that I can’t find a method to create this pointcloud that is not aligned with world XYZ.

“You will now have a new problem, having the grid be meaningful for computing optimal pathing or any sort of task…”
Thank you for the heads-up, but I got that part covered, I’m really just struggling with the pointcloud alignment.

Hum, that’s one way to do it, but I would rather create the poincloud in the correct orientation form the start, instead of having to move/rotate/transform it afterwards. I will go down that path if it’s my only option.