Center and fit part/object

Started by rembem, August 17, 2018, 02:37:18 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

rembem

I'm starting to use scripts. I can use the standard one in KeyShot with creating all the camera angle, but I also want to centre and fit the product per camera. Can someone help !!!?
(I will import a product in KeyShot and then create all the angles/cameras)

This is the script from KeyShot:

views = {lux.VIEW_FRONT: "Front",
   lux.VIEW_BACK: "Back",
         lux.VIEW_LEFT: "Left",
         lux.VIEW_RIGHT: "Right",
         lux.VIEW_TOP: "Top",
         lux.VIEW_BOTTOM: "Bottom",
         lux.VIEW_ISOMETRIC: "Isometric"}

for view in views:
    name = "_" + views[view]
    has = False
    if name in lux.getCameras():
        has = True
        lux.setCamera(name)
    else:
        lux.newCamera(name)
    lux.setStandardView(view)
    lux.saveCamera()
    print("{} camera: {}".format("Updated" if has else "Created", name))

... all I need is that it also will center and fit the objects.

Morten Kristensen

Hi Remko,

To center-and-fit a node, you can get the root node via lux.getSceneTree() then you find the node you want to center-and-fit via find() on the root, which returns a list of nodes.