Sub-subassembly apperance color

Sub-subassembly apperance color

m_baczewski
Advocate Advocate
600 Views
8 Replies
Message 1 of 9

Sub-subassembly apperance color

m_baczewski
Advocate
Advocate

Hello,

 

Is it possible to change the appearance of color in a sub-subassembly or part in a subassembly from the main assembly?

Everything is in the attached image, and I'm also including the code that I thought would handle it. I tried updating the document, but unfortunately, it didn't work.

m_baczewski_0-1696232620998.png


czarny = "Czarny"
szary = "Ciemnoszara"
niebieski = "Niebieska — farba ścienna — lśniąca"
ocynkowana = "Jasnoszara"

Select Case KOLOR_BLACHY_BOCZNEJ
	Case = "Czarny (RAL 9005)"
		kolor = czarny
	Case = "Szary (RAL 7001)"
		kolor = szary
	Case = "Ocynkowana"
		kolor = ocynkowana
	Case = "Niebieski (RAL 5010)"
		kolor = niebieski
End Select

Logger.Info(kolor)

Component.Color("Obrzeże Środek:1") = kolor 'part in sub subassembly
Component.Color("RAMA1") = kolor 'sub subassembly

InventorVb.DocumentUpdate()

iLogicVb.UpdateWhenDone = True

 

Has anyone ever had this problem and solved it?

Additionally, I created a separate assembly with 2 subassemblies, and there is the possibility to change the color there. However, when I change the color, turn off the assembly, and turn it on again, I lose the ability to change the color. The color names are definitely available in the library because if I enter an incorrect name, I get an error.

 

@ EDIT

Additionally, when I change the color in the following way:

Component.Color("RAMA1") = "Czarny"

The color does not change in the main assembly view. However, if I open the RAMA1 assembly, the color is as I expected.

0 Likes
601 Views
8 Replies
Replies (8)
Message 2 of 9

A.Acheson
Mentor
Mentor

Hi @m_baczewski 

 

Try the makepath function to define the path to the component within the sub assembly. See iLogic Help page here at the bottom

From help page

"MakePath

Defines the path to a component name in a subassembly. To specify the path, list all subassembly levels in the order they appear in the tree. This function is required if you want to specify a component name when the same name also exists elsewhere in the assembly. "

Syntax

MakePath(“SubassemblyComponentName”,“PartComponentName”)

Examples

Component.Color(MakePath("SubAssem1:1", "Part2:1")) = “Green”
Component.IsActive(MakePath("SubAssem1:1", "SubSubAssem2:1", "Part2:1")) = “Yellow”

 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
0 Likes
Message 3 of 9

m_baczewski
Advocate
Advocate

Hi @A.Acheson

Thank you for your response; I'm including the code below in which I've described what works and what doesn't.

 

Component.Color(MakePath("RDZEN", "Platforma uchylna", "Obrzeże LT PP:1")) = “Anodowana — czarna” 'It works, there are no errors, but it doesn't change the color.

Component.Visible(MakePath("RDZEN", "Platforma uchylna", "Obrzeże LT PP:1")) = False 'It works correctly, the visibility changes.

Component.IsActive(MakePath("RDZEN", "Platforma uchylna", "Obrzeże LT PP:1")) = “Anodowana — czarna” 'The conversion from the string "Anodized - black" to the 'Boolean' type is not valid.

 

@EDIT

I don't know why it's happening, but it changes the color of the specific part. However, this change is not visible from the main assembly. If I enter the sub-assembly that contains this part, I can see the color has been changed

0 Likes
Message 4 of 9

A.Acheson
Mentor
Mentor

Hi @m_baczewski 

What is your end goal with the rule? Change the part document, change the occurrence color within the sub assembly without changing the document? Can you confirm the document color only has been changing and you want the occurrence color to change? Can you confirm your able to do what you want in a manual method using the UI? 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
0 Likes
Message 5 of 9

m_baczewski
Advocate
Advocate
Hi @A.Acheson

I would like the color to change as seen by the user, and it doesn't necessarily have to be a change in the color of a specific part; it could be, for example, the overridden color of the entire welded assembly.
0 Likes
Message 6 of 9

A.Acheson
Mentor
Mentor

I would suggest ditch the ilogic API route snd use the inventor API methods. See help page here written in VBA

 

And here is how to implement in ilogic. That sample is filtering for bom structure but just delete those lines. 

 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
0 Likes
Message 7 of 9

m_baczewski
Advocate
Advocate

Yesterday, I arrived at this solution:

1) I define individual colors as Asset:

Dim oDoc As AssemblyDocument
oDoc = ThisDoc.Document

Dim kolor As Asset
Dim kolor1 As Asset
Dim czarny As Asset
czarny = oDoc.AppearanceAssets.Item(1)
Dim niebieski As Asset
niebieski = oDoc.AppearanceAssets.Item(5)
Dim szary As Asset
szary = oDoc.AppearanceAssets.Item(2)
Dim ocynk As Asset
ocynk = oDoc.AppearanceAssets.Item(4)

kolor = czarny

2) go through all the elements that make up the assembly, assign them to variables:

For Each item In oDoc.AllReferencedDocuments 
 	If item.DisplayName = "Obrzeże LP PT.ipt"
		obrzezeLP = item
....
Next

 

3) change them to the color I'm interested in.:

obrzezeLP.ActiveAppearance = kolor

 

I thought there might be a faster and easier way.

0 Likes
Message 8 of 9

A.Acheson
Mentor
Mentor

Hi @m_baczewski 

 

This works for me, this will assign the colour asset to the main assembly and then override the documents "Base Plate" colour to Blue through the sub assembly "Base". Top level view rep "default" shows the override and the  "Master View rep shows the document colour. 

Component.Color({"Base:1", "Base Plate:1"}) = “Blue”

 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
0 Likes
Message 9 of 9

m_baczewski
Advocate
Advocate

@A.Acheson 

I've created a video demonstrating how what you described works in my case. The color changes within the subassembly, but the view doesn't change in the main assembly. I must be doing something wrong.

 

0 Likes