Script that can remove imported cameras

Started by Dion Christensen, June 29, 2021, 01:55:34 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Dion Christensen

Hello everyone

Problem description:
When importing from CREO Parametric. Keyshot converts all view angles into cameras e.g. FRONT, LEFT, RIGHT and so on.
We have over 8000 parts that I need to make new product images for using Keyshot.

My question now is if there is any one here willing to help me make a python script to remove the cameras in question.
The complete list of cameras that need to be removed is:
BACK
BOTTOM
FRONT
LEFT
RIGHT
TOP
STD

What I have been told is that I need to use a combination of getCameras(...) and removeCamera(...)
I just don't know how to code in python so it would be greatly appreciated if someone would help to solve this problem.

//Dion

AutomaticDesign

Hey Dion,
I wrote that little script. You can add new lines for the cameras you want to remove.
Hope it helps.
Don't hesitate to ask if you have any further questions. Just create a new script and add the code.
We do a bunch of automation in KeyShot.
Best Regards
Philipp


# AUTHOR pmeyer
# COMPANY Automatic Design
# WEBSITE https://www.automatic-design.de
# VERSION 1.0.0
# Removes cameras from a defined list.

#function where the cameras are removed
def removeCameras():
    #define remove list
    cameraToRemoveList = []
   
    #add items to remove
    cameraToRemoveList.append("FRONT")
    cameraToRemoveList.append("LEFT")
    cameraToRemoveList.append("RIGHT")
    cameraList = lux.getCameras()

    #iterate over all cameras
    for camera in cameraList:
        #remove if in remove list
        if (camera in cameraToRemoveList):
            lux.removeCamera(camera)

#main function
def main():
    removeCameras()

#start program
main()

Dion Christensen

Hello Philipp

Thanks for the help, it works just as I was hoping for.
Now I just need to automate som things on our server, and press the start button.

//Dion

INNEO_MWo

That is a very helpful script for all the Creo KeyShot users.
Thanks for sharing!