Parameter Read-Only Problem

Hello everyone,
I’m unable to change the value of the parameter ‘Switch ID’ . I’m using 2 Families with a common parameter mentioned before (‘Switch ID’). The 1º Family is of a built in category type ‘Lighting Fixture’, the 2º Family is a custom created ‘Lighting Devices’.

I have already tried the following dynamo coding with the python script respectively. But no luck there.

import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
import clr
clr.AddReference('RevitAPI')
import Autodesk
from Autodesk.Revit.DB import *
clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
		
doc = DocumentManager.Instance.CurrentDBDocument

x = IN[0][0]

z = UnwrapElement(x)

TransactionManager.Instance.EnsureInTransaction(doc)
zz = z.LookupParameter('Switch ID').Set('N')
TransactionManager.Instance.TransactionTaskDone()

I want to be able to force write the parameter value under ‘Switch ID’ of the ‘Lighting Fixture’ Family

Thanks in advance.

Best of regards,
Jonathan Oliveira

Couple thing I’d ask.
What does the error message say?
Are they instance or Type parameters?
I’d recommend using double quotes " and not single quotes ’ for Parameter Name and Value. Those mean different things.
I think you need to specific and OUT for your python unless you just aren’t showing that.

Hello @SeanP,

I changed to double quotes and still get the same error as shows in the image below.


I have specified an OUT but did not show it in the first code I sent.

import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
import clr
clr.AddReference('RevitAPI')
import Autodesk
from Autodesk.Revit.DB import *
clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
		
doc = DocumentManager.Instance.CurrentDBDocument

x = IN[0][0]

z = UnwrapElement(x)

TransactionManager.Instance.EnsureInTransaction(doc)
zz = z.LookupParameter("Switch ID").Set("1")
TransactionManager.Instance.TransactionTaskDone()

#This basically tells me if the set operation was successful
OUT = zz

I want to complement the information I said initially, the ‘Lighting Fixtures’ Category belongs to an Electrical System, and it contains several Families. Each of these Families have a Switch System. And in this System I want to assign a value to the parameter ‘Switch ID’ via the python script.

Can you do what u are asking in the UI?

Yes I can.

I would suggest you check either of the following:

  • Check the elements going in are just the elements you want to change, filter the elements down if needed.
  • Is the parameter a Type or a instance, if it is a instance make sure you only input instances, and similar for type.
  • Check on what type of storage that parameter can hold, as parameters can be Doubles, String, Elements or a Int. Therefore if it wants a Double you have to input a double not a string.

Can you share one of the families your trying to set?

Also, do you have any formulas that are driving or being driven in the Family?

Hello Brendan_Cassidy,

Regarding your points:

  • I filter by the first element of the category, where I get a list of parameters in that element, and afterwards with 'LookupParameter command I’m able to select the desired parameter.
  • The parameter is instance
  • When I change manually via UI it can hold either String or Double

Hello Sean,

Here are two families in my use case. The following we transfer link contains both.

We are not using any formulas.

Hi,
MEP Switch Systems creation are not available in Revit API, so you can’t set programmatically this parameter on LightingFixtures families

1 Like

Hello @c.poupin,

Ok, thank you for your time. :slight_smile: