Custom Feature API Preview - Feedback Thread

Custom Feature API Preview - Feedback Thread

prainsberry
Autodesk Autodesk
14,592 Views
81 Replies
Message 1 of 82

Custom Feature API Preview - Feedback Thread

prainsberry
Autodesk
Autodesk

Fusion 360 Custom Feature APIFusion 360 Custom Feature API

 

 

 

 

 

 

 

With the release of Fusion 360 today, we are very excited to announce the availability of a preview of the new Custom Feature API.  This is a long-awaited capability for the Fusion 360 API and our first iteration is now available Please note we are considering this “Preview” functionality as there are some limitations and only some specific workflows that we support That said this a MAJOR enhancement to the Fusion 360 API 

 

You can now not only define a custom command dialog for your add-in, but you can actually define it as a full feature definition This means that parametric timeline updates, model parameter changes and user edits will all now behave as expected for any other feature in Fusion 360 There is a lot of information to digest for this one, so if this interests you, check out our help documentation and learn more about this functionality. 

 

We would love to hear more about how you would like to use it, what you have built, or would like to build.  We would like to use this thread to capture feedback about the current capabilities, as well as what you would like to see next.  



Patrick Rainsberry
Developer Advocate, Fusion 360
14,593 Views
81 Replies
Replies (81)
Message 2 of 82

kandennti
Mentor
Mentor

I noticed that the Document was updated yesterday.
I am looking forward to it, but Fusion360 is not updated.

0 Likes
Message 3 of 82

kandennti
Mentor
Mentor

The update was successful, and I tried both "Round Emboss" and "Custom Pocket".
I'm very impressed.

 

