problem with activate() method of nested occurrences

Anonymous

problem with activate() method of nested occurrences

Anonymous
Not applicable

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

 

oops!

 

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).

 

=> ??

 

0 Likes
Reply
Accepted solutions (1)
715 Views
4 Replies
Replies (4)

MichaelT_123
Advisor
Advisor

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

 

Regards

MichaelT

 

 

 

MichaelT
0 Likes

Anonymous
Not applicable

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).

0 Likes

MichaelT_123
Advisor
Advisor
Accepted solution

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...

 

Regards 

MichaelT

 

MichaelT
1 Like

Anonymous
Not applicable

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,

 

0 Likes