TypeError: SetValue() takes exactly 2 arguments (1 given)

I am trying to set a parameter value with an angle/integer type so SetParameterByName wont work, I also tried Set but it did not work either

here is the piece of code
titleparam[0].SetValue(Angle)

titleparam is a parameter, and Angle is called from a for loop from a list of values.

i get this error TypeError: SetValue() takes exactly 2 arguments (1 given)

@osayed643PD can you try to post the whole code here so you can get proper help?

for BuildingNo, direction,Angle in zip(BuildingNoValue, DirectionValue, AngleValue):
        TransactionManager.Instance.EnsureInTransaction(doc)
        theSheet[0].SetParameterByName("BLDG. NO.", str(BuildingNo))
        theSheet[0].SetParameterByName("UNIT ORIENTATION", str(direction))
        titleparam[0].SetValue(Angle)
        TransactionManager.Instance.TransactionTaskDone()
        y = TitleBlock[0].GetParameterValueByName(IN[8])
        debuglist.append(y)
        PrintView(doc,theSheet,pRange, printerName, combined, filePath,printSetting)

I believe you should use Set() instead of SetValue(). It looks like the latter is for a different purpose in Revit API, and that one has two arguments.

For setting an angle parameter I think this should work:

1 Like

Gavin is correct, .Set is the method you’re looking for. You said you already tried it, can you show us the error it’s giving you when you use .Set?

Hello,
Revit.Elements.Parameters.SetValue(Parameter parameter, object value) is a static method, not instance.

titleparam[0].Set(Angle)

AttributeError: ‘Parameter’ object has no attribute ‘Set’

I would suggest using the LookupParameter method to get the parameter by name in the Revit API which should then allow you to set that parameter, assuming it is available at an instance level.

@osayed643PD use Revit.Elements.Parameters (Dynamo Wrapper) not DB.Parameter (Revit API)

1 Like

not sure how to do that, can you please write a line of code to import?

still it does not understand the word Set

i did from Revit.Elements import* still not working

Hi,
here an example, if you want to work with the Revit Dynamo wrapper

import sys
import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *

clr.AddReference('RevitNodes')
import Revit
clr.ImportExtensions(Revit.GeometryConversion)
clr.ImportExtensions(Revit.Elements)

clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
doc = DocumentManager.Instance.CurrentDBDocument

elem = IN[0]
parameterName = IN[1]
new_value = IN[2]
TransactionManager.Instance.EnsureInTransaction(doc)
wrap_parameter = next((p for p in elem.Parameters if p.Name == parameterName), None)
if wrap_parameter is not None:
	Revit.Elements.Parameter.SetValue(wrap_parameter, new_value)
TransactionManager.Instance.TransactionTaskDone()

OUT = wrap_parameter

if you want to work directly with the Revit API, you need to unwrap the input element
more info here

1 Like

thank you so much for your response!

But you are using SetValue() and I need to use Set() because the storage type is not a string(it is a number). thats what the error said after I tried your code. I tired using Set() but there is no attribute for it.

it’s work with number (Double)

Your storage type is Integer?

Solution using Revit API (need to Unwrap the input Element)

import sys
import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *

clr.AddReference('RevitNodes')
import Revit
clr.ImportExtensions(Revit.GeometryConversion)
clr.ImportExtensions(Revit.Elements)

clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
doc = DocumentManager.Instance.CurrentDBDocument

elem = UnwrapElement(IN[0])
parameterName = IN[1]
new_value = IN[2]
TransactionManager.Instance.EnsureInTransaction(doc)
parameter = elem.LookupParameter(parameterName)
if parameter is not None:
	parameter.Set(new_value)
TransactionManager.Instance.TransactionTaskDone()

OUT = elem