Le0Michine / FusionGridfinityGenerator

Other
629 stars 40 forks source link

`baseGenerator.createBaseWithClearance` causing crash in Gridfinity baseplate and Gridfinity bin (with lip) #40

Closed DavidGeorge528 closed 11 months ago

DavidGeorge528 commented 11 months ago

Just installed this plugin in a fresh install of Fusion 360 on my MacBook Air.

When I try to generate a Gridfinity bin, everything seems to work fine, until I enable Generate lip for stickability, which then produces the following error:

Error: An unknonwn error occurred, please validate your inputs and try again:
Traceback (most recent call last):
  File "/Users/david/Library/Containers/com.autodesk.mas.fusion360/Data/Library/Application Support/Autodesk/ApplicationPlugins/GridfinityGenerator.bundle/Contents/commands/commandCreateBin/entry.py", line 927, in generateBin
    binBody = createGridfinityBinBody(
  File "/Users/david/Library/Containers/com.autodesk.mas.fusion360/Data/Library/Application Support/Autodesk/ApplicationPlugins/GridfinityGenerator.bundle/Contents/lib/gridfinityUtils/binBodyGenerator.py", line 75, in createGridfinityBinBody
    lipBody = createGridfinityBinBodyLip(lipInput, targetComponent)
  File "/Users/david/Library/Containers/com.autodesk.mas.fusion360/Data/Library/Application Support/Autodesk/ApplicationPlugins/GridfinityGenerator.bundle/Contents/lib/gridfinityUtils/binBodyLipGenerator.py", line 115, in createGridfinityBinBodyLip
    lipCutout = baseGenerator.createBaseWithClearance(lipCutoutInput, targetComponent)
  File "/Users/david/Library/Containers/com.autodesk.mas.fusion360/Data/Library/Application Support/Autodesk/ApplicationPlugins/GridfinityGenerator.bundle/Contents/lib/gridfinityUtils/baseGenerator.py", line 227, in createBaseWithClearance
    extendFeature = features.extendFeatures.add(extendClearanceSurfaceFeatureInput)
  File "/Users/david/Library/Application Support/Autodesk/webdeploy/production/f062eb7fe2b3f339ca6929f181b828b841f39073/Autodesk Fusion 360.app/Contents/Api/Python/packages/adsk/fusion.py", line 20182, in add
    return _fusion.ExtendFeatures_add(self, input)
RuntimeError: 5 : Some input argument is invalid.

Additionally, if I try to produce any Gridfinity baseplate (using any configuration) I get the following error:

Error: An unknonwn error occurred, please validate your inputs and try again:
Traceback (most recent call last):
  File "/Users/david/Library/Containers/com.autodesk.mas.fusion360/Data/Library/Application Support/Autodesk/ApplicationPlugins/GridfinityGenerator.bundle/Contents/commands/commandCreateBaseplate/entry.py", line 313, in generateBaseplate
    baseplateBody = createGridfinityBaseplate(baseplateGeneratorInput, gridfinityBaseplateComponent)
  File "/Users/david/Library/Containers/com.autodesk.mas.fusion360/Data/Library/Application Support/Autodesk/ApplicationPlugins/GridfinityGenerator.bundle/Contents/lib/gridfinityUtils/baseplateGenerator.py", line 16, in createGridfinityBaseplate
    baseBody = baseGenerator.createBaseWithClearance(cutoutInput, targetComponent)
  File "/Users/david/Library/Containers/com.autodesk.mas.fusion360/Data/Library/Application Support/Autodesk/ApplicationPlugins/GridfinityGenerator.bundle/Contents/lib/gridfinityUtils/baseGenerator.py", line 227, in createBaseWithClearance
    extendFeature = features.extendFeatures.add(extendClearanceSurfaceFeatureInput)
  File "/Users/david/Library/Application Support/Autodesk/webdeploy/production/f062eb7fe2b3f339ca6929f181b828b841f39073/Autodesk Fusion 360.app/Contents/Api/Python/packages/adsk/fusion.py", line 20182, in add
    return _fusion.ExtendFeatures_add(self, input)
RuntimeError: 5 : Some input argument is invalid.

The common function call between the two seems to be baseGenerator.createBaseWithClearance. I've tried to dig into the code to debug it, but I've never worked on a Fusion 360 plugin, so I'm not sure where to start. The error states there are some invalid input arguments, but it seems everything is set properly.

I have also tried with both the Fusion 360 plugin download and the manual git install.

I will carry on debugging, but posting this there to bring light to the issue I'm facing.

Fusion 360 Info:

Fusion 360 2.0.16753 arm64 [Native] 
Active Plan: Personal
macOS 14.0 (23A5301g) on Mac14,15
DavidGeorge528 commented 11 months ago

I'm starting to think there is a bug with Fusion 360's internal extendFeatures.add() function in the latest version. As even when I try inputs that should work from examples online, I still get the same error

Le0Michine commented 11 months ago

I tried to look at it, so far it seems something has changed on Fusion side again.

in v2.0.16490 everything is fine in v2.0.16753 it breaks

error is coming from this extend feature https://github.com/Le0Michine/FusionGridfinityGenerator/blob/master/lib/gridfinityUtils/baseGenerator.py#L227

I suspect there might be an issue with this line now https://github.com/Le0Michine/FusionGridfinityGenerator/blob/master/lib/gridfinityUtils/baseGenerator.py#L220, it takes a body from array assuming there is only one offsetFacesFeature.bodies.item(0) which is true in v2.0.16490 but when I look at v2.0.16753 it shows two bodies in that list

Le0Michine commented 11 months ago

looks like offsetFeature includes not only offset surface body but also the solid body those faces were used to create offset

Le0Michine commented 11 months ago

updated code to filter bodies by isSolid property. Should fix the issue, let me know if you still see it

Le0Michine commented 11 months ago

getting fix uploaded to the app store will take a few weeks

DavidGeorge528 commented 11 months ago

Perfect, thanks for the quick investigation and fix. Just pulled master and re-installed the plugin and both the baseplate and bin with stackable lip now function properly for me.

cspiron commented 11 months ago

Perfect, thanks for the quick investigation and fix. Just pulled master and re-installed the plugin and both the baseplate and bin with stackable lip now function properly for me.

What do you mean by "pulled the master"??

Le0Michine commented 11 months ago

Most likely installation from source code described in reader here https://github.com/Le0Michine/FusionGridfinityGenerator

the next release with the fix is prepared but it is pending review in autodesk app store, that will likely take a couple weeks