Can I pass macro in extract macro

sgnarkhede2016
sgnarkhede2016 New Altair Community Member
edited November 5 in Community Q&A
Hello,

I want to pass attribute name dynamically as loop iteration like in 1st iteration in "attribute name" is "attribute_1" in second "attribute_2" and so on.

when i checked in generate attribute this macro gives correct result what i want "SCENARIOPARAMETER_"+%{iteration}" but same when i passed in extract macro giving error " attribute not present in input data" and hardcoded workling

Answers

  • MartinLiebig
    MartinLiebig
    Altair Employee
    Hi,
    i guess you want to use the attribute function. to access the value of attribute_%{iteration} you usually do

    attribute("attribute_"+%{iteration})
    There are some more things you can do with the # notation instead of %, but i always forget them and need to ask @David_A

    Best,
    Martin
  • David_A
    David_A New Altair Community Member
    Hi,

    the attribute() function is exactly the thing you're looking for. It will resolve the macro value first and and then looks the combined string as an attribute name.  With the # you could basically do the same, but the function is the more readable approach.

    Best,
    David