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: 

Setting Colors to complex parts with iLogic

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
DPolsky-VAH
880 Views, 2 Replies

Setting Colors to complex parts with iLogic

I've tried everything I could find, hopefuly its something obvious I've missed..

 

I have an assembly made up of multiple assemblies. I have code that changes the color of the sub-assemblies to match to color of the main assembly. However there are a couple parts in those sub-assemblies that I don't want to change with the main assembly color, those need to be static. I tried changing the color of the part at the lowest level, but whenever I change the main assembly color it forces it to change.

 

I found if while looking at the top level assembly I can right click on the part and change the appearance under occurrence in the iProperties. However, everytime I change the paramater in the assembly to change the main color it changes that parts color back to "As Material". I was thinking I could be clever by writing a line of code that would change the color back to my desired color, but I can't get iLogic to do that for me.

 

Here is my structure:

 

-Top Assembly (Change color with parameter option)

       - Sub Assembly (Changes color with the Top Assembly to match)

                 -Part (ALWAYS WHITE)

 

I appreciate any help!

 

Thanks,

Daniel

2 REPLIES 2
Message 2 of 3
wayne.brill
in reply to: DPolsky-VAH

Hi Daniel,

 

In my simple tests I find that the API can change the material of a part in a sub assembly after the occurrence appearance is changed from the iProperties dialog.  I believe the problem is how to get this to happen automatically after this change.

 

iLogic has the iProperties Event Trigger but this does not fire for a sub assembly in my tests. (the iProperties need to be set for the Sub Assembly) One of the events in the Inventor API could be used to change the part. Your code would need to identify which part needs to have it's material changed. 

 

Thanks,

Wayne 



Wayne Brill
Developer Technical Services
Autodesk Developer Network

Message 3 of 3
MjDeck
in reply to: DPolsky-VAH

Hi Daniel,

I was surprised to find out that it’s not easy to do this in iLogic. You can’t set colors in sub-components and have the color show up at the top level.  You can set the color on a subassembly, but once that’s done you can’t reach below that level to sub-subassemblies or parts. This is a defect, and we should be able to fix it soon.

As a workaround, here's an external rule to replace the Component.Color function. It doesn’t do everything that the original function does. You can't specify a component by path, or reset the color to the default. I hope this limited implementation works for you.

-          Download the attached external rule file (ComponentForColor.txt) to the directory that contains your top-level assembly

-          Add these two lines to the top of any rule that sets the component color:

AddVbFile "ComponentForColor.iLogicVb"

Dim ComponentC As New ComponentForColor(ThisDoc.Document)

-          In the rule, replace all instances of Component.Color  with ComponentC.Color

 


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