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.
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.
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.
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
Hello @lucamanzoni, does your script work on Lenght Parameter Type? I need to set a quote value on global parameters. I create a global parameter and set it on Lenght Parameter Type, but using that script it does not work. Any ideas?
I am new on Dynamo and do not know hot to use Python at this moment