Inventor Customization

Inventor Customization

Reply
Distinguished Contributor
MRanda
Posts: 123
Registered: ‎10-06-2006
Message 1 of 4 (649 Views)

Strip Assembly Level Color Overrides with iLogic

649 Views, 3 Replies
04-11-2011 10:13 AM

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.

Asus Tower
32 Gigs Ram
Solid State HD
Intel i7-4770 CPU
Windows 8.1 (Hate it with a passion)
Website;
Applied Design Intelligence
http://applieddesignintelligence.com/
Employee
MjDeck
Posts: 959
Registered: ‎02-24-2009
Message 2 of 4 (632 Views)

Re: Strip Assembly Level Color Overrides with iLogic

04-12-2011 03:28 PM 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
DLS - Mechanical Design
Autodesk, Inc.

Distinguished Contributor
MRanda
Posts: 123
Registered: ‎10-06-2006
Message 3 of 4 (629 Views)

Re: Strip Assembly Level Color Overrides with iLogic

04-12-2011 04:28 PM 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

 

Asus Tower
32 Gigs Ram
Solid State HD
Intel i7-4770 CPU
Windows 8.1 (Hate it with a passion)
Website;
Applied Design Intelligence
http://applieddesignintelligence.com/
Employee
MjDeck
Posts: 959
Registered: ‎02-24-2009
Message 4 of 4 (627 Views)

Re: Strip Assembly Level Color Overrides with iLogic

04-12-2011 06:33 PM 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
DLS - Mechanical Design
Autodesk, Inc.

Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Do you have 60 seconds to spare? The Autodesk Community Team is revamping our site ranking system and we want your feedback! Please click here to launch the 5 question survey. As always your input is greatly appreciated.