Description This function assigns a coating model to multiple surfaces. The surfaces can be either explicitly defined in an array argument or be implied by the array arguments through use of the recursive option. An Update command should be issued after calling this function (doesn't have to be immediately after, but before the script finishes execution) to ensure that the assignments have fully propagated through the object tree.
Syntax count = SetSurfsAssignMaterials( mat1, mat2, items(), recursive )
Parameters count (Long) Returned number of surfaces that had their materials set. Materials are only assigned to surfaces. Depending on the construction of the items() array and the use of the recursive option, the number of material assignments made can be different from the number of items in the items() array.
mat1 As Long Node number of the first material being assigned (ordering of materials in assignment does not matter). For lens, mirror and prism type elements, mat1 will specify the immersion material of the object and mat2 specifies the substrate material. If either mat1 or mat2 has a value of -1, the material assignment for that slot will be ignored. When operating on source nodes, mat1 designates the source immersion material and mat2 is not applied.
mat2 As Long Node number of the second material being assigned (ordering of materials in assignment does not matter). For lens, mirror and prism type elements, mat1 will specify the immersion material of the object and mat2 specifies the substrate material. If either mat1 or mat2 has a value of -1, the material assignment for that slot will be ignored. When operating on source nodes, mat1 designates the source immersion material and mat2 is not applied.
items() As Long Node number of the items that the material assignment should occur on. If an item is a surface, then the materials are assigned to the surface. If an item is not a surface and the recursive argument is set to False, then the item is ignored. If an item is not a surface and the recursive argument is set to True, then the materials are assigned to any surfaces which are descended from the item.
recursive As Boolean If True, any surfaces descended from a node in the items() array will be assigned the materials. If False, the materials are only assigned to a surface if the surface is specified in the items() array.
Example The example below retrieves a list of items which have been assigned the "Design Path" keyword, then assigns all of these items a coating, raytrace control scatter model and two materials.
Sub Main
'Construct array of keywords Dim kws(0) As Long kws(0) = KeywordFind( "Design Path" )
'Construct array of items having keywords of interest Dim items() As Long KeywordsGetAppliedItems( "ent", kws(), items() )
'Assign desired properties to retrieved items Dim coat As Long, mat1 As Long, mat2 As Long Dim rctrl As Long, scat As Long coat = FindCoating( "Gold Thin Film" ) rctrl = FindRaytraceCtrl( "Reflective Optics" ) mat1 = FindMaterial( "Al" ) mat2 = FindMaterial( "Air" ) scat = FindScatter( "Harvey Shack" ) SetSurfsAssignCoating( coat, items(), False ) SetSurfsAssignRaytraceCtrl( rctrl, items(), False ) SetSurfsAssignMaterials( mat1, mat2, items(), False ) SetSurfsAssignScatter( scat, items(), False )
End Sub
See Also
|