iLogic: set appearance to As Material

iLogic: set appearance to As Material

cmcconnell
Collaborator Collaborator
1,438 Views
4 Replies
Message 1 of 5

iLogic: set appearance to As Material

cmcconnell
Collaborator
Collaborator

I have added material and appearance dropdown to my new part property form (triggered when I start a new part). I have rules triggered when starting a part that builds user parameter (with lists) from the material library and the appearance library. This works great.

 

My problem is this: There seems to be no way to have the appearance dropdown default to As Material.

 

Does anybody know how to accomplish this?

Mechanix Design Solutions inc.
0 Likes
1,439 Views
4 Replies
Replies (4)
Message 2 of 5

AlexFielder
Advisor
Advisor

This post *might* help you (with the syntax of this since I just realised it relates to Part material, not appearance):

http://adndevblog.typepad.com/manufacturing/2013/07/inventor-2014-api-set-part-material.html

 

The code posted above is VBA but you can easily change it to iLogic.

 

0 Likes
Message 3 of 5

AlexFielder
Advisor
Advisor

Here's my take on the rule in ^ post:

 

Private Sub Main() 

Dim oDoc As PartDocument = ThisApplication.ActiveDocument
Dim Name As String

'Name = "Copper"
Name = "Steel"

Dim localAsset As Asset = Nothing

Try
	localAsset = oDoc.Assets.Item(Name)
Catch
	' Failed to get the appearance
	' in the document, so import it.

	' Get an asset library by name.
	' Either the displayed name (which
	' can changed based on the current language)
	' or the internal name
	' (which is always the same) can be used.

	Dim assetLib As AssetLibrary = ThisApplication.AssetLibraries.Item("Autodesk Appearance Library")

'	Set assetLib = ThisApplication.AssetLibraries.Item("AD121259-C03E-4A1D-92D8-59A22B4807AD")



	' Get an asset in the library

'	Dim libAsset As Asset = assetLib.MaterialAssets.Item(Name)
	Dim libAsset As Asset = assetLib.AppearanceAssets.Item(Name)

	' Copy the asset locally.
	localAsset = libAsset.CopyTo(oDoc)
End Try

'	set material to the part
'   oDoc.ActiveMaterial = localAsset

oDoc.ActiveAppearance = localAsset

'	Select the top browser node of the model pane.
'	This is a workaround to refresh materials info in the UI.

Call oDoc.BrowserPanes.ActivePane.TopNode.DoSelect

End Sub

There doesn't appear to be an "As Part" option in the appearance dropdown (inside Inventor 2019); perhaps you've gotten confused with terminology?

Message 4 of 5

cmcconnell
Collaborator
Collaborator

Thanks for responding. I will start by saying that my programming experience is limited.

I am having difficulty understanding if your rule helps me.

I will try and clarify my issue: I have a dropdown to select material (populated on the fly from the library) and a dropdown to select appearance (also populated on the fly). Selecting the material chooses the material for the part. selecting the appearance overrides the material appearance with the selected appearance. I would like it to default to the As Material appearance (pull the appearance from the material) unless I override it by selecting a different appearance.

 

The As Part, As Material and As Feature names are a hold over from before Autodesk destroyed the Materials and Appearances system in Inventor in the 2013 release. I am not sure how many of those terms are still in use in the product.

Mechanix Design Solutions inc.
0 Likes
Message 5 of 5

chandra.shekar.g
Autodesk Support
Autodesk Support

@cmcconnell,

 

Below article may help you to understand difference between Material and Appearance asset.

 

https://knowledge.autodesk.com/support/inventor-products/learn-explore/caas/CloudHelp/cloudhelp/2019...

 

Thanks and regards,


CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network



0 Likes