JesusFreke / lalboard

A 3D-printed keyboard inspired by the DataHand
http://lalboard.com
Other
817 stars 56 forks source link

Unable to build the Fusion 360 Model: TypeError: create() missing 1 required positional argument: 'z' #12

Closed ripxorip closed 2 years ago

ripxorip commented 2 years ago

Hi, super interesting project! I want to be able to simply build the model and poke around to see all the details in fusion 360. When I try to run the python script like this:

`

$env:PYTHONPATH = "C:\Users\ripxo\AppData\Roaming\Autodesk\Autodesk Fusion 360\API\Python\defs;C:\Users\ripxo\AppData\Roaming\Autodesk\Autodesk Fusion 360\API\AddIns\fscad_addin\src\fscad"

C:/Users/ripxo/AppData/Local/Autodesk/webdeploy/production/849db2e62eaf03702e1167dc7313a6f88a8f47d0/Python/python.exe .\lalboard.py

`

I get the following error:

Traceback (most recent call last): File ".\lalboard.py", line 27, in <module> from fscad import * File "C:\Users\ripxo\AppData\Roaming\Autodesk\Autodesk Fusion 360\API\AddIns\fscad_addin\src\fscad\fscad.py", line 1099, in <module> class Component(BoundedEntity, ABC): File "C:\Users\ripxo\AppData\Roaming\Autodesk\Autodesk Fusion 360\API\AddIns\fscad_addin\src\fscad\fscad.py", line 1121, in Component _origin = Point3D.create(0, 0, 0) TypeError: create() missing 1 required positional argument: 'z'

Has the Fusion360 API got updated so that it is messing with fscad somehow? Thanks in advande

ripxorip commented 2 years ago

I just realized when browsing through the code that the ....\defs folder appeared to be a mock of some kind so I updated the path:

$env:PYTHONPATH = "C:\Users\ripxo\AppData\Local\Autodesk\webdeploy\production\849db2e62eaf03702e1167dc7313a6f88a8f47d0\Api\Python\packages;C:\Users\ripxo\AppData\Roaming\Autodesk\Autodesk Fusion 360\API\AddIns\fscad_addin\src\fscad"

But now it fails to load some DLL:

Traceback (most recent call last): File ".\lalboard.py", line 20, in <module> import adsk.core File "C:\Users\ripxo\AppData\Local\Autodesk\webdeploy\production\849db2e62eaf03702e1167dc7313a6f88a8f47d0\Api\Python\packages\adsk\core.py", line 13, in <module> from . import _core ImportError: DLL load failed: The specified module could not be found.

ripxorip commented 2 years ago

(I am trying to run it straight from Powershell since it fails without any info when trying to run the script from within Fusion 360)

ripxorip commented 2 years ago

I think I am getting somewhere... I have realized that you need IntelliJ and your plugins to inject in to Fusion 360. I have one through the hassle of downloading and installing IDEA and the plugins. I have set up the source of this repo as a project and configured it accordningly. When I now try to build the model I get the following error:

Unhandled exception while importing and running script. Traceback (most recent call last): File "C:/Users/ripxo/AppData/Roaming/Autodesk/Autodesk Fusion 360/API/AddIns/fusion_idea_addin/fusion_idea_addin.py", line 340, in notify spec.loader.exec_module(module) File "", line 728, in exec_module File "", line 219, in _call_with_frames_removed File "C:\dev\lalboard\lalboard.py", line 516, in def find_tangent_intersection_on_circle(circle: Circle, point: Point3D): NameError: name 'Circle' is not defined

Seems like something is not imported correctly?

JesusFreke commented 2 years ago

The script has to be run inside of fusion 360. The easiest way to do this is just by adding it as a script in the "scripts and add-ins" dialog. But if you want to get a full development environment set up, you can install intellij idea (community edition is fine) and use my fusionidea plugin to inject the script into fusion and run it that way. See here for more details on that route - although it looks like this may be slightly out of date. I'll try and get it updated :)

In either case, you'll need to ensure that fscad has been installed in fusion 360. See https://github.com/JesusFreke/fscad/wiki/Installation

ripxorip commented 2 years ago

Thanks for the reply. I have went down the route of the fusionidea plugin. And this:

