STK ObjectsSend comments on this topic.
AddConstraint Method (IAgAccessConstraintCollection)
See Also
EConstraint
Windows





Windows & Linux

Description

Adds a constraint to the Constraint Collection.



To determine the interface to use for a specific constraint, scroll down to the EConstraint Parameter table near the bottom of this help page. This table lists all possible values for the AgEAccessConstraints enumeration. The description column provides the corresponding interface to use with each constraint. For example, IAgAccessCnstrMinMax is the interface used with the Range constraint, eCstrRange.



Code snippet examples that show how to add and configure constraints are provided at the bottom of this help page.



Deprecation - The functionality to add eCstrApparentTime, eCstrDuration, eCstrGMT, eCstrIntervals, eCstrLocalTime constraint types multiple times to the constraint collection is being deprecated.

Syntax

[Visual Basic .NET]
Public Function AddConstraint( _
    ByVal EConstraint As AgEAccessConstraints _
) As IAgAccessConstraint
[Managed C++]
public: IAgAccessConstraint^ AddConstraint(
    AgEAccessConstraints EConstraint
);
[Unmanaged C++]
public: HRESULT AddConstraint(
    AgEAccessConstraints EConstraint,
    IAgAccessConstraint ** ppIAgAccessConstraint
);
[Python - STK API ]
def AddConstraint(self, EConstraint:"AgEAccessConstraints") -> "IAgAccessConstraint":

Parameters

EConstraint

Return Type

IAgAccessConstraint type.

See Also

Example

Add an access constraint to an STK Object
[C#]
IAgAccessConstraintCollection accessConstraints = stkobject.AccessConstraints;

// Add constraints
accessConstraints.AddConstraint(AgEAccessConstraints.eCstrSunElevationAngle);
Add and configure a central body obstruction access constraint
[C#]
// Get IAgAccessCnstrCbObstruction interface
IAgAccessCnstrCbObstruction cbObstrConstraint = accessconstraints.AddConstraint(AgEAccessConstraints.eCstrCbObstruction) as IAgAccessCnstrCbObstruction;

// AvailableObstructions returns a one dimensional array of obstruction paths
Array availableArray = cbObstrConstraint.AvailableObstructions;

// In this example add all available obstructions
Console.WriteLine("Available obstructions");
foreach (string available in availableArray)
{
    Console.WriteLine(available);
    if ("Sun" != available)  // Don't add "Sun". It was already added.
    {
        cbObstrConstraint.AddObstruction(available);
    }
}

// AssignedObstructions returns a one dimensional array of obstruction paths
Array assignedArray = cbObstrConstraint.AssignedObstructions;

Console.WriteLine("Assigned obstructions");
foreach (string assigned in assignedArray)
{
    Console.WriteLine(assigned);
}
Add multiple access constraints of the same type to an STK Object
[C#]
IAgAccessConstraintCollection accessConstraints = stkobject.AccessConstraints;

// Add constraints
// Only the eCstrApparentTime, eCstrDuration, eCstrGMT, eCstrIntervals, eCstrLocalTime constraint
// types can be added multiple times to the constraint collection.
accessConstraints.AddConstraint(AgEAccessConstraints.eCstrLocalTime);
accessConstraints.AddConstraint(AgEAccessConstraints.eCstrLocalTime);
Add an access constraint to an STK Object
[Visual Basic .NET]
Dim accessConstraints As IAgAccessConstraintCollection = stkobject.AccessConstraints

' Add constraints
accessConstraints.AddConstraint(AgEAccessConstraints.eCstrSunElevationAngle)
Add and configure a central body obstruction access constraint
[Visual Basic .NET]
' Get IAgAccessCnstrCbObstruction interface
Dim cbObstrConstraint As IAgAccessCnstrCbObstruction = TryCast(accessconstraints.AddConstraint(AgEAccessConstraints.eCstrCbObstruction), IAgAccessCnstrCbObstruction)

' AvailableObstructions returns a one dimensional array of obstruction paths
Dim availableArray As Array = cbObstrConstraint.AvailableObstructions

' In this example add all available obstructions
Console.WriteLine("Available obstructions")
For Each available As String In availableArray
	Console.WriteLine(available)
	If "Sun" <> available Then
		' Don't add "Sun". It was already added.
		cbObstrConstraint.AddObstruction(available)
	End If
Next

' AssignedObstructions returns a one dimensional array of obstruction paths
Dim assignedArray As Array = cbObstrConstraint.AssignedObstructions

Console.WriteLine("Assigned obstructions")
For Each assigned As String In assignedArray
	Console.WriteLine(assigned)
Next
Add multiple access constraints of the same type to an STK Object
[Visual Basic .NET]
Dim accessConstraints As IAgAccessConstraintCollection = stkobject.AccessConstraints

' Add constraints
' Only the eCstrApparentTime, eCstrDuration, eCstrGMT, eCstrIntervals, eCstrLocalTime constraint
' types can be added multiple times to the constraint collection.
accessConstraints.AddConstraint(AgEAccessConstraints.eCstrLocalTime)
accessConstraints.AddConstraint(AgEAccessConstraints.eCstrLocalTime)
© 2024 Analytical Graphics, Inc. All Rights Reserved.