Description This function assigns a keyword to an item. The item is specified by an argument indicating the item type (ex. source, geometry, material, etc.) and the item node number. Specifying the item type is critical because of how FRED stores node numbers internally. For example, it is possible to have two items with node #5, one being a geometry element and one being a material definition. Specifying the item type is required to remove any ambiguity about which node #5 is being referenced.
Syntax kwRet = KeywordApplyToItem( itemType, kw, itemId )
Parameters kwRet (Long) Value returned by the function call. A returned value of 1 indicates a successful assignment and a return value of 0 indicates a failed assignment.
itemType As String String indicating the type of item being modified. Options are:
kw As Long Node number of the keyword being applied to the item.
itemId As Long Node number of the item being assigned the keyword. The type of item is given by itemType.
Example The following script checks for the existence of a keyword with a given name and either retrieves the node number of the existing keyword or creates a new keyword node, then loops over the entities in the system (sources, geometry and analysis surfaces) and assigns the keyword to any surface that has a scatter model.
Sub Main
'Check to see if the keyword exists. If not, add it. Dim kw As Long, kwName As String kwName = "Scattering Surface" kw = KeywordFind( kwName ) If kw < 0 Then kw = KeywordAdd( kwName, "A custom keyword example" ) End If
'Loop over the entities in the model and assign the keyword to any 'surface with a scatter model applied. Dim curEnt As Long For curEnt = 0 To GetEntityCount()-1 If IsSurface(curEnt) Then If GetSurfScatterCount(curEnt) > 0 Then KeywordApplyToItem( "ent", kw, curEnt ) End If End If Next
End Sub
See Also
|