Unhandled exception while importing and running script. Traceback (most recent call last): File "C:/Users/ripxo/AppData/Roaming/Autodesk/Autodesk Fusion 360/API/AddIns/fusion_idea_addin/fusion_idea_addin.py", line 340, in notify spec.loader.exec_module(module) File "", line 728, in exec_module File "", line 219, in _call_with_frames_removed File "C:\dev\lalboard\lalboard.py", line 516, in def find_tangent_intersection_on_circle(circle: Circle, point: Point3D): NameError: name 'Circle' is not defined

Is infact from Fusion 360 so I have a connection :) I have installed both plugins in Fusion 360, fscad and ideafusion. It seems that when running in Fusion 360 it is having a problem referecing classes from the "from fscad import *" ?

ripxorip commented 2 years ago

My guess is that something goes wrong when adding the fscad plugin as a dependency?

JesusFreke commented 2 years ago

Also note that the lalboard.py script itself doesn't actually create any parts. You'll need to run the script for an individual part or for an assembly, in the parts folder. See, e.g. static_base_left_full_assembly, which should create the full left-hand side, using a "static" base.

ripxorip commented 2 years ago

The script failed to run directly in Fusion 360 without any output, so thats why I continued my investigation and installed IntelliJ etc.

JesusFreke commented 2 years ago

Are you sure fscad is installed as an add-in? And is the add-in running? You may need to set it to auto-run when fusion starts.

JesusFreke commented 2 years ago

Also, make sure you're on the v2_no_stls branch :). I don't think the main (v1) branch is what you want at this point.

ripxorip commented 2 years ago

Yeah fscad_addin is running and set to auto-start. Tried the steel_base_left_full_assembly now and it failed:

Unhandled exception while importing and running script. Traceback (most recent call last): File "C:/Users/ripxo/AppData/Roaming/Autodesk/Autodesk Fusion 360/API/AddIns/fusion_idea_addin/fusion_idea_addin.py", line 342, in notify module.run({"isApplicationStartup": False}) AttributeError: module 'mainC%3A%5Cdev%5Clalboard%5Clalboard_py' has no attribute 'run'

ripxorip commented 2 years ago

Yeah Im on the v2_no_stls now :)

JesusFreke commented 2 years ago

Yeah, looking at the main branch, that Circle error makes sense, since fscad has been slightly restructured, so it requires slightly different imports now. Hopefully the v2_no_stls branch should work fine though.

JesusFreke commented 2 years ago

Oh, you probably want to restart fusion at this point. Just to clear out any lingering loaded scripts from when you were using the main branch.

ripxorip commented 2 years ago

Score! It works, managed to run the part manually without IntelliJ straight in Fursion360 :) However using IntelliJ:

Unhandled exception while importing and running script. Traceback (most recent call last): File "C:/Users/ripxo/AppData/Roaming/Autodesk/Autodesk Fusion 360/API/AddIns/fusion_idea_addin/fusion_idea_addin.py", line 342, in notify module.run({"isApplicationStartup": False}) AttributeError: module 'mainC%3A%5Cdev%5Clalboard%5Clalboard_py' has no attribute 'run'

Still a win since I now can look at the full model in Fusion 360 :) Thank you very much for this project and for the support

JesusFreke commented 2 years ago

It looks like it's still trying to run lalboard.py instead of the individual part script

ripxorip commented 2 years ago

Correct, I am a IDEA noob... First time using it. Now it runs the part script:

Unhandled exception while importing and running script. Traceback (most recent call last): File "C:/Users/ripxo/AppData/Roaming/Autodesk/Autodesk Fusion 360/API/AddIns/fusion_idea_addin/fusion_idea_addin.py", line 342, in notify module.run({"isApplicationStartup": False}) File "C:\dev\lalboard\parts\static_base_left_full_assembly\static_base_left_full_assembly.py", line 83, in run lalboard.run_design(design, context=context) File "C:\dev\lalboard\lalboard.py", line 3415, in run_design filename = module.file AttributeError: 'NoneType' object has no attribute 'file'

ripxorip commented 2 years ago

Still very happy that generation using "script" in Fusion 360 works. This project is amazing! Mad skills all over. I will try to build a version sourcing what I can find in terms of magnets etc here in Sweden. Now Im able to tweak it if I need to 👍

ripxorip commented 2 years ago

Now I got the IntelliJ plugin working as well. In my desperation I messed with the depencies path in IntelliJ, I now remebered that I had to restore it to your instructions and it works :) Once again, a huge thank you!