Jump to content
Romain B

Documentation regarding classes for Python scripting

Recommended Posts

Hi everyone,


I am definitely not a Python expert, but I've been using PyFlux for quite some time now. I have always had issues guessing the structure of different classes for my scripts and was wondering if there was somewhere a document describing the different classes in PyFlux? If not, a simple screenshot of the classes définitions might help...

I am aware of solutions such as vars(myClassInstance), yet I cannot always find everything I want with this method. Is there another efficient method?

I also know that a lot of tricks can be learnt by checking the code of the provided macros...


For example, my most recent bother is that I am trying to implement a post-processing script that automatically generates reporting on a given scenario, but the control parameters can be mono or

multi value and I cannot know it beforehand. What is the class attribute of the pilot that tells me whether it is mono or multi? Multi defined by step value or by step number?


Than you very much for your help!


Share this post

Link to post
Share on other sites

Hi Romain,


Unfortunately there is no document that can give you all pyflux commands for all entities. Most commands and attributes can be found by doing a help command (for instance "Point.help()" will give you everything about point entity.


We have a few mementos that give some commands and help but not as much as you would expect I suppose.

The best way to create your python script stays the manual way and recovering the log file.


About your reporting, there is an interesting macro called AutomaticReport in the main folder of macros. This can generate a html and txt file whith all the info of your project.


Best regards



Share this post

Link to post
Share on other sites

Hi Simon,


OK, thanks for your answer and the mementos, I had never seen them.

I know this macro but wanted to take it a step further.

I'll see what I can do with the information you gave me!


Have a nice day,

Best regards,




Share this post

Link to post
Share on other sites

Hi Romain,


I have been fighting with that beast also. So I am sharing what I am currently using, maybe it can be helpful for you as well.

In my application, I can either have no parameters, or an unknown number of parameters (with an unknown number of values). In any case, I want to apply the same actions to all possibilities that are solved.


So I have a function that returns a "view" of the situation of my scenario:

import collections
import itertools

def get_index_values_dict(scenario_name):
        Get an ordered dictionary containing the indexes \
        of all steps of a scenario and the corresponding \
        parameters' values. Index 0 contains the names \
        of the parameters.

        :param scenario_name: name of the Scenario
        :type scenario_name: string

        :return: Dictionary containing indexes
            for all steps and corresponding values
        :rtype: OrderedDict(index, values)

        :Example: get_index_values_dict(scenario_name='REFERENCEVALUES')

    # Get all parameters and their values as a dict(param, values)
    values_parameter = Scenario[scenario_name].getValuesParameter()
    # Check if there is at least a parameter
    # otherwise return a dictionary "empty"
    if values_parameter == {}:
        index_values_dict = collections.OrderedDict({0: [], 1: []})
        return index_values_dict
        # Create a list of lists of values
        lists_of_values = []
        for parameter in values_parameter.keys():
        # Fill index 0 of the ordered dict with the name of the parameters
        index_values_dict = collections.OrderedDict(
            {0: values_parameter.keys()})
        # Calculate all combinations of parameters' values
        for values in itertools.product(*lists_of_values):
            # Get corresponding index of the step matching that combination
            index = Scenario[scenario_name].getIndexStep(
            # Add index value and parameters' values in the dict
            index_values_dict[index[0]] = list(values)
        # Return the dict filled with indexes and
        # corresponding parameters' values
        return index_values_dict

And then inside my main "program", I can easily handle all the steps by doing something like:

# Get all steps indexes and corresponding values
index_value_dict = get_index_values_dict(scenario_name)
# Loop over all the steps
# Skip index 0 since it contains only names of parameters and no values
for step in list(index_value_dict.keys())[1:]:


Share this post

Link to post
Share on other sites

Hi Louis,


Thanks for the input! That's an interesting solution.

In my case the issue is slightly different, as I want to automatically generate some parametric curves and also store in a text file the definition of the solved scenario. However, I found the "magic" command for me: getType()


Example of use:


It worked wonders for me as it returns a string describing the type of each pilot (Mono or Multi values) and the type of each interval.


Have fun :-)

Share this post

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

You are posting as a guest. If you have an account, please sign in.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...