# getting all points of an object.

## Recommended Posts

lets say i have a 1'x1'x1' cube, i need to return the x,y,z of all the corners of the cube so i can format it to a .txt file to send that to another program.

my goal is to achieve this for more detailed objects in the future.

This depends on the type of object, which is easier if you’re intentionally creating objects for export.

The only object that gives you actual vertices is a mesh. If the objects are extrudes, you need to get the points off the planar base, the do the math to get the vertices in space. If it’s a generic solid, it can’t be done.

Here is a stripped out version from my custom python library for a geometry object.
In this case the object must be a 3D type (Mesh, Extrude, 3DPoly, Nurbs, etc); And this is only for the 3D bounding box points. Josh is right, if its a mesh object, there are function calls to get the actual vertex points.

```import vs

class GEOMETRY3D():
class POINT3D():
def __init__(self, x, y, z):
self.x = x
self.y = y
self.z = z

def __sub__(self, other):
self.x -= other.x
self.y -= other.y
self.z -= other.z

self.x += other.x
self.y += other.y
self.z += other.z

def mid_point_to_other_point(self, other_point):
return

def length_to_other_point(self, other_point):
return

def get_offset_pt(self, offsetX=0, offsetY=0, offsetZ=0):
return GEOMETRY3D.POINT3D(self.x + offsetX, self.y + offsetY, self.z + offsetZ)

def __init__(self, handle):
self.handle = handle
self.generate_bounding_box()

def generate_bounding_box(self):
self.top_center = GEOMETRY3D.POINT3D(self.center.x, self.center.y, self.center.z + (self.depth / 2))
self.bottom_center = GEOMETRY3D.POINT3D(self.center.x, self.center.y, self.center.z - (self.depth / 2))

self.top_back_left = self.top_center.get_offset_pt(-self.width / 2, self.height / 2)
self.top_back_right = self.top_center.get_offset_pt(self.width / 2, self.height / 2)
self.top_front_right = self.top_center.get_offset_pt(self.width / 2, -self.height / 2)
self.top_front_left = self.top_center.get_offset_pt(-self.width / 2, -self.height / 2)

self.bottom_back_left = self.bottom_center.get_offset_pt(-self.width / 2, self.height / 2)
self.bottom_back_right = self.bottom_center.get_offset_pt(self.width / 2, self.height / 2)
self.bottom_front_right = self.bottom_center.get_offset_pt(self.width / 2, -self.height / 2)
self.bottom_front_left = self.bottom_center.get_offset_pt(-self.width / 2, -self.height / 2)

@property
def bounding_box_points(self):
"""
:return:
"""
return self.top_back_left, self.top_back_right, self.top_front_right, self.top_front_left, self.bottom_back_left, self.bottom_back_right, self.bottom_front_right, self.bottom_front_left

@property
def center(self):
ptxy, z = vs.Get3DCntr(self.handle)
return GEOMETRY3D.POINT3D(ptxy[0], ptxy[1], z)

@property
def height(self):
return vs.Get3DInfo(self.handle)[0]

@property
def width(self):
return vs.Get3DInfo(self.handle)[1]

@property
def depth(self):
return vs.Get3DInfo(self.handle)[2]

# obj3D = GEOMETRY3D(vs.FSActLayer())
# for x in obj3D.bounding_box_points:
#     vs.Locus3D(x.x, x.y, x.z)```

55 minutes ago, JBenghiat said:

This depends on the type of object, which is easier if you’re intentionally creating objects for export.

The only object that gives you actual vertices is a mesh. If the objects are extrudes, you need to get the points off the planar base, the do the math to get the vertices in space. If it’s a generic solid, it can’t be done.

so i've made some great progress with vs.ConvertTo3DPolys() and vs.GetPolyPt3D() to convert whatever selected symbols to polys. seems to be working great. ill post some source code once i work out a few kinks!

@twk i can't use bounding box because i need the actual geometry polys. i've worked it out. will post a sample after i work some kinks out.

Edited by Jayme McColgan

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

×   Pasted as rich text.   Restore formatting

Only 75 emoji are allowed.

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×

• KBASE
• #### MARIONETTE

×
• Create New...