- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi! I'm new to F360 scripting and trying to work my way through the object model.
I'm trying to put together a script to do the following:
- Hides all sketch points on all sketched
- Sets the camera to the TopViewOrientation.
- Sets the Current view as Home ->Fit to View
Here's what I have so far:
import adsk.core, adsk.fusion, adsk.cam, traceback
def run(context):
ui = None
try:
app = adsk.core.Application.get()
ui = app.userInterface
product = app.activeProduct
design = adsk.fusion.Design.cast(product)
vp = app.activeViewport
#ui.messageBox('Start')
# Hide sketch points in all sketches
for component in design.allComponents:
for sketch in component.sketches:
sketch.arePointsShown = False
#Re-set Home
cam = vp.camera
cam.viewOrientation = adsk.core.ViewOrientations.TopViewOrientation
cam.isFitView = True
vp.camera = cam
except:
if ui:
ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))
There are two problems that I'm running into:
- Sometimes, but not always, the TopViewOrientation is rotated by 90 degrees.
- I can't figure out how to set the current view as the new Home -> Fit to View
So, what I end up doing is having to manually rotate the view using the rotation arrows. And, even if the TopViewOrientation is correctly oriented, I still have to manually set the current view as home. I don't get why I have to sometimes rotate the view 90 degrees. And I cannot find a way through my review of the object model to be able to set the current view to Home.
I'm attaching a sample file here. When I run the script on this file, the TopViewOrientation is rotated 90 degrees clockwise. I have to manually rotate the view 90 degrees counterclockwise.
Any help is appreciated! Thank you!
Jonathan
Solved! Go to Solution.