Using the Custom Feature, I saved the document with the history in the timeline and closed it.
When I stop the add-in and reopen the saved document, I lose the timeline icon. (I think that's the correct behavior.)

1.png

There seems to be no problem in editing the part after the Custom Feature, but editing the part before the Custom Feature (even if it does not affect you.) results in an error. (I think that's the correct behavior.)


If you have a long timeline, it's likely that you won't notice it just from the icons.

 

If the add-in you need is not running when you open it in a document or when it becomes active, why not warn you in the lower right part of the screen?

2.png

 

 

 

 

Message 4 of 82

prainsberry
Autodesk
Autodesk

Hey thanks @kandennti thats great feedback.  You are correct that it is expected behavior.  We went back and forth on how obtrusive the error should be, but I like this idea and will see if we can get it in.   We are also considering some idea about how we could better inform the user of the app that is needed for the given feature, but that is tied into a little bit bigger project.  



Patrick Rainsberry
Developer Advocate, Fusion 360
Message 5 of 82

kandennti
Mentor
Mentor

Thanks @prainsberry .

 

I'm sure you've probably already noticed this.


First, create three points on your sketch.
Use each point to create a "Hole", a "Custom Pocket" and a "Round Emboss".
Then, delete all the points in the sketch.
The timeline should look like this

2.png

Only the "Custom Pocket" did not turn yellow.


The difference between "Custom Pocket" and "Round Emboss" is as follows
・Whether the base feature is used or not
・Whether customFeatureCompute event is used or not
But I couldn't figure out what makes the difference.


I would like to have a mechanism to turn the timeline yellow when a CustomFeature of type "Custom Pocket" also loses the entity it references.


However, I think it would be better if the add-in developer decides when the timeline turns yellow, instead of automatically detecting that the CustomFeatureDependency.entity in the custFeature.dependencies property is None.


I'm imagining this in the future, but let's say you create a CustomFeature that allows you to select an entity with some options, and you execute "None" in CreateExecute.

 

custFeatInput.addDependency('optionPoint', None)

 

In EditExecute, this is a situation where the user needs to specify an option and execute it.

 

optionPoint = optionSelectInput.selection(0).entity
dependency =_editedCustomFeature.dependencies.itemById('optionPoint')
dependency.entity = optionPoint

 

 I really don't know if such a situation will ever come up.
Still, it would be nice if the add-in developer could specify when to turn the timeline yellow.

 

Thank you for your consideration.

 

 

 

I'd like to tell you about another thing I noticed.

In the description of CustomFeatureInput Object in the document, it says "Ruled Surface feature", but I read it as "Custom Feature".
There seem to be two places.

1.png

https://help.autodesk.com/view/fusion360/ENU/?guid=GUID-36B1FFB5-5291-4532-8F11-90E912769B34 

https://help.autodesk.com/view/fusion360/ENU/?guid=GUID-16A01374-4A10-44D7-BAC1-D2D3395C3024 

 

0 Likes
Message 6 of 82

kandennti
Mentor
Mentor

Fusion360 Ver2.0.9642.

 

I am thinking of using IntegerSpinnerCommandInput.
In the addCustomParameter method, I add a ValueInput without a unit, but it is forced to have a unit of length and is registered in the model parameter.

https://help.autodesk.com/view/fusion360/ENU/?guid=GUID-3A7333B1-CAC7-44F2-84C9-40938EDAC464 

 

I take it as "ValueInput without unit is not supported at present".
So, I looked for something suitable and found that "pcs" could be used.

1.png

Message 7 of 82

BrianEkins
Mentor
Mentor

@kandennti, This is some great feedback.  I've been doing some testing of custom features too and believe I've also found some issues.  I know this is why it's in preview so that others can begin experimenting and helping to find issues. Even with its current limitations, there are still many ways it can be used so the more people testing the more likely those issues will be identified.

 

Everything you've identified so far are good suggestions and valid issues that need to be investigated. The only one that I may be seeing something different is your earlier comment about warning the user when a design is opened that contains a custom feature and the add-in isn't running. If I change the model in a way that changes one of its inputs so the feature computes, the timeline icon changes to yellow and there is a message in the lower-right corner.  Personally, I think this is good behavior. I don't want the dialog to pop up just by opening the design. If I don't do anything to the model, there isn't anything wrong with it so there's no reason to warn the user.

---------------------------------------------------------------
Brian Ekins
Inventor and Fusion 360 API Expert
Website/Blog: https://EkinsSolutions.com
Message 8 of 82

kandennti
Mentor
Mentor

Thank you, @BrianEkins .

 

Now that you mention it, I think it would be sufficient to just give a warning when you make a change.


This is a continuation of the story about the "Custom Pocket" not turning yellow when deleting a sketch point that has a reference to it.
I have confirmed that if I delete a sketch point with a fillet attached to the "Custom Pocket", it changes to yellow and a warning appears.

1.png


I am very much looking forward to the official release of CustomFeature.

0 Likes
Message 9 of 82

BrianEkins
Mentor
Mentor

I realized the issue with the timeline node not turning yellow is associated with the issue you brought up earlier about not being able to indicate that the compute failed.  In this case, the add-in is attempting to get the sketch dependent point and that is failing so the rest of the compute fails.  Currently, Fusion assumes if the add-in is there that the compute was successful so it doesn't change the color of the node.  The add-in needs to be able to specify if the compute was actually successful or not. I think that has to be done before it can be released.

---------------------------------------------------------------
Brian Ekins
Inventor and Fusion 360 API Expert
Website/Blog: https://EkinsSolutions.com
Message 10 of 82

nnikbin
Collaborator
Collaborator

The missing part of Fusion 360 excellent API! It is a game changer for add-in developers! 

0 Likes
Message 11 of 82

debreuil
Participant
Participant

Really loving the Custom Feature feature, it's allowing work at a much higher level of abstraction for specific tasks.

 

One issue I'm running in to, when including selected items in a custom feature's edit mode, pan or zoom will deselect everything in there. This happens with the point selection in the CustomPocket sample, as well the feature I'm working on, so I think it is a general thing.

 

I understand selected items are not yet supported for edit mode, but this does seem a little strange so reporting it just in case it is useful. Also on the off chance there is a workaround where I could reattach the selection. It doesn't  fire the InputChanged or Validate events (even though it will dim the OK button), as expected it doesn't get mouse events, and I don't see a way to get viewPort events like for pan.

 

Not a showstopper or anything, I do have editing elections more or less working for my needs, and I can just avoid panning :).

0 Likes
Message 12 of 82

prainsberry
Autodesk
Autodesk

Thanks, this is great feedback.   I think it is possible to do what you want, but I'd like to better understand it.  I'd also be very interested to just get some more detailed feedback.  Sending you a DM right now.  



Patrick Rainsberry
Developer Advocate, Fusion 360
Message 13 of 82

nnikbin
Collaborator
Collaborator

For a relatively long time now, when I come to the forum, first I look to see how many comments this post has and I am surprised to see that it still has 11 comments (from now on it will be 12). I hope to hear new news about Custom Feature API soon. I also hope more users who have experience working with this important feature will share their valuable experiences.

Message 14 of 82

kandennti
Mentor
Mentor

@nnikbin .

 

When Custom Features was added, I started to develop this add-in as a test.

https://forums.autodesk.com/t5/fusion-360-design-validate/two-turn-mobius-strip/m-p/10165846 

However, the development with Custom Features did not go well, so I switched to a regular add-in and published it.

 

 

My personal impression is that it takes about three times as much time to develop an add-in with Custom Features as with a regular add-in.
(I understand that there is a big return in return.)
This makes it difficult to try various things easily.

 

Also, this sentence from the documentation is not very motivating.

kandennti_0-1620366945622.png

 

It takes more time and effort to develop than usual, but not being able to publish it makes me lose motivation to try.

Message 15 of 82

nnikbin
Collaborator
Collaborator

Thank you @kandennti for sharing your valuable experience. I hope the great feedbacks like yours help this feature to come out of preview.

Message 16 of 82

debreuil
Participant
Participant

I'm not using it to it's full potential so it isn't that much more work for me (I'm mostly combining existing things vs creating brand new functionality), but I still find it totally great to work with. I love how it makes a complex add-in pretty much indistinguishable from a regular fusion feature.

 

