Change Faces color permenently in assmbly .iam file

Change Faces color permenently in assmbly .iam file

sagar_ladawaUZSPM
Autodesk Autodesk
263 Views
2 Replies
Message 1 of 3

Change Faces color permenently in assmbly .iam file

sagar_ladawaUZSPM
Autodesk
Autodesk

Hello everyone,

I am trying to assign a permanent color to selected faces (not the entire body) in an Assembly file using the FinishFeature API.

So far, I tried SetRenderStyle, but it either applied to the entire part or threw an error (E_NOTIMPL). However, I found that FinishFeature can help apply color only to selected faces.

There is already a tool under Inventor UI :
📌 Assemble Tab → Appearance Panel → "Finish" Tool
When clicked, it applies a color/material kind of thing to the selected faces in the assembly.

🔹 How can I correctly implement this in C# using FinishFeature API?
🔹 Is there a better way to handle face-level appearance inside an Assembly document?

Below is my working code for this:

 

 

0 Likes
264 Views
2 Replies
Replies (2)
Message 2 of 3

james.collinsPWQR2
Advocate
Advocate

Hi @sagar_ladawaUZSPM,

I haven't played with FinishFeature yet, but if you want to do it the old school way take a look at this old post for some ideas: Re: Coating drawing flag automation - Autodesk Community

 

Hope it helps,

 

James

0 Likes
Message 3 of 3

JelteDeJong
Mentor
Mentor

If you are trying to add an "AppearanceFinish" to an occurrence (Proxy)Face then I guess this is what you need.

FaceProxy faceProxy = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kPartFaceFilter, "");

var doc = ThisDoc.Document as AssemblyDocument;

var finishFeatures = doc.ComponentDefinition.Features.FinishFeatures;

var faceCollection = ThisApplication.TransientObjects.CreateFaceCollection();
faceCollection.Add(faceProxy);


var assetLib = ThisApplication.AssetLibraries["Inventor Material Library"];
var asset = assetLib.AppearanceAssets["Red"];

try
{
    asset.CopyTo(doc);
}
catch (Exception)
{
    // if the asset is already copied then a exception is thrown. 
    // It can be ignored.
}
            
var finishDefinition = finishFeatures.CreateFinishDefinition(faceCollection, FinishTypeEnum.kAppearanceFinishType, null , asset);
finishFeatures.Add(finishDefinition);

 

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