We are having a problem with color overrides whereby the color of subassemblies are being changed at the master model level. We are not sure how it is happening as nobody admits to doing so. When we manually click on the subassembly and change the drop-down to “As Material”, the subassembly returns to the correct colors which are set via iLogic rules.
Could it be that somehow our code is causing the change in the first place? Whatever the case may be, is there a snippet of iLogic code that we can place at the top level of a model –or at the top level of the subassemblies, that will strip out these overrides?
In all cases, we want assemblies to show the colors that are set at the part level. What code would reset assemblies to their “As Material” state?
Any help would be greatly appreciated.
Here's a rule that will do it. It won't affect sub-subassemblies, but it could be extended to do that if required.
Dim assemDoc as AssemblyDocument = TryCast(ThisDoc.Document, AssemblyDocument) For Each compOcc as ComponentOccurrence In assemDoc.ComponentDefinition.Occurrences If (compOcc.Suppressed) Then Continue For If (compOcc.ReferencedDocumentDescriptor Is Nothing OrElse compOcc.ReferencedDocumentDescriptor.ReferenceMiss
ing) Then Continue For compOcc.SetRenderStyle(StyleSourceTypeEnum.kPartRe nderStyle) Next
Hi Mike, thanks for the quick response. I set up a test, and am getting an error running the rule:
Rule Compile Errors in Rule1, in Assembly2.iam
Error on Line 5 : ')' expected.
Error on Line 6 : 'kPartRe' is not a member of 'Inventor.StyleSourceTypeEnum'.
Error on Line 6 : Comma, ')', or a valid expression continuation expected.
It dosent appear as though the code needs a part name inserted or anything, but then again I dont know jack.
Did I do something wrong? The rule was added to a sub assembly where I overrode the color of the part within, then tried the code and got the error.
I've attached the test files. What we do is control the color of parts within subassembles from the top level by passing the color via iProperties. To change the part color, change the Custom iproperty COLOR to a valid color, then run the Rule0 rule. Our problem dosent happen exactly like this --it is usually within sub-sub assemblies where if if a color is changed it changes the sub assembly's color as well, hiding future changes.
Thanks again Mike.
It looks like there's a problem with pasting text from this forum into the iLogic rule editor. I saw the same errors when I tried it.
Please try the new version of the rule in the attached file ResetAssemblyColors.txt. This new version will go into sub-subassemblies. So you should be able to run it from the top-level assembly.
Access a broad range of knowledge to help get the most out of your products and services.