Change properties of appearance by code

Change properties of appearance by code

b.graaf
Advocate Advocate
1,762 Views
5 Replies
Message 1 of 6

Change properties of appearance by code

b.graaf
Advocate
Advocate

I have searched but not found an answer.

 

Is it possible to change the properties of a document appearance by code (iLogic, VB or perhaps C#)?

 

So I do not mean to change the color of the part itself, but color, bump, textures and so on of an existing appearance in the appearance library (document appearances)

 

I have found a small peace of code, to get an appearance, which can be found within my Inventor document:

Dim doc As Document
doc = ThisApplication.ActiveDocument

Dim appearance As Asset
appearance = doc.Assets.Item("RAL 5015 Sky blue")

But how can I change the properties of this appearance, like color, reflectivity, transparancy, etc.....

Accepted solutions (1)
1,763 Views
5 Replies
Replies (5)
Message 2 of 6

HermJan.Otterman
Advisor
Advisor

Hello B.

 

do you mean this:

 

https://forums.autodesk.com/t5/inventor-forum/access-material-property-fields-via-iproperty-expressi...

 

If this answers your question then please select "Accept as Solution"
Kudo's are also appreciated Smiley Wink

Succes on your project, and have a nice day

Herm Jan


0 Likes
Message 3 of 6

b.graaf
Advocate
Advocate

Hello Hermjan,

 

Tnx for your reply.

 

What I like to achieve, is to change some vaules of document appearances. These appearances do not need to have been used in the part, I just want to itterate through the appearances and change some values like color and I would like to clear the image and to uncheck for example the bump and tint options.

See also attachment.

 

 

0 Likes
Message 4 of 6

HermJan.Otterman
Advisor
Advisor
Accepted solution

Hello B.

 

With this iLogic rule you will go through the properties

 

        Dim oPartDoc As Inventor.PartDocument = ThisApplication.ActiveDocument

        Dim oAppearanceAssets As AssetsEnumerator = oPartDoc.AppearanceAssets
        Dim oAsset As Asset

        'loop trough the part appearences
        For Each oAsset In oAppearanceAssets

            'Loop through the assetsvalues, that you see in the appearance dialogbox
            Dim oAssetValue As AssetValue
            For Each oAssetValue In oAsset

                MsgBox(oAssetValue.DisplayName,,"Asset Value")
                'here you can do something with the values
                'On Error Resume Next
                'MsgBox(oAssetValue.value)
            Next
        Next

 

If this answers your question then please select "Accept as Solution"
Kudo's are also appreciated Smiley Wink

Succes on your project, and have a nice day

Herm Jan


Message 5 of 6

b.graaf
Advocate
Advocate

Hello HermJan,

 

Tnx, with this I managed what I tried to do.

I have used it not in iLogic, but in a simple VB addin.

 

I managed to accomplish my goal, to change some values of several appearances within all the parts in an assembly!

 

This is part of the code I have used:

 

'loop trough the part appearences
        For Each oAsset In oAppearanceAssets

            'Loop through the assetsvalues, that you see in the appearance dialogbox
            Dim oAssetValue As AssetValue
            For Each oAssetValue In oAsset

                'Uncheck bump
                Try
                    If oAssetValue.DisplayName = "Tint" Then
                        Dim booleanValue As BooleanAssetValue
                        booleanValue = oAssetValue
                        booleanValue.Value = False
                    End If
                Catch
                    'Some error handling
                End Try

                'Uncheck Tint
                Try
                    If oAssetValue.DisplayName = "Bump" Then
                        Dim colorAssetValue As ColorAssetValue
                        colorAssetValue = oAssetValue
                        colorAssetValue.HasConnectedTexture = False
                    End If
                Catch
                    'Some error handling
                End Try

        Next
Next

 

0 Likes
Message 6 of 6

RoyWickrama_RWEI
Advisor
Advisor

Hi HermJan.Otterman

 

Thanks a lot. Your code was useful to fix one of my rules.

https://forums.autodesk.com/t5/inventor-customization/to-retrieve-appearances-from-the-current-appea...

 

Roy Wickrama

0 Likes