reading RenderStyle of Face objects

reading RenderStyle of Face objects

Anonymous
Not applicable
675 Views
1 Reply
Message 1 of 2

reading RenderStyle of Face objects

Anonymous
Not applicable

I want to read the Renderstyle used for a Face.

I have an Assembly file containing 3 copies of a cube part. While the original cube part file has no color information, but i have assigned a (different) color/RenderStyle to each of the 3 cube parts in the assembly.

 

Problem: i cannot get the correct renderstyle information for the faces. This is how i iterate over the document:

 

StyleSourceEnum source;

 

foreach (ComponentOccurence occ in AssemblyDocument doc) {

  if (occ.GetDefinitionDocumentType == kPartDocument) {

    PartDocument part = (PartDocument) occ.GetDefinition().GetDocument()

    RenderStyle partStyle = part.GetActiveRenderStyle(source)

    foreach (Feature feature in part.GetComponentDefinition().GetFeatures()) {

      RenderStyle featureStyle = feature.GetRenderStyle(source)

      RenderStyle bodyStyle = feature.GetSurfaceBody().GetRenderStyle(source)

       foreach (Face face in feature.GetSurfaceBody().GetFaces()) {

        RenderStyle faceStyle = face.GetRenderStyle(source)

      }

    }

  }

}

 

face.GetRenderStyle returns Null, source = kFeatureRenderStyle

feature.GetRenderStyle returns Null, source= kBodyRenderStyle

surfaceBody.GetRenderStyle returns Null, source= kPartRenderStyle

part.GetActiveRenderStyle returns Default material

 

where is the custom color i assigned to the cubes? The cubes are definitely colored in the 3D view of Inventor.

I coud provide the assembly and part files if needed.

 

Using Inventor 2011, 64 Bit, programming in C++

0 Likes
Accepted solutions (1)
676 Views
1 Reply
Reply (1)
Message 2 of 2

Anonymous
Not applicable
Accepted solution

Solved it myself. For Future reference:

 

1. In VC++, the correct method call is CComPtr<RenderStyle> style = something.MethodGetRenderStyle(source). something.GetRenderStyle is the raw method which returns HRESULT and needs a second parameter (Pointer to RenderStyle) which is used as output. The Compiler does not detect this (HResult to CComPtr is ok, the second parameter seems to have a default value)

2. In Assembly documents, each ComponentOccurence can override the Renderstyle of the part. Calling MethodGetRenderStyle for these Occurences is missing in the code.

0 Likes