Navigation: Scripting Reference Manual > Functions & Subroutines > AddGroup

 

AddGroup

 

Contact Us: fredsupport@photonengr.com

 

Description

Adds a group to the associated FRED document.

 

Syntax

n = AddGroup ( gname, desc )

 

Parameters

n (Long)

Node number of the new group.

 

gname As String

The name assigned to the new group.

 

desc As String

The description assigned to the new group.

 

 

Remarks

This function adds a group to the associated FRED document. If there is a problem, the function returns 0 and does not set an error.

 

See Also

GetGroupCount

GetNthGroupCount

FindGroup

AddToNthGroup

DeleteFromNthGroup

GetFromNthGroup

 

 

Example

The following example adds two groups with name and description to a document then adds selected elements to each group. In this case, most elements are lenses requiring the additional use of the GetChild and GetSibling commands.

 

Dim id0&, id1&, id2&, gname$, child&, sibling&, count&
 

id0 = AddGroup("First Group", "first lens and stop")
Print "group node number is " & id0

id1=FindFullName("Geometry.triplet.Lens 1-2")
id2=FindFullName("Geometry.triplet.Surface 3.Surf 3")

child = GetChild(id1)
 While child>0
  count = AddToNthGroup(id0,child)
  child = GetSibling(child)
 Wend
count = AddToNthGroup(id0,id2)
Print GetNthGroupCount(id0) & " items added to group " & id0

id0 = AddGroup( "Second Group", "second and third lenses" )
Print "group node number is " & id0

id1=FindFullName("Geometry.triplet.Lens 4-5")
id2=FindFullName("Geometry.triplet.Lens 6-7")

child = GetChild(id1)
 While child>0
  count = AddToNthGroup(id0, child)
  child = GetSibling(child)
 Wend

child = GetChild(id2)
 While child>0
  count = AddToNthGroup(id0,child)
  child = GetSibling(child)
 Wend
Print GetNthGroupCount(id0) & " items added to group " & id0

 

 

 

 

 

 

Copyright © Photon Engineering, LLC