iLogic - Change appearance (get it from a Material Library)

iLogic - Change appearance (get it from a Material Library)

mgFNR8M
Contributor Contributor
689 Views
3 Replies
Message 1 of 4

iLogic - Change appearance (get it from a Material Library)

mgFNR8M
Contributor
Contributor

Hi.

 

How can I change the current part appearance to an appearance saved on a library?

 

I tested this, but it only changes the appearance to the default one (grey).

 

ThisApplication.ActiveDocument.ActiveRenderStyle = ThisApplication.ActiveDocument.RenderStyles.Item("Appearance Name")

 

I don't know hot to get it from a library (not the current file).

 

Any help?

 

Thanks!

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

mgFNR8M
Contributor
Contributor
Accepted solution

Done.

 

 

Dim oDoc As PartDocument = ThisApplication.ActiveDocument
Dim Name As String = "Appearance Name"
Dim localAsset As Asset = Nothing

Try
	localAsset = oDoc.Assets.Item(Name)
Catch
	Dim assetLib As AssetLibrary = ThisApplication.AssetLibraries.Item("Library Name")
	Dim libAsset As Asset = assetLib.AppearanceAssets.Item(Name)
	localAsset = libAsset.CopyTo(oDoc)
End Try

oDoc.ActiveAppearance = localAsset
Call oDoc.BrowserPanes.ActivePane.TopNode.DoSelect
Message 3 of 4

WCrihfield
Mentor
Mentor
Accepted solution

Hi @mgFNR8M.  Besides the Inventor API way, like shown above, there is also this iLogic shortcut snippet you could try.  I just can not remember if it will copy in the appearance from the active library for you, if it is not found locally, or not.

 

iProperties.PartColor = "AppearanceName"

 

Here is the online documentation about it:

https://help.autodesk.com/view/INVNTOR/2024/ENU/?guid=5cf3ba03-b3a3-d8ae-1923-4edd807fb7a6 

Edit:  Here is also a link to the online help documentation about Materials & Appearances which tells you that the 'Material' object and the 'RenderStyle' related stuff was retired back in 2013, just for reference.

https://help.autodesk.com/view/INVNTOR/2024/ENU/?guid=GUID-2912C0FB-885F-47ED-81C3-AF19584EA9C1 

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Message 4 of 4

mgFNR8M
Contributor
Contributor

That's perfect. That simple line does exactly what I need.

 

(it gets the appearance from the file and if it doesn't exists it copies from the active library)

 

Thanks!!!

0 Likes