I've been doing a lot of experiments with laser cut joints on multilayered objects, which can be tedious and confusing to do by hand. The custom feature I made initially creates/joins/intersects multiple layers in a single command, and it's made experimenting really fast and easy.

 

I would have shared code earlier, but it's still in progress -- and it's the first time I've used the Fusion API, so it is probably awkward as a code example. The goal is to have it automatically detect edges, corners, shelves etc and join them with a chosen joint strategy. So far I have copy and paste of sketches (including dimensions, parameters and constraints), and then multi-layer functionality. I have inactive test code for auto-creating shelving in there, that shouldn't be much more to integrate -- mostly it's been a hard UI problem (not a Fusion API issue, but hard for me to understand how I want the UI to work). 

 

Anyway, the code so far is here if anyone wants a look, fwiw. The custom feature in the Extrude Layers command (select a sketch, and it works much like extrude, but you can specify layers). I'm currently in a different part of the project, but hope to finish the auto-joint UI soon.

Message 17 of 82

nnikbin
Collaborator
Collaborator

Thank you @debreuil  for sharing your valuable experience and for sharing your nice add-in. I hope you can take full advantage of Custom Feature API in your add-ins, especially when this API reaches to a state that we can publish our add-ins using it with no worries of breaking the existing programs.

Message 18 of 82

florian.pommereningDGUYA
Enthusiast
Enthusiast

I tried adding support for this to my add-in. I managed to get it working in some cases but am still debugging some errors. While working on this, I collected some feedback that you might be interested in and the problems I stumbled over.

 

  1. Some minor comments about the documentation
    1. "The createInput method used to create a CustomFeatureInput object has three arguments. The first ..."
      --> The other two parameters are not discussed, which makes it a difficult to figure out how to set them.
    2. Duplicated "the" in "Define a transaction marker so the the rollback".
  2. Some comments about the design of the API
    1. "Fusion will only execute the edit command when a custom feature of the type it is associated with is being edited. Still, you need to get the specific instance of that type the user has chosen to edit"
      --> Why isn't this passed to the handler in the arguments of the event? Asking the UI from inside the event handler for the selected item seems like a very complicated and error-prone way of passing this information to the event when the UI is the one triggering the event anyway.
    2. When editing a feature, we have to roll the timeline back to the state just before the edited feature was created. I understand why this is necessary but I don't understand why we have to do it manually inside the event. Isn't this something that should happen at the start of every activate event of an edit command? If so, couldn't you just do this step before calling the event? That would reduce the amount of boiler-plate-code in the add-ins. It would also make the move back to the previous position of the timeline unnecessary inside the add-in.
    3. How are options that do not have a uni supposed to be stored? In addition to unit-less numbers as @kandennti mentioned, I'd like to store the selected option of a button group (an enum or string) or a checkbox (boolean). I managed to get this part to work by converting the values to ints, and storing them as floating point numbers with the unit 'pcs' but that isn't ideal because the user can then enter invalid values for them.
    4. Is it possible to specify the "comment" of a parameter in addition to the name? I am referring to the column "Comment" in the dialog where the user can edit the parameters.
  3. Question and problems I ran into
    1. How should editing a feature do its preview? During feature creation, I used isValidResult in the preview to avoid recomputing the result when the user clicks OK. Is there a way to do this in the edit dialog as well? If so, how should this interact with rolling the timeline back? Should I roll the timeline back to the original position at the end of the preview handler, or should I roll it just past the feature, so the modified parameters are visible? If I leave the timeline rolled back, the preview is not visible to the user because in the edit command, no new features are added, only parameters are changed.
    2. It seems that creating a custom feature also triggers the compute command. This is a bit strange, as the code in the compute command relies on the feature being there already, and only updates it, so it only makes sense to call this when some parameters or dependencies change. The preview also triggers this which means a lot of duplicated computation is done when some values in the feature creation dialog are modified. In some cases this really slowed down my GUI. Is there a way to avoid this?
    3. I got some errors when adding an edge as a dependency. The error is not reproducible every time and I'm not sure what exactly caused it but it happened in the context of a preview execute of the feature (when changing options in the feature creation dialog). The call stack to the error ended in

          _fusion.CustomFeatureInput_addDependency(self, id, entity)
          RuntimeError 2: InternalValidationError: edge

      My guess is that depending on the options, the edge that is an input parameter to the custom feature is destroyed by the feature (breaking up the edge into several new ones). This is already happening in the preview of the model and somehow it happens before the dependency is set. Then, when the depency should be set, the edge is no longer there. I don't know if it is intentional that the compute handler is already called while the command is still in preview mode. It seems like an odd choice that would lead to unnecessary recomputation of the feature.

    4. I created a combine feature in a parent component like this:

 

