Problem with createForAssemblyContext

Problem with createForAssemblyContext

grakoczy
Contributor Contributor
656 Views
5 Replies
Message 1 of 6

Problem with createForAssemblyContext

grakoczy
Contributor
Contributor

Hi,

 

With some scenes I have error when calling createForAssemblyContext function.

I got error: "The object has been in root component."

This is how my code looks like:

 

for occ in rootComp.allOccurrences:
    if occ.isVisible:
         comp = occ.component
         for body in comp.bRepBodies:
                b = body.createForAssemblyContext(occ)

assemblyContext for such bodies returns None.

Is there any way to fix this issue? Maybe different way of getting bRepBodies?

 

--

Grzegorz

 

0 Likes
657 Views
5 Replies
Replies (5)
Message 2 of 6

KrisKaplan
Autodesk
Autodesk

That code should not ever fail with that (admittedly bad syntax) error.  Normally, you should only see that error if you are attempting to createForAssemblyContext on a body that is in the root component's bodies collection (not in an occurrence).  So it should be a bug in the API.

 

I can run that code in various assemblies that I have without seeing that error.  Can you post a document that demonstrates this, or detail exactly how to build an assembly that deomonstrates this?

 

Kris



Kris Kaplan
0 Likes
Message 3 of 6

cekuhnen
Mentor
Mentor

@KrisKaplan Please send me an email at: info@ckbrd.de  I made that file for the plug-in developer.

 

I will send you my Fusion 360 log-in data so you can take a look at it directly inside my account.

 

I made two furniture models as separate files

then I made a new file for the space and linked in the other two models.

 

With linked in models often parts are missplaced for the chairs when I made copies of the linked in model in the studio file.

 

When I broke the link oddly also the table had multiple copies - this time the chairs remained at their original position.

 

 

Claas

Claas Kuhnen

Faculty Industrial Design – Wayne State Universit

Chair Interior Design – Wayne State University

Owner studioKuhnen – product : interface : design

0 Likes
Message 4 of 6

grakoczy
Contributor
Contributor

Is there any way to handle linked models with the API?

0 Likes
Message 5 of 6

KrisKaplan
Autodesk
Autodesk

Ah.  There is the problem.  There is an error check intended to prevent objects in the root component from being used as an object for createForAssemblyContext.  And this check is incorrectly not allowing objects directly owned by the root component of a linked design to be used with createForAssemblyContext.  So in your example, this will fail if there are root level bodies in a linked design component.  I will file a bug on this and it should be fixed in the next major update (likely the latter half of January).

 

There is no way to force the assembly context Body to be created for bodies in the root of linked component designs.  If you only need the assembly context body to get transformed results (e.g. from meshes obtained from the body), then the workaround would be to use the transform from the occurrence with the geometry obtained from the native body and manually transform all results.  I understand this would be very inconvenient if your code is only expecting assembly context objects.

 

Kris



Kris Kaplan
0 Likes
Message 6 of 6

grakoczy
Contributor
Contributor

Thanks, getting transform from occurence seems to work. 

0 Likes