STK Advance¶
Exceptions¶
- 引入库:
agi.stk12.utilities.exceptions
| Exception | Description |
|---|---|
| STKInitializationError | STKDesktop and STKEngine unable to init or attach to the STK application |
| STKInvalidCastError | cast an object to an unsupported interface or class type |
| STKRuntimeError | STK method call fails |
| STKAttributeError | set an unrecognized attribute within the STK API |
Events¶
Events can be accessed directly in applicable parent objects.

- 使用
Parent Object上的subscribe()访问事件(“订阅这个事件,timeline一直延展”) - 使用
+=/-=进行事件回调处理 - 不再需要事件处理时,使用
Unsubscribe()方法取消订阅
当Python拥有 "事件订阅者" 时,STK桌面应用程序用户界面可能对用户输入无反应,并且STK应用程序试图回到Python解释器中以通知事件
STK's built-in Python Plugins¶
API Modules¶
Interfaces 都存储在 agi.stk12.plugins
获得某个 STK Object Model (of a plugin) 的方式是: 用 IAgStkPluginSite.StkRootObject 获取Object Root
Add properties for Python plugins¶
如果Interface有某种属性,那Class中显然也得有对应的属性
STK支持两种方式在类中设定属性
1)初始化类成员的属性
| Python | |
|---|---|
1 2 3 | |
2)@property装饰器
- 对带有属性名称的方法/函数,使用
@property装饰器 - 返回类型必须匹配属性定义的类型
这里给出一种等价写法:
| Python | |
|---|---|
1 2 3 4 5 6 | |
Hidden parameters for the Object Model¶
root: 是脚本与 STK 对象模型交互的入口点versionString = root.ExecuteCommand('GetStkVersion /')获取root“句柄”
abortMCS: 用于控制任务序列是否中止- 控制 MCS(Mission Control Sequence,任务控制序列)的执行行为
- 当设置为
True时,STK 会在脚本执行后停止 MCS 序列; 默认值为False
iteration: 用于指定任务的迭代次数或条件
gRPC Features¶
对于gRPC而言:
agi.stk12.stkruntime.STKRuntimeApplicationagi.stk12.stkdesktop.STKDesktopApplicationagi.stk12.stkengine.STKEngineApplication
这三个Interfaces, 每个都有下面两个方法:
SetGrpcOptionsNewGrpcCallBatcher
对于 SetGrpcOptions

TL;DR
release batch size:- a form of garbage-collection added to reduce the communication over the gRPC server
- 默认值
(int)12;设置成1表示禁用batch批处理
collection iteration batch size:- When iterating a collection using the syntax
for object in collection:..., the values are requested in batches rather than as each iteration occurs to reduce the communication over the gRPC server - 默认值
(int) 100;设置成1表示禁用batch批处理
- When iterating a collection using the syntax
disable batching- Disables batching of all
agi.stk12.utilities.grpcutilities.GrpcCallBatcherobjects. - 默认值为
False;设置成true会在debug时更有用!
- Disables batching of all
对于 NewGrpcCallBatcher
略之,详见官方文档!