I have borrowed a few lines of iLogic code to change all parts to the same colour from here:
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
Solved! Go to Solution.
Solved by xiaodong_liang. Go to Solution.
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
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
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
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
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.