Problem with moveFeatures

Problem with moveFeatures

brad.bylls
Collaborator Collaborator
651 Views
4 Replies
Message 1 of 5

Problem with moveFeatures

brad.bylls
Collaborator
Collaborator

I am trying to move bodies in a script.

I copied the code from the online samples to this:

Screenshot (28).png

And got this error but what does it mean?

Screenshot (29).png

Brad Bylls
0 Likes
Accepted solutions (1)
652 Views
4 Replies
Replies (4)
Message 2 of 5

BrianEkins
Mentor
Mentor

My guess is that either the features collection or the bodies are not in the same context. I can't tell from your code because the code that shows where you got those are not displayed. I tried a simple case where I deliberately had bodies in two different components and provided both bodies in the context of the component that owned them. In that case, I got the clearer error shown below, so yours is something different. When I provide the correct context, the move was successful.

 

 Failed:
Traceback (most recent call last):
  File "C:/Users/t_ekinb/AppData/Roaming/Autodesk/Autodesk Fusion 360/API/Scripts/Samples/Samples.py", line 548, in createMove
    move = moves.add(input)
  File "C:\Users/t_ekinb/AppData/Local/Autodesk/webdeploy/develop/6154ed41f984a6d55387f8e7e8a12643fced376b/Api/Python/packages\adsk\fusion.py", line 27058, in add
    return _fusion.MoveFeatures_add(self, input)
RuntimeError: 3 : object is not in the assembly context of this component
---------------------------------------------------------------
Brian Ekins
Inventor and Fusion 360 API Expert
Website/Blog: https://EkinsSolutions.com
0 Likes
Message 3 of 5

MichaelT_123
Advisor
Advisor
Accepted solution

Hi Mr BradBylls,

 

Consider to add assembly contexts for your bodies ...

body_proxy = body.createForAssemblyContext( bodies_occ )
 
Regards
MichaelT
 
 
MichaelT
0 Likes
Message 4 of 5

brad.bylls
Collaborator
Collaborator

@BrianEkins they are both bRepBodies and are both in the same component.

I tried commenting out line 466 but still didn't work with just one body.

I also tried commenting out line 467 with no luck.

Full code attached.

I will try the assembly suggestion from @MichaelT_123 

Thank you

Brad Bylls
0 Likes
Message 5 of 5

brad.bylls
Collaborator
Collaborator

@MichaelT_123  thank you. That worked.

Brad Bylls