save plugins Fusion 360
This commit is contained in:
1
zoom_test/.env
Normal file
1
zoom_test/.env
Normal file
@@ -0,0 +1 @@
|
||||
PYTHONPATH=C:/Users/bartool/AppData/Local/Autodesk/webdeploy/production/9209df45963e1599ff476303834125d21fd43de4/Api/Python/packages
|
||||
20
zoom_test/.vscode/launch.json
vendored
Normal file
20
zoom_test/.vscode/launch.json
vendored
Normal 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"
|
||||
}]
|
||||
}
|
||||
5
zoom_test/.vscode/settings.json
vendored
Normal file
5
zoom_test/.vscode/settings.json
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"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.pythonPath": "C:/Users/bartool/AppData/Local/Autodesk/webdeploy/production/9209df45963e1599ff476303834125d21fd43de4/Python/python.exe"
|
||||
}
|
||||
10
zoom_test/zoom_test.manifest
Normal file
10
zoom_test/zoom_test.manifest
Normal file
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"autodeskProduct": "Fusion360",
|
||||
"type": "script",
|
||||
"author": "",
|
||||
"description": {
|
||||
"": ""
|
||||
},
|
||||
"supportedOS": "windows|mac",
|
||||
"editEnabled": true
|
||||
}
|
||||
65
zoom_test/zoom_test.py
Normal file
65
zoom_test/zoom_test.py
Normal file
@@ -0,0 +1,65 @@
|
||||
# Author-
|
||||
# Description-
|
||||
|
||||
import adsk.core
|
||||
import adsk.fusion
|
||||
import adsk.cam
|
||||
import traceback
|
||||
|
||||
|
||||
def run(context):
|
||||
ui = None
|
||||
try:
|
||||
app = adsk.core.Application.get()
|
||||
ui = app.userInterface
|
||||
|
||||
zoom_camera(app, app.activeViewport)
|
||||
# ui.messageBox('Hello script')
|
||||
|
||||
except:
|
||||
if ui:
|
||||
ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))
|
||||
|
||||
|
||||
def zoom_camera(app: adsk.core.Application, view: adsk.core.Viewport):
|
||||
try:
|
||||
camera = view.camera
|
||||
eye = camera.eye
|
||||
target = camera.target
|
||||
|
||||
eye_x = eye.x
|
||||
eye_y = eye.y
|
||||
eye_z = eye.z
|
||||
|
||||
tgt_x = target.x
|
||||
tgt_y = target.y
|
||||
tgt_z = target.z
|
||||
|
||||
eye_tgt_vector = eye.vectorTo(target)
|
||||
|
||||
eye_tgt_vector.scaleBy(0.5)
|
||||
|
||||
new_x = eye_tgt_vector.asPoint().x
|
||||
new_y = eye_tgt_vector.asPoint().y
|
||||
new_z = eye_tgt_vector.asPoint().z
|
||||
# eye.set(eye_x - new_x, eye_y - new_y, eye_z - new_z)
|
||||
eye = adsk.core.Point3D.create(
|
||||
eye_x - new_x, eye_y - new_y, eye_z - new_z)
|
||||
# eye.translateBy(eye_tgt_vector)
|
||||
eye = adsk.core.Point3D.create(100, 100, 100)
|
||||
camera.eye = eye
|
||||
fit = camera.isFitView
|
||||
base = camera.viewExtents
|
||||
base = base*2
|
||||
camera.viewExtents = base
|
||||
view.camera = camera
|
||||
view.refresh()
|
||||
|
||||
ui = app.userInterface
|
||||
ui.messageBox('Eye: {0}, {1}, {2} \ntarget: {3}, {4}, {5}'.format(
|
||||
eye.x, eye.y, eye.z, target.x, target.y, target.z))
|
||||
|
||||
except:
|
||||
ui = app.userInterface
|
||||
if ui:
|
||||
ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))
|
||||
Reference in New Issue
Block a user