Announcements

Starting in December, we will archive content from the community that is 10 years and older. This FAQ provides more information.

Community
Inventor Forum
Welcome to Autodesk’s Inventor Forums. Share your knowledge, ask questions, and explore popular Inventor topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Make a lot of appearances at once (with excel, xml, ilogic or table in inventor)

3 REPLIES 3
SOLVED
Reply
Message 1 of 4
jaco011
324 Views, 3 Replies

Make a lot of appearances at once (with excel, xml, ilogic or table in inventor)

Hi all,

 

I have one appearance I am happy with, but now I want it in a lot of different colorshades (only RGB value should change). Is there a quick solution to create all these at once? I have an excel file with the new appearance names and their RGB values. I hope to find to way to prevent my to typing all these values manually to inventor.

 

It doesn't matter if its via excel, xml or a table in inventor. If someone has some code to duplicate an appearance or material in ilogic, I will be able to make to work.

 

Hope someone can help

Labels (9)
3 REPLIES 3
Message 2 of 4
Gabriel_Watson
in reply to: jaco011

Try this suggested solution from the Inventor VBA/iLogic/etc. forum:
https://forums.autodesk.com/t5/inventor-programming-ilogic/batch-create-appearences-maybe-with-macro...

Sub main()

    Dim name(200) As String
    Dim red(200) As Integer
    Dim green(200) As Integer
    Dim blue(200) As Integer
    
    Dim i As Integer

    For i = 1 To 200
                
        Call CreateAppearance(name(i), green(i), red(i), blue(i))
                
    Next i
    
End Sub


Sub CreateAppearance(ByVal name As String, ByVal red As Integer, ByVal green As Integer, ByVal blue As Integer)

    Dim oDoc As PartDocument
    Set oDoc = ThisApplication.ActiveDocument
    
    Dim oTG As TransientObjects
    Set oTG = ThisApplication.TransientObjects
    
    Dim docAsset As Assets
    Set docAsset = oDoc.Assets

    Dim appearance As Asset
    Set appearance = docAsset.Add(AssetTypeEnum.kAssetTypeAppearance, "Generic", name & "Appearances", name)

    Dim generic_color As ColorAssetValue
    Set generic_color = appearance.Item("generic_diffuse")
       
    generic_color.Value = oTG.CreateColor(red, green, blue)
    generic_color.HasConnectedTexture = True
    
    Dim generic_texture As AssetTexture
    Set generic_texture = generic_color.ConnectedTexture
        
    Dim generic_image_fade As FloatAssetValue
    Set generic_image_fade = appearance.Item("generic_diffuse_image_fade")
    generic_image_fade.Value = 0.75
    
    Dim generic_glossiness As FloatAssetValue
    Set generic_glossiness = appearance.Item("generic_glossiness")
    generic_glossiness.Value = 0.3
    
    Dim generic_highlights As BooleanAssetValue
    Set generic_highlights = appearance.Item("generic_is_metal")
    generic_highlights.Value = False

End Sub
Message 3 of 4
jaco011
in reply to: Gabriel_Watson

Thank you for that link, I tried to search but did not find this one myself.

 

It works, so I am very happy!

 

Do you also happen to know if there is a list how to address all the different aspects of an appearance? (for example reflectivity or description)

Message 4 of 4
Gabriel_Watson
in reply to: jaco011

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report