Issue setting Global Yes/No Parameter

Good morning everyone,

I am hoping to get some help with setting a Yes/No global parameter. I have successfully modified text based global parameters in this script but the Yes/No is being a pain. Here is the method I am using right now.

As you can see it is not setting the value to Yes.

Any thoughts??

Have you already tried with true/false?

Maybe this is due to the structure of the output of your If statement ? You are setting the value of the Global Parameter to a list containing 1 (aka [1] ), not to the actual value.

@mellouze Here are two attempts at making sure the list is not the problem.
image
image

Both results in the same outcome.

@lucamanzoni I did try true/false but that was last friday so I will try it again just to make sure.
image

Same result. :frowning:

Have you verified that you could edit this parameter ? I think that some parameters are not editable.

I have looked around and have not found any info regarding whether I can or not. I can modify Global text parameters so it would be surprising if the Global Yes/No parameters were off limits.

Edit: I may just use a text parameters and then set the global yes/no parameters to work off of formulas based on the number parameter at this point. Still, I would like to know why this isn’t working.

Upon further testing it almost seems like the only Global Parameter that CAN be modified is a text parameter. I have tried length and number along with yes/no and none of them seem to work except text.

Can anyone verify that this is correct?

@Mostafa_El_Ayoubi

I am trying to utilize your script in lieu of the OOB global nodes since they do not seem to be working for anything except text parameters. When I paste your code I am only getting IN[0] and not IN[1]. Is the script out of date and could you possibly update it to work again? Thanks in advance if you can!

I was thinking about using Python, glad that someone already did it before.
Just change the code like this, and it should work, but only for one parameter at the time.

import clr
clr.AddReference('RevitAPI')
from Autodesk.Revit import DB as db

clr.AddReference('RevitServices')
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

doc = DocumentManager.Instance.CurrentDBDocument

filter =  db.FilteredElementCollector(doc).OfClass(db.GlobalParameter)
gp = UnwrapElement(IN[0])

#getting the right ParameterValue constructor :
methodname = gp.GetValue().GetType().ToString().rsplit('.',1)[-1]

TransactionManager.Instance.EnsureInTransaction(doc)
try:
	#setting the parameter with the right parametervalue constructor
	gp.SetValue(getattr(db,methodname)(IN[1]))
	out = 'success'
except:
	out = 'failed, check if the parameter value is the right type'

TransactionManager.Instance.TransactionTaskDone()

OUT = out

1 Like


Are you using Dynamo 2.0.? or 1.3.? I am in 2.0.?

I paste what you posted and still only have one input. It must be Monday.

Click on the “+” sign of the Python Script :stuck_out_tongue:

1 Like

Hah!

1 Like

Thanks guys! Now I can finish this bad boy and get it deployed!

.