API: MultiBody parts.

API: MultiBody parts.

Anonymous
Not applicable
1,081 Views
3 Replies
Message 1 of 4

API: MultiBody parts.

Anonymous
Not applicable

Hi.

I am trying to access the material and/or renderstyle for each solid in a multibody part document, but it seems like this is not supported in the API.

Is this correct?

If this is correct, why the HasMultipleSolidBodies property? (Yes, I am probably missing something here, but... :-))

 

R

0 Likes
Accepted solutions (1)
1,082 Views
3 Replies
Replies (3)
Message 2 of 4

sanjay.ramaswamy
Alumni
Alumni
Accepted solution

The PartComponentDefinition.SurfaceBodies returns all the solid bodies within a part. You can then call the SurfaceBody.GetRenderStyle method on each returned body to query its render style. Note that Material can only be set per document (and not per body).

 

Does this help? If not, please provide the Inventor document and sample code to reproduce the problem.

 

 

0 Likes
Message 3 of 4

Anonymous
Not applicable

Yes, of course! Why didn't I think of this?

Thank you very much!

 

R

0 Likes
Message 4 of 4

Anonymous
Not applicable

Sorry for bringing up such an old post.  This is exactly what I'm trying to do, but it takes such a long time.  On some of our larger parts, iterating through and setting each face on a surface body to featureRenderStyle takes hours.  Is there a faster way?

 

 Here is my current code:

foreach (SurfaceBody oSurfaceBody in oPartDef.SurfaceBodies)
{
	oSurfaceBody.SetRenderStyle(StyleSourceTypeEnum.kFeatureRenderStyle, null, true);

	foreach (Face face in oSurfaceBody.Faces)
	{
		face.SetRenderStyle(StyleSourceTypeEnum.kFeatureRenderStyle);
	}
}

 

Is there a way to make it faster or more efficient?  If Inventor were thread-safe, I'd do it in parallel.  

 

Is there code similar to this that might work on a surfaceBody? ModTheMachine shows that it only selects faces that have an override.

oPartDocument.AttributeManager.FindObjects("com.autodesk.inventor.FaceAttributes", "FaceColor");

 

0 Likes