"[SOLVED] catch the attribute name to a macro"

sfmorais
sfmorais New Altair Community Member
edited November 5 in Community Q&A
Hi everybody!

Is there any way to get the 'attribute name' of a example set (to put for example in a macro) to use later in a 'set data' operator ?  

In middle of my process I have one example set with only 1 example and 1 attribute (1 cell), but the attribute is not the same. I need to catch the name of that attribute to use later as parameter in the 'set data' operator.

Thanks for the help

Regards
Sérgio Morais

Answers

  • haddock
    haddock New Altair Community Member
    Hi there,

    There may well be other ways, but you can loop through the attributes, like this..
    <?xml version="1.0" encoding="UTF-8" standalone="no"?>
    <process version="5.1.013">
      <context>
        <input/>
        <output/>
        <macros/>
      </context>
      <operator activated="true" class="process" compatibility="5.1.013" expanded="true" name="Process">
        <process expanded="true" height="457" width="839">
          <operator activated="true" class="generate_data" compatibility="5.1.013" expanded="true" height="60" name="Generate Data" width="90" x="45" y="75"/>
          <operator activated="true" class="loop_attributes" compatibility="5.1.013" expanded="true" height="60" name="Loop Attributes" width="90" x="183" y="73">
            <process expanded="true" height="457" width="839">
              <operator activated="true" class="set_macro" compatibility="5.1.013" expanded="true" height="76" name="Set Macro" width="90" x="179" y="75">
                <parameter key="macro" value="%{MYMACRO}"/>
                <parameter key="value" value="%{loop_attribute}"/>
              </operator>
              <operator activated="true" class="provide_macro_as_log_value" compatibility="5.1.013" expanded="true" height="76" name="Provide Macro as Log Value" width="90" x="368" y="21">
                <parameter key="macro_name" value="%{MYMACRO}"/>
              </operator>
              <operator activated="true" class="log" compatibility="5.1.013" expanded="true" height="76" name="Log" width="90" x="514" y="18">
                <list key="log">
                  <parameter key="MYMACRO" value="operator.Set Macro.value.macro_value"/>
                </list>
              </operator>
              <connect from_port="example set" to_op="Set Macro" to_port="through 1"/>
              <connect from_op="Set Macro" from_port="through 1" to_op="Provide Macro as Log Value" to_port="through 1"/>
              <connect from_op="Provide Macro as Log Value" from_port="through 1" to_op="Log" to_port="through 1"/>
              <connect from_op="Log" from_port="through 1" to_port="example set"/>
              <portSpacing port="source_example set" spacing="90"/>
              <portSpacing port="sink_example set" spacing="0"/>
            </process>
          </operator>
          <connect from_op="Generate Data" from_port="output" to_op="Loop Attributes" to_port="example set"/>
          <connect from_op="Loop Attributes" from_port="example set" to_port="result 1"/>
          <portSpacing port="source_input 1" spacing="0"/>
          <portSpacing port="sink_result 1" spacing="0"/>
          <portSpacing port="sink_result 2" spacing="0"/>
        </process>
      </operator>
    </process>
    Check out the text view of the log to see the results.

    Good luck.
  • sfmorais
    sfmorais New Altair Community Member

    Ok! Thanks. The example helped me.