调用库: STK Object Model modules (e.g. agi.stk12.stkobjects)
继承自: Python本身的 IntEnum / IntFlag
使用方式: 通过 | 将Enum中的不同元素进行连接
Python
1 2 3 4 5 6 7 8 910
fromagi.stk12.stkobjectsimportAgESTKObjectType# AgESTKObjectType is a enum: AgESTKObjectType = [a, b, c, d, ...]fac=ObjectRoot.CurrentScenario.Children.New(AgESTKObjectType.eFacility,"fac1")fromagi.stk12.graphicsimportAgEStkGraphicsCylinderFill# AgEStkGraphicsCylinderFill = [a, b, c, d, ...]# AgEStkGraphicsCylinderFill inherits from IntFlag and may be combinedcyl_fill=AgEStkGraphicsCylinderFill.eStkGraphicsCylinderFillBottomCap|AgEStkGraphicsCylinderFill.eStkGraphicsCylinderFillTopCap
fromagi.stk12.stkdesktopimportSTKDesktopfromagi.stk12.stkutilimportAgEExecMultiCmdResultActionstk=STKDesktop.StartApplication()connect_commands=['GetStkVersion /','New / Scenario ExampleScenario']#use a list of stringscommand_results=stk.ExecuteMultipleCommands(commands,AgEExecMultiCmdResultAction.eContinueOnError)
fromagi.stk12.stkobjectsimportAgFacility,AgESTKObjectTypetry:# this facility is not a valid STK referencemy_facility_attempt=AgFacility()my_facility_attempt.HeightAboveGround=123.4exceptSTKRuntimeErrorase:print(e)# this facility represents a valid STK objectmy_facility=AgFacility(ObjectRoot.CurrentScenario.Children.New(AgESTKObjectType.eFacility,"fac1"))my_facility.HeightAboveGround=123.4
These classes have an Item() method that may be used to get an indexed item from the collection, but they also support Python indexing and iteration.
Python
123456789
fromagi.stk12.stkdesktopimportSTKDesktopfromagi.stk12.stkutilimportAgEExecMultiCmdResultActionstk=STKDesktop.StartApplication()connect_commands=['GetStkVersion /','New / Scenario ExampleScenario']command_results=stk.Root.ExecuteMultipleCommands(connect_commands,AgEExecMultiCmdResultAction.eContinueOnError)first_message=command_results.Item(0)# iterator formatalso_first_message=command_results[0]# index format