Read Only Parameter Exception

Read Only Parameter Exception

StruSoft_Iwona
Contributor Contributor
10,056 Views
8 Replies
Message 1 of 9

Read Only Parameter Exception

StruSoft_Iwona
Contributor
Contributor

I made a code what turns on (enables) analytical models of walls, floors, beams and columns. Its worked very well on my test files. But i have got some older files from my collegue and i always get InvalidOperationException with the message "The parameter is read-only." on those files. What can be the difference? Why is it happening?

Accepted solutions (1)
10,057 Views
8 Replies
Replies (8)
Message 2 of 9

Revitalizer
Advisor
Advisor
Accepted solution

Hi,

 

a parameter becomes read-only if it is driven by another one.

For example, the user can define a key/value table in which a user parameter drives the "Comments" parameter.

In this case, you cannot set the comment.

 

In Revit 2017, there are also GlobalParameters which can drive other parameters.

 

 

Revitalizer




Rudolf Honke
Software Developer
Mensch und Maschine





Message 3 of 9

Anonymous
Not applicable

Revitalizer,

 

Can you further explain this? I'm having the same issue only with Isolated Foundation Elements. I'm trying to collect them and change their workset, but "The parameter is read only" keeps happening when I run my macro. I do not understand why. I posted on the forum last week and haven't heard back. 

 

	var otherfndCollector = new FilteredElementCollector(doc).OfClass(typeof(FamilyInstance)).OfCategory(BuiltInCategory.OST_StructuralFoundation);
						IList<Element> otherfndcollector1 = otherfndCollector.ToElements();
						
						var otherfndtypeelements = from element in otherfndCollector
							where element.Name.Contains("Pile") || element.Name.Contains("Footing") || element.Name.Contains("PC") || element.Name.Contains("Caisson")
							select element;

Am I collecting them wrong? 

 

Thank you,

 

Damien

0 Likes
Message 4 of 9

Revitalizer
Advisor
Advisor

Hi,

 

the question is if you get the correct parameter.

If you get it by its plain, localized name, there may be several ones of that name, perhaps some of them hidden to the user.

It may be that one can be set while another one cannot.

 

I would recommend to investigate the desired elements' parameters by RevitLookup.

So you can find a parameter's related BuiltInParameter (if existing) and get the correct parameter language-independent.

 

Sometimes parameters are readonly because they are meant to be set in an indirect way, by setting a property or another, connected parameter.

 

 

Revitalizer




Rudolf Honke
Software Developer
Mensch und Maschine





Message 5 of 9

Anonymous
Not applicable

Revitalizer,

 

Ok so I figured out why I am getting the read only issue. Its because of my pile cap has nested piles inside. If I take the pile cap out, the macro works. The filter is trying to collect the nested piles, and they are the reason the read only is showing up.  How would I go about ignoring the read only or overwriting the read only.

 

Thank you,

 

Damien

Message 6 of 9

jlpgy
Advocate
Advocate

Hi:

I have read this chat and wanna ask one more question:

 

Is there a general method of querying whether a parameter is read-only or writable?

单身狗;代码狗;健身狗;jolinpiggy@hotmail.com
0 Likes
Message 7 of 9

naveen.kumar.t
Autodesk Support
Autodesk Support

Hi @jlpgy,

You can find whether the parameter is readonly or not using the below code

if(parameter.IsReadOnly)
                        {
                            //Do something if parameter is readonly
                        }
                        else
                        {
                            //Do something if parameter is writable
                        }

Naveen Kumar T
Developer Technical Services
Autodesk Developer Network

0 Likes
Message 8 of 9

jlpgy
Advocate
Advocate

@naveen.kumar.t

Hi:

Thank you very much.

I just realized that I asked a silly question, because several minutes after I post the question, I found this property by RevitLookup...

 

Thanks !Smiley LOL

单身狗;代码狗;健身狗;jolinpiggy@hotmail.com
0 Likes
Message 9 of 9

Anonymous
Not applicable

He is right. Nested families, stacked walls causes this exception.

 

0 Likes