Imperative Blocks #2

Hi guys! me again…

in my previous post I was able to set the name parameter of drawing sheet using Imperative blocks.

I have now added a loop to the same Imperative block but it doesn’t seem to be working, nor i’m getting any errors or warnings.

any ideas?

Many thanks

Is there a reason you want to do this in DesignScript instead of Python?
I’m not great with code but I usually have better luck in Python.

No reason other than I’m not very familiar with python. If I have hit a wall here I will try using python but come on, what good is DS if you can’t loop and set Revit parameters?

you want to check i I think, not Names

Why do you need to loop it? It’s processing a single list which can be done with standard lacing, no matter how many conditions you have… am I missing something?

con1;
con2;
names;

n_names = [Imperative]
{
   out = {};
   for (i in GetKeys(names))
   {
      if (names[i] == con1)
      {
         out[i] = "True this";
      }
      elseif (names[i] == con2)
      {
         out[i] = "True that";
      }
      else
      {
         out[i] = "All true";
      }
   }
   return = out;
};
1 Like

Jacob,

for some reason the code does not handle list well. The first code sample was dealing with a single sheet. The moment i fed a list of sheets to the imperative block it stopped working, that’s why i thought i needed to iterate through the list?

Thank you for this, but i’m still not able to update the sheet name parameter :frowning:

Ah! Lacing and levels issue. I can check on changing this accordingly later.

1 Like

cheers man!

Imperative 2

con1;
con2;
sheets;
names = sheets.GetParameterValueByName("Sheet Name");

n_names = [Imperative]
{
   out = {};
   for (i in GetKeys(names))
   {
      if (names[i] == con1)
      {
         out[i] = sheets[i].SetParameterByName("Sheet Name", "True this");
      }
      elseif (names[i] == con2)
      {
         out[i] = sheets[i].SetParameterByName("Sheet Name", "True that");
      }
      else
      {
         out[i] = sheets[i].SetParameterByName("Sheet Name", "All true");
      }
   }
   return = out;
};
5 Likes

Organon, you’re the man!

thank you so much for your help. This imperative block works perfectly!

thank you again! :slight_smile:

2 Likes