IAccessConstraint#

class ansys.stk.core.stkobjects.IAccessConstraint#

AccessConstraint used to access the AccessConstraint attributes.

Overview#

constraint_name

Property used to access the constraint name.

is_plugin

Return true if the access constraint is a plugin.

exclusion_interval

Exclude Time Intervals.

constraint_type

Property used to access the constraint type.

maximum_time_step

Maximum time step used in adaptive sampling.

maximum_relative_motion

Maximum relative motion used in adaptive sampling.

Examples#

Get access between objects by path using the existing accesses

# STKObjectRoot root: STK Object Model root
scenario = root.current_scenario
accesses = scenario.get_existing_accesses()

size = len(accesses)  # number of accesses

object1 = accesses[0][0]  # e.g. "Satellite/MySatellite"
object2 = accesses[0][1]  # e.g.  "Facility/MyFacility"
computed = accesses[0][2]  # e.g. True  (if access has been computed)

access = scenario.get_access_between_objects_by_path(object1, object2)

Configure the access interval to the availability time span of the object where access is being computed to

# STKObjectRoot root: STK Object Model root

satellite = root.get_object_from_path("Satellite/MySatellite")
facility = root.get_object_from_path("Facility/MyFacility")
access = satellite.get_access_to_object(facility)

access.access_time_period = AccessTimeType.SPECIFIED_TIME_PERIOD
accessTimePeriod = access.access_time_period_data

if satellite.analysis_workbench_components.time_intervals.contains("AvailabilityTimeSpan"):
    availabilityTimeSpan = satellite.analysis_workbench_components.time_intervals.item("AvailabilityTimeSpan")
    accessTimePeriod.access_interval.set_implicit_interval(availabilityTimeSpan)

Remove all access constraints except for Line Of Sight

# AccessConstraintCollection accessConstraints: Access Constraint collection
for i in range(accessConstraints.count - 1, 0, -1):
    constraint = accessConstraints.Item(i).ConstraintName

    if (constraint == "LineOfSight") is False:
        if constraint == "ThirdBodyObstruction":
            thirdBodyConstraint = accessConstraints.GetActiveNamedConstraint("ThirdBodyObstruction")
            assignedArray = thirdBodyConstraint.AssignedObstructions

            for j in range(0, len(assignedArray)):
                thirdBodyConstraint.RemoveObstruction(assignedArray[j])

        elif constraint == "ExclusionZone":
            accessConstraints.GetActiveNamedConstraint("ExclusionZone").RemoveAll()

        else:
            accessConstraints.RemoveNamedConstraint(constraint)

Add an Exclusion Zone access constraint

# AccessConstraintCollection accessConstraints: Access Constraint collection
excludeZone = accessConstraints.add_named_constraint("ExclusionZone")
excludeZone.maximum_latitude = 45
excludeZone.minimum_latitude = 15
excludeZone.minimum_longitude = -75
excludeZone.maximum_longitude = -35

Add multiple access constraints of the same type to an STK Object

# AccessConstraintCollection accessConstraints: Access Constraint collection

# Add constraints
# Only the eCstrApparentTime (4), eCstrDuration (13), eCstrGMT (16), eCstrIntervals (22), eCstrLocalTime (27) constraint
# types can be added multiple times to the constraint collection.
time1 = accessConstraints.add_constraint(AccessConstraintType.LOCAL_TIME)
time1.minimum = "00:00:00.000"
time1.maximum = "23:00:00.000"

Add and configure an altitude access constraint

# AccessConstraintCollection accessConstraints: Access Constraint collection

# To make this more efficient, wrap this method between calls to root.BeginUpdate() and root.EndUpdate()
# Attitude constraint
altitude = accessConstraints.add_constraint(AccessConstraintType.ALTITUDE)
altitude.enable_minimum = True
altitude.minimum = 20.5  # km

Add and configure a central body obstruction access constraint

# AccessConstraintCollection accessConstraints: Access Constraint collection
# Get IAgAccessCnstrCbObstruction interface
cbObstrConstraint = accessConstraints.add_constraint(AccessConstraintType.CENTRAL_BODY_OBSTRUCTION)

# AvailableObstructions returns a one dimensional array of obstruction paths
availableArray = cbObstrConstraint.available_obstructions

# In this example add all available obstructions
print("Available obstructions")
for i in range(0, len(availableArray)):
    print(availableArray[i])
    if availableArray[i] != "Sun":  # Sun is enabled by default
        cbObstrConstraint.add_obstruction(availableArray[i])

# AssignedObstructions returns a one dimensional array of obstruction paths
assignedArray = cbObstrConstraint.assigned_obstructions

print("Assigned obstructions")
for i in range(0, len(assignedArray)):
    print(assignedArray[i])

Add and configure a sun elevation angle access constraint

# AccessConstraintCollection accessConstraints: Access Constraint collection

# To make this more efficient, wrap this method between calls to root.BeginUpdate() and root.EndUpdate()
minmax = accessConstraints.add_constraint(AccessConstraintType.SUN_ELEVATION_ANGLE)
minmax.enable_minimum = True
minmax.minimum = 22.2
minmax.enable_maximum = True
minmax.maximum = 77.7

Add and configure a lunar elevation angle access constraint

# AccessConstraintCollection accessConstraints: Access Constraint collection

# To make this more efficient, wrap this method between calls to root.BeginUpdate() and root.EndUpdate()
minmax = accessConstraints.add_constraint(AccessConstraintType.LUNAR_ELEVATION_ANGLE)
minmax.enable_minimum = True
minmax.minimum = 11.1
minmax.enable_maximum = True
minmax.maximum = 88.8

Add and configure a Line Of Sight sun exclusion access constraint

# AccessConstraintCollection accessConstraints: Access Constraint collection

# Angle constraint
cnstrAngle = accessConstraints.add_constraint(AccessConstraintType.LIGHT_OF_SIGHT_SOLAR_EXCLUSION_ANGLE)
cnstrAngle.angle = 176.0

Add and configure a lighting condition access constraint

# AccessConstraintCollection accessConstraints: Access Constraint collection

# Condition constraint
light = accessConstraints.add_constraint(AccessConstraintType.LIGHTING)
light.condition = ConstraintLighting.DIRECT_SUN

Return a list of available constraints

# AccessConstraintCollection accessConstraints: Access Constraint collection
constraintArray = accessConstraints.available_constraints()

print("List of Available Constraints:")
for i in range(0, len(constraintArray)):
    print(constraintArray[i])

Import detail#

from ansys.stk.core.stkobjects import IAccessConstraint

Property detail#

property IAccessConstraint.constraint_name: str#

Property used to access the constraint name.

property IAccessConstraint.is_plugin: bool#

Return true if the access constraint is a plugin.

property IAccessConstraint.exclusion_interval: bool#

Exclude Time Intervals.

property IAccessConstraint.constraint_type: AccessConstraintType#

Property used to access the constraint type.

property IAccessConstraint.maximum_time_step: float#

Maximum time step used in adaptive sampling.

property IAccessConstraint.maximum_relative_motion: float#

Maximum relative motion used in adaptive sampling.