- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello, I am currently working on a project that requires me to export images of each component/occurence in my designs. I would like to grab an iso, top, front, and right image of each, to export, and I'm doing so with the code below.
Functionally, this seems to sort-of work (the images seem to drift off the bodies a bit sometimes). The biggest problem though, and the reason for this post, is that each time I adjust the camera and reassign it to the viewport, the viewport updates in the ui while the script is running. This makes the whole program wait while the viewport transitions on-screen for me, and slows down the program considerably, especially when I have a file with many components.
With the goHome command I can set transitions to false to avoid this problem, is there any way to do it here as well, or am I screwed with long processing times?
def export_as_image(occ, path, uuid):
app = adsk.core.Application.get()
if os.path.exists(path+"/design-package/payload/components/" + uuid) == False:
os.mkdir(path+"/design-package/payload/components/" + uuid)
os.mkdir(path+"/design-package/payload/components/" + uuid + "/images")
# isolate the occurence requested
occ.isIsolated = True
vp = app.activeViewport
camera = app.activeViewport.camera
# grab images at different angles and save them
vp.goHome(False)
vp.saveAsImageFile(path+"/design-package/payload/components/" + uuid + "/images/iso.png", 720, 720)
camera.viewOrientation = adsk.core.ViewOrientations.TopViewOrientation
camera.isFitView = True
vp.camera = camera
vp.saveAsImageFile(path+"/design-package/payload/components/" + uuid + "/images/top.png", 720, 720)
camera.viewOrientation = adsk.core.ViewOrientations.RightViewOrientation
camera.isFitView = True
vp.camera = camera
vp.saveAsImageFile(path+"/design-package/payload/components/" + uuid + "/images/right.png", 720, 720)
camera.viewOrientation = adsk.core.ViewOrientations.FrontViewOrientation
camera.isFitView = True
vp.camera = camera
vp.saveAsImageFile(path+"/design-package/payload/components/" + uuid + "/images/front.png", 720, 720)
# unisolate the occurence
occ.isIsolated = False
Thanks a bunch for any help
Solved! Go to Solution.