Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.
chandra.shekar.g
in reply to: Anonymous

@Anonymous ,

 

Try below iLogic code to select the material from the list.

 Sub Main()
	Dim oDoc As PartDocument
	oDoc = ThisApplication.ActiveDocument
	
	Dim oList As ArrayList = New ArrayList()
	Dim oMaterial As Asset 
	For Each oMaterial In ThisApplication.AssetLibraries.Item(2).AppearanceAssets 
		 
		oList.Add(oMaterial.DisplayName)
	Next
	
	If oDoc.DocumentType = kPartDocumentObject Then

		Dim oPartCompDef As PartComponentDefinition
		oPartCompDef = oDoc.ComponentDefinition
			
		Dim oParams As Parameters
		oParams=oPartCompDef.Parameters
					
		Dim oUserParams As UserParameters
		oUserParams=oParams.UserParameters       
		
		Dim oAwesomeParameter As Parameter                     
				
		Try
			otester = oUserParams.Item("material")
		Catch
			oInsulationType=oUserParams.AddByValue("material", oList.Item(1), kTextUnits) 
		End Try
    End If

	Parameter.Param("material").ExposedAsProperty = False
	Parameter.Param("material").IsKey = True
	MultiValue.List("material") = oList 
	
	selected_mat = InputListBox("Choose Part material", MultiValue.List("material"),oList.Item(1), Title := "Part material", ListName := "Available Standard materials")
	
	Dim oAsset As Asset 
	oAsset = ThisApplication.AssetLibraries.Item(2).AppearanceAssets.Item(selected_mat)
	
	Dim oDocAsset As Asset 
	Try 
		oDocAsset = oDoc.AppearanceAssets.Item(selected_mat)
	Catch
		oAsset.CopyTo(oDoc)
		oDocAsset = oDoc.AppearanceAssets.Item(selected_mat)
	End Try

	Dim oCompDef As ComponentDefinition
	oCompDef = oDoc.ComponentDefinition

	Dim oFaces As Faces
	oFaces = oCompDef.SurfaceBodies(1).Faces

	Dim AttSets As AttributeSets
	Dim AttSet As AttributeSet
	
	Dim oFace As Face 

	For Each oface In oFaces
		 AttSets = oface.AttributeSets
		 If AttSets.NameIsUsed("iLogicEntityNameSet") Then
		  	AttSet = AttSets.Item("iLogicEntityNameSet")
			  For Each Att In AttSet
			    If Att.value = "Top" Then
					oFace.Appearance = oDocAsset
				End If 
			  Next
		 End If
	Next
End Sub
 

 

Thanks and regards,


CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network