Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Strip Assembly Level Color Overrides with iLogic

3 REPLIES 3
Reply
Message 1 of 4
MRanda
1164 Views, 3 Replies

Strip Assembly Level Color Overrides with iLogic

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.

Intel i7-6700K Liquid Cooled CPU
MSI GTX GeForce 1080 AERO 8GB OC Graphics
32 Gigs DDR 4 Ram
500 GB SSD OS Drive
4TB SSHD File Server Drive
Windows 10 Pro
Applied Design Intelligence
http://applieddesignintelligence.com/
3 REPLIES 3
Message 2 of 4
MjDeck
in reply to: MRanda

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.ReferenceMissing) Then Continue For
  compOcc.SetRenderStyle(StyleSourceTypeEnum.kPartRenderStyle)
Next

 


Mike Deck
Software Developer
Autodesk, Inc.

Message 3 of 4
MRanda
in reply to: MjDeck

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.

 

Error.JPG

 

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.

 

Mark Randa

 

Intel i7-6700K Liquid Cooled CPU
MSI GTX GeForce 1080 AERO 8GB OC Graphics
32 Gigs DDR 4 Ram
500 GB SSD OS Drive
4TB SSHD File Server Drive
Windows 10 Pro
Applied Design Intelligence
http://applieddesignintelligence.com/
Message 4 of 4
MjDeck
in reply to: MRanda

Mark,

 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.


Mike Deck
Software Developer
Autodesk, Inc.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report