Get bodies in Inventor pattern

Get bodies in Inventor pattern

sandeep_vaal
Enthusiast Enthusiast
587 Views
4 Replies
Message 1 of 5

Get bodies in Inventor pattern

sandeep_vaal
Enthusiast
Enthusiast

Hello Autodesk,

We want to read bodies in inventor pattern feature (rectangular, Circular, etc)

We tried to read bodies in Pattern feature but it seems it whole pattern bodies as single body.

We tried following code

PartComponentDefinition partComponentDefinition = this.ivPartDocument.ComponentDefinition;

RectangularPatternFeatures rectPatternFeatures = partComponentDefinition.Features.RectangularPatternFeatures;
foreach (RectangularPatternFeature patternFeat in rectPatternFeatures)
{
int patternBodiesCount = patternFeat.SurfaceBodies.Count; // Getting 1 body always though pattern contains many instances of a body
RectangularPatternFeatureDefinition patterndefinition = patternFeat.Definition;

foreach (SurfaceBody surfaceBody in patternFeat.SurfaceBodies)
{
int patternBodyFacesCount = patternFeat.SurfaceBodies.Faces.Count; // Faces count is total of faces all pattern body instances
}
}


I have attached sample part

sandeep_vaal_0-1631863961343.png

 

We tried differrent API's from RectangularPatternFeature but couldn't get disting bodies from pattern features.

sandeep_vaal_1-1631864164171.png


We tried many things but couldn't get each body data seperately from PatternFeature

PartFeaturesEnumerator partFeatureEnum = surfaceBody.AffectedByFeatures;
foreach (PartFeature feature in surfaceBody.AffectedByFeatures) // surfaceBody.AffectedByFeatures.Count = 2 but still body is same for each AffectedFeature.
{
   SurfaceBody body = feature.SurfaceBody; // This body
}

Please suggest correct way if possible to achieve this. Looking for fastest resolution.

0 Likes
Accepted solutions (1)
588 Views
4 Replies
Replies (4)
Message 2 of 5

JelteDeJong
Mentor
Mentor
Accepted solution

im not exactly sure what you are trying to do but if you want to get multiple bodies from a pattern then you should make the pattern like this.

JelteDeJong_0-1631866652491.pngthen you will get multiple bodies.

JelteDeJong_1-1631866694624.png

 

 

Jelte de Jong
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature


Blog: hjalte.nl - github.com

0 Likes
Message 3 of 5

sandeep_vaal
Enthusiast
Enthusiast

Thanks @JelteDeJong 
But is it possible to get bodies separately without this change somehow through API's? Like for attached part without modifying pattern feature?

Thanks again!
  

0 Likes
Message 4 of 5

J-Camper
Advisor
Advisor

If you don't want to change the model to be actual separate bodies, then you have to look at the FaceShells of the solid body. 

 

simple sample:

 

Dim pDef As PartComponentDefinition = TryCast(ThisApplication.ActiveDocument.ComponentDefinition, PartComponentDefinition)
If IsNothing(pDef) Then Exit Sub
	
Dim oBody As SurfaceBody = pDef.SurfaceBodies.Item(1)

MessageBox.Show(oBody.FaceShells.Count)

 

If you have hollow parts then you will have loop through All FaceShells to look out for Void FaceShells [FaceShell Object], but if not then Count should be sufficient.

0 Likes
Message 5 of 5

sandeep_vaal
Enthusiast
Enthusiast

@J-Camper 
Actually we need proper separate bodies for further  computations. I needed just confirmation that if the pattern is not created without separate bodies we can not get separate bodies using some API's or relational data from Inventor .

 Thanks for your inputs.

0 Likes