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: 

Assembly Colour Finish

5 REPLIES 5
SOLVED
Reply
Message 1 of 6
SeanFarr
599 Views, 5 Replies

Assembly Colour Finish

I have borrowed a few lines of iLogic code to change all parts to the same colour from here:

http://forums.autodesk.com/t5/Autodesk-Inventor/Color-multiple-parts-in-an-assembly/td-p/3191850#.UP...

Rule:

Dim num As Long
num = ThisApplication.ActiveDocument.ComponentDefinition.Occurrences.Count
jj=1
While jj<num+1
Component.Color(ThisApplication.ActiveDocument.ComponentDefinition.Occurrences.Item(jj).Name) = paint_colour
jj=jj+1
End While
iLogicVb.UpdateWhenDone = True

 

This rule user a multi value text user parameter where I have input a group of colours.

 

I then apply this rule to my form for control of the final assembly.

 

Is there a way to alter this rule or better yet add another rule to over ride so that 3 parts of my assembly can be changed to another colour?

 

I have an assembly with ~200 parts and all same colour except for 3 parts. These three parts are the same colour as well. I can use specific files names in the rule as these will never change.

 

I would like to have a rule for this so I can add it to my form that I use to control size parameters and colours.

 

Thanks

 

Sean

Sean Farr
Product Designer at TESInc.ca

Inventor Professional 2014-Update 2 - AutoCAD Electrical 2014
Win7-x64 | ASUS P8Z77-V | i7 3770 -3.4 GHz | 32GB RAM |
240GB SSD | nVidia GTX 670 4GB - 320.49
5 REPLIES 5
Message 2 of 6
SeanFarr
in reply to: SeanFarr

I meant to add some screenshots to help clarify. first image is what I currently have, Paint Finish changes all parts in the assembly to selected colour.

 

Second Image shows what I am trying to do, There are 3 parts called backplates that should be a different colour.

 

Any help would be awesome!!

 

Thanks

 

Sean

Sean Farr
Product Designer at TESInc.ca

Inventor Professional 2014-Update 2 - AutoCAD Electrical 2014
Win7-x64 | ASUS P8Z77-V | i7 3770 -3.4 GHz | 32GB RAM |
240GB SSD | nVidia GTX 670 4GB - 320.49
Message 3 of 6
xiaodong_liang
in reply to: SeanFarr

Hi,

 

Hope the code below helps:

 

'name list of specific parts
' Note: case sensitive!!
Dim listOfSpecificPart() As String = New String(){"Part1:1", "part2:1"}
 
	num = ThisApplication.ActiveDocument.ComponentDefinition.Occurrences.Count
	jj=1
	While jj<num+1
	Dim eachOccName
	eachOccName = ThisApplication.ActiveDocument.ComponentDefinition.Occurrences.Item(jj).Name
	' check if this is a specific part
	Dim oIndex As Integer = Array.IndexOf(listOfSpecificPart, eachOccName)
	 
	If  oIndex > 0 Then
		 Component.Color(eachOccName) = black_colour		 
	Else	
		 Component.Color(eachOccName) = paint_colour		 
	End If
	jj=jj+1
	End While
	iLogicVb.UpdateWhenDone = True
 

 

Message 4 of 6
SeanFarr
in reply to: xiaodong_liang

This rule is almost perfect,

I have created another multi-value user parameter called backplate_colour, edited the rule you provided, added in the 3 parts file names and it works except for the first part file in the list of 3 doesn't change. It is not a problem with the part file, because I re-arranged the file order and it still doesnt apply the colour change to the first file in the list. Not sure what this could be.

 

I have attached a few images t show what I mean.

 

Thanks


Sean Farr

Sean Farr
Product Designer at TESInc.ca

Inventor Professional 2014-Update 2 - AutoCAD Electrical 2014
Win7-x64 | ASUS P8Z77-V | i7 3770 -3.4 GHz | 32GB RAM |
240GB SSD | nVidia GTX 670 4GB - 320.49
Message 5 of 6
SeanFarr
in reply to: xiaodong_liang

I still do know why the first part in the list of parts doesnt change colour, but I have found a work around.

 

I added the bolts to the list of parts and made sure it was first in the list, as these are painted with the frame (blue in this case). Bolts are MPC-100010

 

Then I added my 3 backplates (white in this case), so since the bolts were first in the list, they didn't change to white, but my 3 backplates changed. Backplates are MPC-100011, MPC-100012, MPC-100013

 

So it works, see attached image.

 

Thanks for your help.

 

Sean Farr

Sean Farr
Product Designer at TESInc.ca

Inventor Professional 2014-Update 2 - AutoCAD Electrical 2014
Win7-x64 | ASUS P8Z77-V | i7 3770 -3.4 GHz | 32GB RAM |
240GB SSD | nVidia GTX 670 4GB - 320.49
Message 6 of 6
ChristinaForest
in reply to: SeanFarr

Hi 🙂

 

Do you think it's possible to create a same rule in drawing with a CommandeManager.Pick and select assembly view and send iproperties in all parts???

 

Thanks!

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

Post to forums  

Autodesk Design & Make Report