I am new to VC but I need to make a simulation of a cartesian robot that I designed for my master thesis. I would need to import geometry (a metal plate where parts are cut out using a laser) so that the robot can grasp the objects and place them on pallets.
My question was: is there a way so that I can make a python script that asks a uri and opens the part on a specific location? If so, how?
In addition to what KustiH said, you can also pre-position a piece of material in a specific location and then make him invisible, and when needed, use part.clone() or app.cloneComponent(part) to copy it, and of course you’ll need code similar to the following to remove the extra component:
a = part.clone()
temp.append(a)
def OnReset():
for i in temp:
try:
i.delete()
except:
pass
temp = []
Hmm. The Help documentation says the following about the file type filter argument in dialogOpen: “A filter argument defines file extension filter(s) using a standard Windows filter format.” (which is specified further on Microsoft’s page FileDialog.Filter Property (Microsoft.Win32) | Microsoft Learn). I don’t believe the file dialog even allows selecting a folder, or at least I have never seen the default file dialog do so.
I would advise you to implement the folder selection as follows:
User chooses one .stl file from the folder, after which the file path is split to path and filename using os.path.split(). After that, you could loop through the files in the folder with the following syntax:
folder_uri, filename = os.path.split(file_uri)
for root, dirs, files in os.walk(folder_uri):
for file in files:
# Checking for file extension here, and calling appropriate functions
BAD:s comment was a good addition; please remember that importing geometries during a simulation run has drawbacks. Invisible components are one option; creating a product type before simulation run and using a feeder component to spawn these products is one option. Best of luck for your project!