Error while editing CustomFeature from CustomPocket sample code

Error while editing CustomFeature from CustomPocket sample code

mcd8604
Enthusiast Enthusiast
375 Views
2 Replies
Message 1 of 3

Error while editing CustomFeature from CustomPocket sample code

mcd8604
Enthusiast
Enthusiast

I ran into this error while working on my own CustomFeature but I am also able to reproduce it using the downloaded CustomPocket sample code:

 

 

Execute: Traceback (most recent call last):
  File "C:/Users/mcd86/AppData/Roaming/Autodesk/Autodesk Fusion 360/API/AddIns/CustomPocket/CustomPocket.py", line 320, in notify
    eventArgs.command.beginStep()
  File "C:/Users/mcd86/AppData/Local/Autodesk/webdeploy/production/96174d2c4918a1a613b00371fd422e0f30e1d187/Api/Python/packages\adsk\core.py", line 5179, in beginStep
    return _core.Command_beginStep(self, makeExistingStepNonUndoable)
RuntimeError: 3 : Associated feature is invalid.

 

 

It occurs when editing the CustomFeature. Completing a camera pan or orbit appears to be firing the Activate event for the edit command which then calling beginStep.

0 Likes
376 Views
2 Replies
Replies (2)
Message 2 of 3

kandennti
Mentor
Mentor

Hi @mcd8604 .

 

I also experienced that error.

"FusionBoxer" published by @prainsberry  does not have that error, so there seems to be a way to avoid the error, but I did not look into it in detail.

 

However, if you run FusionBoxer as is, you will get the error.

https://github.com/tapnair/FusionBoxer/blob/master/commands/OffsetBoundingBoxCommand.py#L438 

This is because the parameters of the CustomFeatures.createInput method were changed in an update a while ago, but it has not been fixed.

 

The error can be avoided by modifying the method as follows

・・・
            custom_features = new_comp.features.customFeatures
            inputs = custom_features.createInput(config.custom_feature_definition)
            inputs.setStartAndEndFeatures(base_feature, base_feature)
・・・

 

0 Likes
Message 3 of 3

mcd8604
Enthusiast
Enthusiast

I see that the modification breaks the custom_features.createInput and setStartAndEndFeatures into two calls instead of one. I am left puzzled because the CustomPocket sample code already does this:

 

custFeatInput = comp.features.customFeatures.createInput(_customFeatureDef)
custFeatInput.setStartAndEndFeatures(baseFeat, combineFeature)

 

 

0 Likes