Author Topic: Script that can remove imported cameras  (Read 2033 times)

0 Members and 1 Guest are viewing this topic.

Script that can remove imported cameras
« on: June 29, 2021, 01:55:34 am »
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

Re: Script that can remove imported cameras
« Reply #1 on: June 29, 2021, 05:10:03 am »
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()

Re: Script that can remove imported cameras
« Reply #2 on: June 29, 2021, 06:02:54 am »
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

Offline INNEO_MWo

  • Hero Member
  • *****
  • Posts: 1239
  • Total likes: 69
  • Senior Technical Consultant @ INNEO (Germany)
    • german KeyShot page from INNEO Solutions
Re: Script that can remove imported cameras
« Reply #3 on: June 29, 2021, 11:16:17 am »
That is a very helpful script for all the Creo KeyShot users.
Thanks for sharing!