Navigation: Scripting Reference Manual > Functions & Subroutines > KeywordsGetAppliedItems

 

KeywordsGetAppliedItems

 

Contact Us: fredsupport@photonengr.com

 

Description

Given a list of keyword nodes, this function returns the item node numbers for any item that has at least one of the input keywords assigned.  An 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 = KeywordsGetAppliedItems( itemType, kws( ), itemNodes() )

 

 

Parameters

kwRet (Long)

Returned value indicating the number of items that were found having one or more assigned keywords of those specified in the kws() array.

 

itemType As String

String indicating the type of item being queried.  Options are:

itemType

Meaning

"ent"

Source, Geometry or Analysis Surface

"geo"

Source, Geometry or Analysis Surface

"coat"

Coating

"mat"

Material

"ray"

Raytrace Property

"cont"

Raytrace Property

"ctrl"

Raytrace Property

"prop"

Raytrace Property

"rough"

Surface Roughness

"scat"

Scatterer

"spect"

Spectrum

 

kws() As Long

Array containing the list of keyword nodes.  If an item has assigned at least one of these keyword nodes, the item is added to the itemNodes() array.

 

itemNodes() As Long

This array is passed in as an argument but after the function is executed will contain the list of item node numbers having at least one of the keywords specified in kws() assigned.

 

 

Example

The example below demonstrates how to use KeywordsGetAppliedItems in pair with KeywordsRemoveFromItems in order to remove all keyword assignments from all entities.  The example starts by populating the keys() array with all keyword node numbers, then calls KeywordsGetAppliedItems to retrieve the array of item node numbers having keywords assigned, and then finally calls KeywordsRemoveFromItems in order to remove the keywords from the items.

 

Sub Main

 

    ClearOutputWindow()

 

    'Populate an array with all keyword node numbers

    Dim keys() As Long, items() As Long, curKey As Long, keyCount As Long

    Dim itemType As String

    itemType = "ent"

    keyCount = KeywordCount()

    ReDim keys(keyCount-1)

    For curKey = 0 To keyCount-1

        keys(curKey) = curKey

    Next

 

    'Retrieve the item node numbers that have keywords assigned

    Dim getRet As Long

    getRet = KeywordsGetAppliedItems( itemType, keys(), items() )

    Print "Get applied items return = " & getRet

 

    'Remove all keywords from the items

    Dim remRet As Long

    If getRet > 0 Then

        remRet = KeywordsRemoveFromItems( itemType, keys(), items() )

        Print "Remove applied items return = " & remRet

    End If

 

End Sub

 

See Also

Keyword Scripting Commands

 

 

 

 

 

Copyright © Photon Engineering, LLC