淘宝官方店     推荐课程     在线工具     联系方式     关于我们  
 
 

微波射频仿真设计   Ansoft Designer 中文培训教程   |   HFSS视频培训教程套装

 

Agilent ADS 视频培训教程   |   CST微波工作室视频教程   |   AWR Microwave Office

          首页 >> Ansoft Designer >> Ansoft Designer在线帮助文档


Ansoft Designer / Ansys Designer 在线帮助文档:


Generating Reports and Postprocessing >
User Defined Outputs: Python Script API >
   Using .NET Collection Classes and Interfaces in Python Scripts       


Using .NET Collection Classes and Interfaces in Python Scripts

Some of the API functions specified above use .Net collection classes and interfaces, i.e., Array class, IList interface, IEnumerable interface, and IDictionary interface. The following section describes how to work with the .Net collection objects in python scripts.

.NET Array, IEnumerable, and IList objects can be indexed and iterated over as if they were Python lists. You can also check for membership using 'in'. To get .Net Array and IList sizes you can use python’s 'len' or .Net ‘Count’.

Example:

Getting size:

arraySize = doubleDataArray.Count

arraySize = len(doubleDataArray)

 

listSize = sweepsNamesList.Count

listSize = len(sweepsNamesList)

Iterating:

for sweep in sweepsNamesList:

print sweep

for in in xrange(listSize)

print sweepsNamesList[i]

Checking for membership:

if ‘Time’ in sweepsNamesList:

doThis()

else:

doThat()

For .NET IDictionary, same as for Array and IList, you can get size with ‘len’ or ‘Count’ and check for membership of the keys using 'in'. Getting values for the keys also works the same way as in python ‘dict’.

Example

Getting size:

varValuesSize = varValues.Count

varValuesSize = len(varValues)

Checking for membership:

if ‘offset’ in varValues:

print varValues[‘offset’]

Getting value:

if ‘offset’ in varValues:

offsetValue = varValues[‘offset’]

As for iteration .NET Dictionary is different from python dict. While iterating, python dict will return keys, .Net Dictionary will return .Net KeyValuePair.

Example:

Iterating:

for .Net IDictionary:

for varPair in varValues: #varPair is of .Net KeyValuePair type

varName = varPair.Key

varValue = varPair.Value

 

for python dict:

for varName in varValues:

varValue = varValues[varName]

You can use python types instead of .Net types if you prefer. For this you need to cast .Net Array and .Net iList to python list type and .Net Dictionary to python dict type.

Casting should not be used for data arrays – it can be extremely costly for the memory usage as well as time consuming.

Example:

aPythonList = list(dotNetArray)

aPythonList = list(dotNetList)

aPythonDict = dict(dotNetDictionary)

 




HFSS视频教学培训教程 ADS2011视频培训教程 CST微波工作室教程 Ansoft Designer 教程

                HFSS视频教程                                      ADS视频教程                               CST视频教程                           Ansoft Designer 中文教程


 

      Copyright © 2006 - 2013   微波EDA网, All Rights Reserved    业务联系:mweda@163.com