Error When Setting Formula on Parameter

Error When Setting Formula on Parameter

Anonymous
Not applicable
1,800 Views
4 Replies
Message 1 of 5

Error When Setting Formula on Parameter

Anonymous
Not applicable

Hello Everyone!

 

I am having a somewhat odd issue that I can not seem to tackle. I am trying to set some placeholder values in a family I have opened however I keep receiving an error when doing so. I am not sure as to why I am unable to set the formula in the param. I have attached the relevant code where I am trying to set the formula as well as the error message I am receiving. Any Help would be greatly appreciated!

 

Thanks!

0 Likes
Accepted solutions (1)
1,801 Views
4 Replies
Replies (4)
Message 2 of 5

RPTHOMAS108
Mentor
Mentor

How do you know all the parameters you are iterating through have a double storage type and are without units?

i.e. you use 2+2 for double but 2=2 for Boolean (yes/no). Probably you get some built-in ones also that can't be assigned formula.

Suggest you check FamilyParameter.CanAssignFormula, FamilyParameter.IsReadOnly, FamilyParameter.StorageType (amongst other checks). 

 

Not sure what your disk error message relates to, is probably specific to your setup.  Also bare in mind that Families have intricate Formula relationships created by Family author's so would not generally touch formulas in such a indiscriminate way.

 

 

 

0 Likes
Message 3 of 5

Anonymous
Not applicable

Thanks for the reply! That makes sense I was wondering if there was something along those lines. I will look into those and begin writing some checks to see what I should be storing in there.

 

Is there anyone to add a placeholder value? Something like "insert value" or maybe just clear the value out? IE make the formula value "null" or ""

 

Thanks!

 

P.S Yes the disk check error is an internal error. I am reading these files a file dialog and opening them in revit (making my own open command) and that error gets thrown if any error happens down the road. Bit lazy but its still in development!

0 Likes
Message 4 of 5

RPTHOMAS108
Mentor
Mentor
Accepted solution

According to RevitAPI.chm to clear the formula you call FamilyManager.SetFormula(FParameter, null).

 

In terms of PlaceHolder values I think you could try creating a Type and then assigning the parameter a value. I've not tried this but that is what you would do in the UI (apart from not having to create a current type). Unfortunately that is just the way the FamilyManger works, in that CurrentType must be set to something to assign values (even instance parameter values).

0 Likes
Message 5 of 5

Anonymous
Not applicable

Awesome! Thank you. Exactly what I was looking for.

0 Likes