🎉Community Raffle - Win $25

An exclusive raffle opportunity for active members like you! Complete your profile, answer questions and get your first accepted badge to enter the raffle.
Join and Win

How to generate a macro for output values?

User: "LeMarc"
New Altair Community Member
Updated by Jocelyn
Hi,

I would like to generate a general macro which extracts the output (attribute values) independent of the model. Because dependent on the selected model,each output has a different attribute name. Therefore it makes no sense to generate a macro with the "attribute name" of the output.

However, I have no idea how to create such a macro. Can anybody help? Or is there already an Operator with such a function?

Thank you!

Find more posts tagged with

Sort by:
1 - 6 of 61
    Hi,
    so you want to have the name of the label attribute as a macro?
    Best,
    Martin
    User: "LeMarc"
    New Altair Community Member
    OP
    Danke für die schnelle Antwort @mschmitz.
    Ja genau. Das meine ich.
    User: "MartinLiebig"
    Altair Employee
    Accepted Answer
    Hi @LeMarc ,
    das ist interssanterweise etwas, was nicht mit operatoren geht. Ich habe mich auch schon ein paar mal gefragt warum. Anbei ist Prozess, der Execute Script nutzt um das zu lösen. Das ist mein Workaround für das Problem. Ich hoffe, dass das hilft.

    LG,
    Martin
    <?xml version="1.0" encoding="UTF-8"?><process version="9.6.000">
      <context>
        <input/>
        <output/>
        <macros/>
      </context>
      <operator activated="true" class="process" compatibility="9.6.000" expanded="true" name="Process">
        <parameter key="logverbosity" value="init"/>
        <parameter key="random_seed" value="2001"/>
        <parameter key="send_mail" value="never"/>
        <parameter key="notification_email" value=""/>
        <parameter key="process_duration_for_mail" value="30"/>
        <parameter key="encoding" value="SYSTEM"/>
        <process expanded="true">
          <operator activated="true" class="retrieve" compatibility="9.6.000" expanded="true" height="68" name="Retrieve Golf" width="90" x="246" y="85">
            <parameter key="repository_entry" value="//Samples/data/Golf"/>
          </operator>
          <operator activated="true" class="execute_script" compatibility="9.6.000" expanded="true" height="82" name="Execute Script" width="90" x="380" y="85">
            <parameter key="script" value="&#10;ExampleSet inputData =(ExampleSet) input[0];&#10;&#10;String labelName = inputData.getAttributes().getLabel().getName();&#10;operator.getProcess()getMacroHandler().addMacro(&quot;macroName&quot;,labelName);&#10;&#10;return inputData;"/>
            <parameter key="standard_imports" value="true"/>
          </operator>
          <connect from_op="Retrieve Golf" from_port="output" to_op="Execute Script" to_port="input 1"/>
          <portSpacing port="source_input 1" spacing="0"/>
          <portSpacing port="sink_result 1" spacing="0"/>
        </process>
      </operator>
    </process>




    User: "LeMarc"
    New Altair Community Member
    OP

    Danke für deinen Lösungsvorschlag! Leider kann ich nicht programmieren und verstehe daher auch nur ungefähr was codiert wurde. 
    Der Name des generierten Attribut soll im nächsten Schritt für den Operator 'Generat Attribute' verwendet werden. Wie wird das denn mit deinem Lösungsvorschlag umgesetzt?
    User: "MartinLiebig"
    Altair Employee
    Accepted Answer
    Hallo @LeMarc,
    dieses kleine script setzt mit dieser Zeile:
    operator.getProcess()getMacroHandler().addMacro("macroName",labelName);
    den Wert des macros macroName auf den namen des Label attributes. du kannst also in allen weiteren operatoren %{macroName} nutzen und wie gewohnt damit arbeiten. Selbstverständlich kannst du auch irgendeinen anderen namen wählen.

    LG,
    Martin
    User: "LeMarc"
    New Altair Community Member
    OP
    Super, Danke @mschmitz für die Erklärung!