Change Appearance of solid with ilogic

Change Appearance of solid with ilogic

Quoc_Kiet
Explorer Explorer
402 Views
3 Replies
Message 1 of 4

Change Appearance of solid with ilogic

Quoc_Kiet
Explorer
Explorer

Dear all,

In Part environments, I have a file mutiple solid, and using color ID: RGB 10 66 120, I want to go to Appearance edittor and uncheck Self illumination and change color ID to RGB 15 93 132 and applies to all solid with similar color codes.

Is there any ilogic expert here who can help me solve the above problem with ilogic

z5560303498613_75c6763c2dfbef502834dbfcaa5f928a.jpg

Thank you for reading my post.

 

 
 
0 Likes
Accepted solutions (1)
403 Views
3 Replies
Replies (3)
Message 2 of 4

Michael.Navara
Advisor
Advisor

You can use this code snippet. But I strongly recommend you to use tool like this VBA Object Browser for Inventor and look what the code means and how it works.

 

 

Dim part As PartDocument = ThisDoc.Document

'Set custom color
Dim generic_diffuse As ColorAssetValue = part.ActiveAppearance("generic_diffuse")
generic_diffuse.Value = ThisApplication.TransientObjects.CreateColor(10, 66, 120)

' Turn off the check box
Dim generic_self_illum_luminance As FloatAssetValue = part.ActiveAppearance("generic_self_illum_luminance")
generic_self_illum_luminance.Value = 0

 

 

 

Message 3 of 4

nstevelmans
Advocate
Advocate

Hi, can you try this?

 

  Dim doc As PartDocument = ThisApplication.ActiveDocument
   
       
        Dim oColor As ColorAssetValue
        Dim generic_self_illum_luminance As FloatAssetValue
        Dim a As Asset = Nothing
        Dim oTG As TransientObjects = ThisApplication.TransientObjects
		 ' loop all appearances
        For Each a In doc.Assets
            If a.AssetType = AssetTypeEnum.kAssetTypeAppearance Then
                oColor = a.Item("generic_diffuse")
                generic_self_illum_luminance = a.Item("generic_self_illum_luminance")
                If oColor.Value.Red = 10 Then
                    If oColor.Value.Green = 66 Then
                        If oColor.Value.Blue = 120 Then
                            oColor.Value = oTG.CreateColor(15, 93, 132)
                            generic_self_illum_luminance.Value = 0
                        End If
                    End If
                End If
                 End If
            Next

 

Message 4 of 4

Quoc_Kiet
Explorer
Explorer
Accepted solution

Hello @nstevelmans 

Thank you for helping, but i find a orther solution from: VBA Macro - Change Part Colour Using RGB Values and resolved my issue, you can try it.

Have a great day.

 

 
0 Likes