Here is how to build a list of materials and apply it to a
multi-value parameter in an action
// Update_Material_List
parameter = ( parameter == True ) ? False ; True
Let ioRepRef ( VPMRepReference )
ioRepRef = GetPLMOwner( Material_Name ) // Parameter From Tree
Let ioRef ( VPMReference )
ioRef = ioRepRef.AggregatingReference : VPMReference // Get Parent
Product of the Parameter
Notify("#" , ioRef.PLM_ExternalID )
CreateProgressBar( "Querying Material: " + Material_Name )
ProgressBarSetValue( 5 )
ProgressBarSetText( "Querying..." )
Let ioPLMQuery ( PLMQuery )
Let ioPLMResultsList ( List )
ioPLMQuery = CreatePLMQuery( "CATMATReference" )
ioPLMQuery.AddCriterion( "project" , "Standard" )
ioPLMQuery.AddCriterion( "current" , "RELEASED" )
ioPLMResultsList = ioPLMQuery.RunQuery()
Notify("Number of Results Found : #" ,
ioPLMResultsList->Size())
Let ioPLMQueryResult( PLMQueryResult )
Let ioResultStringList ( List )
Let ioIndex ( Integer )
ioIndex = 1
For ioPLMQueryResult inside ioPLMResultsList
{
Let ioMaterialRef ( CATMatReference )
ioMaterialRef = ioPLMQueryResult.LoadResult( ) :
CATMatReference
Notify("#" , ioMaterialRef.V_Name)
ioResultStringList->Append( ioMaterialRef.V_Name )
ProgressBarSetValue( ( 100 / ioPLMResultsList->Size() ) *
ioIndex)
ProgressBarSetText( "Material Found : " + ioMaterialRef.V_Name
)
ioIndex = ioIndex + 1
}
ioResultStringList->RemoveDuplicates()
ProgressBarSetValue( 100 )
Material_Name.AuthorizedValues = ioResultStringList
Here is how to apply the material from the list with EKL this
was written as an action
// Material_Name : String
//Apply_Material_On_Body : Boolean
Let oMaterialApplied ( Boolean )
Let ioRepRef ( VPMRepReference )
ioRepRef = GetPLMOwner( Material_Name ) // Parameter From Tree
Let ioRef ( VPMReference )
ioRef = ioRepRef.AggregatingReference : VPMReference // Get Parent
Product of the Parameter
Notify("#" , ioRef.PLM_ExternalID )
CreateProgressBar( "Applying Material: " + Material_Name )
ProgressBarSetValue( 50 )
ProgressBarSetText( "Querying..." )
Let ioPLMQuery ( PLMQuery )
Let ioPLMResultsList ( List )
ioPLMQuery = CreatePLMQuery( "CATMATReference" )
ioPLMQuery.AddCriterion( "project" , "Standard" )
ioPLMQuery.AddCriterion( "V_Name" , Material_Name )
ioPLMQuery.AddCriterion( "current" , "RELEASED" )
ioPLMResultsList = ioPLMQuery.RunQuery()
Notify("Number of Results Found : #" ,
ioPLMResultsList->Size())
If( ioPLMResultsList->Size() > 0 )
{
Let ioPLMQueryResult( PLMQueryResult )
ioPLMQueryResult = ioPLMResultsList [ 1 ]
Let ioMaterialReference ( CATMatReference )
Let ioMaterialConnection ( CATMatConnection )
Set ioMaterialReference = ioPLMQueryResult.LoadResult( True )
Let ioPath ( String )
ioPath = "" // Create Material on Part Level
If( Apply_Material_On_Body == True )
{
Let ioFeatureList ( List )
Let Support( Feature )
ioFeatureList =
GetRootUI()->Query("BodyFeature","x.Name=="PartBody"") // Find
the Part Body for the Path
Support = ioFeatureList[ 1 ]
ioPath = ioRef->CreatePathString( NULL , Support )
Notify( "Path to Partbody is : #" , ioPath )
}
Set oMaterialApplied = SetMaterialCore(ioRef , ioPath ,
ioMaterialReference , ioMaterialConnection )
ProgressBarSetValue( 50 )
}
Else
{
Message( "Material Not Found in the Database : #" , Material_Name
)
}