Open A Part Using A Python Script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Can anybody help?
I have a folder called "TEST FILES" that I have created inside the "Project Files" folder.
Inside this "TEST FILES" folder I have a part called "TEST PART".
I can call the routine using the following two variables.
FolderName = "TEST FILES"
PartNumber = "TEST PART"
I can open the "TEST PART" successfully using the following Python code....
def OpenPart(FolderName, PartNumber):
app = adsk.core.Application.get()
proj: core.DataProject = None
for x in app.data.dataProjects.asArray():
if x.name == "Project Files":
proj = x
break
folder: core.DataFolder = None
for x in proj.rootFolder.dataFolders.asArray():
if x.name == FolderName:
folder = x
break
file: core.DataFile = None
for x in folder.dataFiles.asArray():
if x.name == PartNumber:
file = x
break
app.documents.open(file, True)
How can I open a part if the "TEST PART" is located in a folder called:
Project Files > Purchased Parts > Gearboxes > "TEST PART"?
(In the path I have an extra Sub-Folder called "Gearboxes")
Many thanks in advance!
Darren