Fusion API and Scripts
Got a new add-in to share? Need something specialized to be scripted? Ask questions or share what you’ve discovered with the community.
Showing results for 
Show  only  | Search instead for 
Did you mean: 

problem with activate() method of nested occurrences

Message 1 of 5
526 Views, 4 Replies

problem with activate() method of nested occurrences

Simple C++ script to demonstrate problem (-> attached file):

1) create new occurrence/component in active component

2) create sketch in new component

3) activate new component


Works as expected if root-component is active when user starts script:


-> component is activated, user can select sketch in timeline, right-click "edit sketch", create circle, stop sketch, create extrusion.


-> component activated

new component in root.PNG

circle clearly visible after "stop sketch"

new component in root sketch geometry.PNG


Works not as expected if "subassy" is active when user starts script:

-> new component is added, but in an "half-active" state. Timeline looks as if the component is activated, but no active-component radio button in the browser is visible. No component item in the browser is activated at all.


Question: known limitation?


If the user ignores this weird state, it can cause problems:


- user selects sketch in timeline, right-click "edit sketch", creates geometry, then "stop sketch" -> see image, faint display of circle, no component selected in browser

display after stop sketch in sketch palette.PNG


Then the user creates an extrusion with the circle.

-> see image

result of extrusion.PNG




Addendum: if the user leaves the sketch directly by entering "create extrusion" (instead of "stop sketch" and then "create extrusion") then the extrusion is created without any warnings (and the new component is selected in the browser).


=> ??


Message 2 of 5
in reply to: Anonymous

Hi Mr. Steinbach,


 ... it is difficult and time-consuming to give the definitive strict diagnosis but,

when creating extrusion make sure that the following are addressed:

# Get the value of the property.
propertyValue = extrudeFeatureInput_var.creationOccurrence

# Get the value of the property.
propertyValue = profile_var.assemblyContext







Message 3 of 5
in reply to: Anonymous

Just for clarification to avoid misunderstandings:


the example/demonstration C++ script just creates an occurrence in the active object, adds a sketch and activates the occurrence.


The rest of the operations (open/edit sketch, add circle, add extrusion) are done by the user interactively. Just to show what problems might arise when a user runs that script (which is actually only a part of a larger program).


My problem/question is: why does the API return a semi-activated occurrence, when the occurrence is created in a subassembly (in a non-root component/occurrence).

Message 4 of 5
in reply to: Anonymous

Hi Mr. Steinbach


There are many strange behaviors in F360 and depends upon a point of view (from below, from above, from ground level) they could be attributed to devilish work, miracle, someone's fatty fingers or ... misunderstandings of things by me, you and others.

Thank you for the clarification. Regardless of WHO created the strings of commands, they are at the end processed by the same(?) F360 core.

In your case, you are the co-author, sharing responsibility for the final outcome ( or failure).

I do not have time to C-compile and run your script but consider looking into the following:

- <<newOcc = activeComp->occurrences()->addNewComponent(matrix);>> does not create full contextual path to the occurence if it is not at root level
As a fact, if the active component has many occurrences representations, the command will 'create' respective number of occurences.
- <<Ptr<Sketch> sketch = newComp->sketches()->add(xy);>> Based on documentation when planarEntity is deep in the assembly, the different command's construct should be used.
<<returnValue = sketches_var->add(planarEntity, occurrenceForCreation);>>
- it seems that in your code, you did not cupture occurrenceForCreation and as such you can not build assembly context for entities you create.


Hopefully, this will help...





Message 5 of 5
in reply to: MichaelT_123

Hi Mr. Tomsia,

thank you very much for your time and your hints!

It helped me to find a way to achieve what I wanted - problem solved!


->createForAssemblyContext() did the job.

Ptr<Occurrence> newOcc = activeComp->occurrences()->addNewComponent(Matrix3D::create())->createForAssemblyContext(activeOccurrence);	// new occurrence

Kind regards,


Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th

Autodesk Design & Make Report