cutInput = parentComponent.features.combineFeatures.createInput(target, toolBodies)
cutInput.operation = adsk.fusion.FeatureOperations.CutFeatureOperation
cutInput.isNewComponent = False
cutFeature = parentComponent.features.combineFeatures.add(cutInput)

 

When target is a body, this works as expected but if target is a component, the feature belongs to the target (not parentComponent) afterwards. That is, after the last line parentComponent.features.combineFeatures is still empty. This makes it then impossible to combine this feature with other features into a custom feature. The operation that crashes is parentComponent.features.customFeatures.createInput(). I didn't find a solution for this yet.

Message 19 of 82

ginavenolia
Contributor
Contributor

I'm loving the new Custom Feature capability. One quick question - I want my custom feature to have a Boolean custom parameter.

  • Plan A was to use ValueInput.createByBoolean(booleanValue) in CustomFeatureInput.addCustomParameter, but it raised an exception.
  • Plan B was to use ValueInput.createByString(str(booleanValue)), but likewise it raised an exception.
  • Finally I resorted to converting the value to 0 or 1 and then using .createByReal(realValue) with units specified as the empty string. This works but when I look at the parameter in the Modify Parameters dialog as millimeter units. It'll work, but it's not exactly what I wanted.

What's the best way of doing a Boolean custom parameter? If it's necessary to keep it Real, is there a way of doing it unitless?

0 Likes
Message 20 of 82

ginavenolia
Contributor
Contributor

I'm writing an add-in using the new Custom Feature functionality. It's different from the Custom Pocket example code in that it is dependent on multiple selected entities and creates multiple bodies. This is creating three problems that I can't work out on my own.

 

First, one task for the Edit Execute handler is update the dependencies on any newly selected entities. Because Custom Pocket example uses a single dependency it can get it (by ID) and then modify its .entity property. Because my add-in can have any number of entities selected, I need to be able to add and remove dependencies to reflect the changes in the number of entities selected. Adding is no problem, but there's no way I can see to remove a dependency if my selection gets smaller. Alternately, I'd be happy to clear the dependencies and add them all back, but alas there's not CustomFeatureDependencies.clear method. So the API only allows you to modify or add dependencies, so what do I do if I need to remove dependencies?

 

Second, the Edit Execute handler also needs to replace the base feature's bodies with the bodies based on the new selection. Again Custom Pocket can get away with replacing the one and only body. In my add-in, the user can change the selection arbitrarily, which can result in a different number of bodies. The API provides BaseFeature.updateBody() to replace one body with another, and no means of increasing or decreasing the number of bodies.

 

Third, I can't think of a way of using updateBody to replace the CORRESPONDING bodies. Say the user invokes my add-in, selects entities A and then B, and then clicks OK. Then they edit my feature, clear the selection, and then select entities C and then A. Sure, I could replace A->C and B->A but I'd prefer replacing A->A and B->C. But how can I know which is which? How could I, say, associate an identifier with each body in the base feature, which I could use to find the correspondence with the new bodies?