Inventor Customization

Reply
Valued Mentor
SeanFarr
Posts: 475
Registered: ‎07-25-2012
Message 1 of 6 (313 Views)
Accepted Solution

Assembly Colour Finish

313 Views, 5 Replies
01-15-2013 05:08 AM

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

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

 

Valued Mentor
SeanFarr
Posts: 475
Registered: ‎07-25-2012
Message 2 of 6 (311 Views)

Re: Assembly Colour Finish

01-15-2013 05:42 AM 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
ADN Support Specialist
xiaodong.liang
Posts: 1,303
Registered: ‎06-12-2011
Message 3 of 6 (278 Views)

Re: Assembly Colour Finish

01-22-2013 05:57 PM 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
 

 



Xiaodong Liang
Developer Technical Services
Autodesk Developer Network

Valued Mentor
SeanFarr
Posts: 475
Registered: ‎07-25-2012
Message 4 of 6 (268 Views)

Re: Assembly Colour Finish

01-23-2013 08:14 AM 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
Valued Mentor
SeanFarr
Posts: 475
Registered: ‎07-25-2012
Message 5 of 6 (263 Views)

Re: Assembly Colour Finish

01-24-2013 06:36 AM 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
Distinguished Contributor
sergelachance
Posts: 181
Registered: ‎04-30-2012
Message 6 of 6 (117 Views)

Re: Assembly Colour Finish

10-25-2013 02:40 AM in reply to: SeanFarr

Hi :smileyhappy:

 

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!

Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.