System.NullReferenceException: 'Object reference not set to an instance of an object.'

System.NullReferenceException: 'Object reference not set to an instance of an object.'

VanQuyet.Doan
Enthusiast Enthusiast
738 Views
5 Replies
Message 1 of 6

System.NullReferenceException: 'Object reference not set to an instance of an object.'

VanQuyet.Doan
Enthusiast
Enthusiast

I get an error when I duplicate family type and set parameter.
Has anyone encountered this error and is there any solution?


instance.PNG

0 Likes
739 Views
5 Replies
Replies (5)
Message 2 of 6

naveen.kumar.t
Autodesk Support
Autodesk Support

Hi @VanQuyet.Doan ,

 

It looks like there is no parameter called "t_w" in the newly created family symbol.

Make sure the parameter name is correct.

Make sure you are passing the correct parameter name in the LookUpParameter method.


Naveen Kumar T
Developer Technical Services
Autodesk Developer Network

0 Likes
Message 3 of 6

VanQuyet.Doan
Enthusiast
Enthusiast

I have checked the names again, even though the names are correct, the same error occurs.
I think maybe it's the font error.

instance2.PNG

0 Likes
Message 4 of 6

naveen.kumar.t
Autodesk Support
Autodesk Support

Hi @VanQuyet.Doan ,

 

I have no clue why Revit is throwing an error.

1)Can you set the parameter value to this particular parameter via UI?

2)If Yes, then Could you Please try using FamilySymbol.Parameters instead of LookUpParameter?

Now Use foreach loop to access each parameter. Make sure the "H_s" parameter is present.

3)If the "H_s" parameter is present, Make sure the "H_s" parameter is not a read-only parameter and then try to set the value via API.

Sometimes the parameter can be read-only and user-modifiable. (i.e)parameter value can be changed via UI but not Via API.

For Testing purposes, Could you please try to set the value to the parameter directly instead of using MmToFeet(i.e)if the storage type is double, then pass the value as 30.00, etc.,

If nothing helps, could you please share the non-confidential file, non-confidential sample code you used, and step-by-step approach to reproduce the issue?

Please Note: Do not send us any information that you consider to be a trade secret to your company.


Naveen Kumar T
Developer Technical Services
Autodesk Developer Network

0 Likes
Message 5 of 6

Kennan.Chen
Advocate
Advocate

Is the H_s parameter an instance parameter?

0 Likes
Message 6 of 6

naveen.kumar.t
Autodesk Support
Autodesk Support

Hi @VanQuyet.Doan ,

 

I would suggest you download the RevitLookUp tool and explore the parameters.

https://github.com/jeremytammik/RevitLookup 


Naveen Kumar T
Developer Technical Services
Autodesk Developer Network

0 Likes