save plugins Fusion 360

This commit is contained in:
2022-09-21 21:50:43 +02:00
commit 5a41c6454a
74 changed files with 1988 additions and 0 deletions

1
demo/.env Normal file
View File

@@ -0,0 +1 @@
PYTHONPATH=C:/Users/bartool/AppData/Local/Autodesk/webdeploy/production/9209df45963e1599ff476303834125d21fd43de4/Api/Python/packages

20
demo/.vscode/launch.json vendored Normal file
View File

@@ -0,0 +1,20 @@
{
"version": "0.2.0",
"configurations": [{
"name": "Python: Attach",
"type": "python",
"request": "attach",
"pathMappings": [{
"localRoot": "${workspaceRoot}",
"remoteRoot": "${workspaceRoot}"
}],
"osx": {
"filePath": "${file}"
},
"windows": {
"filePath": "${file}"
},
"port": 9000,
"host": "localhost"
}]
}

6
demo/.vscode/settings.json vendored Normal file
View File

@@ -0,0 +1,6 @@
{
"python.autoComplete.extraPaths": ["C:/Users/bartool/AppData/Roaming/Autodesk/Autodesk Fusion 360/API/Python/defs"],
"python.analysis.extraPaths": ["C:/Users/bartool/AppData/Roaming/Autodesk/Autodesk Fusion 360/API/Python/defs"],
"python.defaultInterpreterPath": "C:/Users/bartool/AppData/Local/Autodesk/webdeploy/production/9209df45963e1599ff476303834125d21fd43de4/Python/python.exe",
"python.pythonPath": "C:/Users/bartool/AppData/Local/Autodesk/webdeploy/production/9209df45963e1599ff476303834125d21fd43de4/Python/python.exe"
}

10
demo/demo.manifest Normal file
View File

@@ -0,0 +1,10 @@
{
"autodeskProduct": "Fusion360",
"type": "script",
"author": "",
"description": {
"": ""
},
"supportedOS": "windows|mac",
"editEnabled": true
}

58
demo/demo.py Normal file
View File

@@ -0,0 +1,58 @@
# Fusion360API Python script
import adsk.core, adsk.fusion, adsk.cam, traceback
import math, random
# Number of divisions during one revolution
COUNT = 60
def run(context):
ui = None
try:
app: adsk.core.Application = adsk.core.Application.get()
ui = app.userInterface
# get state
vi :adsk.core.Viewport = app.activeViewport
camera :adsk.core.Camera = vi.camera #This is a deep copy.
eye :adsk.core.Point3D = camera.eye
tgt :adsk.core.Point3D = camera.target
up :adsk.core.Vector3D = camera.upVector
baseArea = camera.viewExtents
# get matrix
front :adsk.core.Vector3D = eye.vectorTo(tgt)
right :adsk.core.Vector3D = up.copy()
right = right.crossProduct(front)
mat :adsk.core.Matrix3D = adsk.core.Matrix3D.create()
mat.setWithCoordinateSystem(tgt, right, front, up)
# get position & ratio
unit = math.radians(360 // COUNT)
rads = [unit] * COUNT
ratios = [random.uniform(0.1, 5.0) for _ in range(COUNT)]
if 360 % COUNT != 0:
rads.append(math.radians(360 % COUNT))
ratios.append(1)
# show
camera.isSmoothTransition = False
for rad, ratio in zip(rads, ratios):
mat.setToRotation(rad, up, tgt)
eye.transformBy(mat)
up.transformBy(mat)
mat.setToRotation(rad, right, tgt)
eye.transformBy(mat)
up.transformBy(mat)
# mat.setToRotation(rad, front, tgt)
camera.eye = eye
camera.upVector = up
# zoom = baseArea * ratio
# camera.viewExtents = zoom
vi.camera = camera
vi.refresh()
adsk.doEvents()
except:
if ui:
ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))