Message 1 of 4
Colour Face Of A-Side In Specific ViewRep C#
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi All,
I am looking to Set the color of the A-Side face to a specific color
but only do it in a specific view rep
my code is in C# but happy to translate from Vb
I am able to set the view rep no problem
public void PrtCreateVRep(string nViewRep)
{
Connect(out Inventor.Application m_InvApp, out bool InvActive);
TestPart(out bool oPartTest);
if (oPartTest == true)
{
//Active Part Document
PartDocument oPartDoc = (PartDocument)m_InvApp.ActiveDocument;
//Define Component definition
PartComponentDefinition oCompDef = oPartDoc.ComponentDefinition;
//get Manager of Representations
RepresentationsManager dViewRepMgr = oCompDef.RepresentationsManager;
//get active Representation view
DesignViewRepresentation dViewRep = dViewRepMgr.ActiveDesignViewRepresentation;
DesignViewRepresentations oDesignViewReps = oCompDef.RepresentationsManager.DesignViewRepresentations;
//DesignViewRepresentation oDesignViewRep = default(DesignViewRepresentation);
int dViewRepCounts = oDesignViewReps.Count;
if (nViewRep != "")
{
try
{
oDesignViewReps[nViewRep].Activate();
//Inventor Status Bar Feedback
m_InvApp.StatusBarText = "View Representation: " + "'" + nViewRep + "'" + " Exists. " + "'" + nViewRep + "'" + " View Representation Now Activaded.";
}
catch
{
DesignViewRepresentation oDesignViewRep = default(DesignViewRepresentation);
oDesignViewRep = oDesignViewReps.Add(nViewRep);
oDesignViewReps[nViewRep].Activate();
//Inventor Status Bar Feedback
m_InvApp.StatusBarText = "View Representation: " + "'" + nViewRep + "'" + " Created. " + "'" + nViewRep + "'" + " View Representation Now Activaded.";
}
}
else
{
MessageBox.Show("No View Rep Name Selected!", "UAPTools");
}
}
else
{
MessageBox.Show("Please Activate a Valid Part Document", "UAPTools");
}
}
Then set the face to the Color
public void SetA_SideColour(string oColour)
{
Connect(out Inventor.Application m_InvApp);
InvPart constrClass = new InvPart();
constrClass.TestPart(out bool oPartTest);
if (oPartTest == true)
{
//Active Part Document
PartDocument oPartDoc = (PartDocument)m_InvApp.ActiveDocument;
//Define Component definition
//PartComponentDefinition oCompDef = oPartDoc.ComponentDefinition;
SMCheck(out bool oSMTest);
if (oSMTest == true)
{
SheetMetalComponentDefinition oSMCompDef = (SheetMetalComponentDefinition)oPartDoc.ComponentDefinition;
if (oSMCompDef.ASideFaceStatus == ASideFaceStatusEnum.kASideUpToDate)
{
ASideDefinition oAsideDef = oSMCompDef.ASideDefinitions[1];
Face oFace = oAsideDef.Faces[1];
//Face oFace = oAside.Faces[1];
if (oColour != "")
{
if (oColour == "As Feature")
{
try
{
//Set Enum
StyleSourceTypeEnum oStyle = StyleSourceTypeEnum.kFeatureRenderStyle;
//Set Render Style of faces
oFace.SetRenderStyle(oStyle);
}
catch
{
//Inventor Status Bar Feedback
m_InvApp.StatusBarText = "RenderStyle/Appearance : " + "' " + oColour + " '" + " Could Not Be activated";
}
}
else
{
try
{
RenderStyle oRenderStyle = oPartDoc.RenderStyles[oColour];
//Set Enum
StyleSourceTypeEnum oStyle = StyleSourceTypeEnum.kOverrideRenderStyle;
//Set Render Style of faces
oFace.SetRenderStyle(oStyle, oRenderStyle);
}
catch
{
//Inventor Status Bar Feedback
m_InvApp.StatusBarText = "RenderStyle/Appearance : " + "' " + oColour + " '" + " Could Not Be activated";
}
}
}
}
else
{
}
m_InvApp.ActiveView.Update();
}
}
}
But This overrides the color in all view reps
Any thoughts?