Set parameter value from another instance

Set parameter value from another instance

mr.engineer.aec
Advocate Advocate
623 Views
5 Replies
Message 1 of 6

Set parameter value from another instance

mr.engineer.aec
Advocate
Advocate

 Hi guys,

 I have a problem like under pic.

 I want to set shared parameter value from element 1 to shared parameter element 2.

 But when i debug, element 2 can't receive shared parameter value from element 1. 
 If i change value in "paradetail1.Set(valueA.ToString());" into any number. They run very good.

 I don't know where code wrong.

 Please help me if you can.

 Thank in advance

 My code:

set param.PNG

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

jeremytammik
Autodesk
Autodesk

You need to check the target parameter data type and use the appropriate overload of the Set method:

 

  • Set(Double) -- Sets the parameter to a new real number value.
  • Set(Int32) -- Sets the parameter to a new integer value.
  • Set(String) -- Sets the parameter to a new string of text.
  • Set(ElementId) -- Sets the parameter to a new element id.

 

https://www.revitapidocs.com/2020/c0343d88-ea6f-f718-2828-7970c15e4a9e.htm

 



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

Message 3 of 6

BobbyC.Jones
Advocate
Advocate

Programming with empty catch blocks is like driving with a blindfold on.  Eventually something bad is going to happen, but you'll have no idea what or when.  Remove that blindfold and run your code again.  Then you'll see the error that @jeremytammik is hinting at.

--
Bobby C. Jones
Message 4 of 6

mr.engineer.aec
Advocate
Advocate

 Hi @jeremytammik 
Hi @BobbyC.Jones 

 

Type of target parameter (DB)  is Length

I think Length is double so i change my code like under pic.

But when i debug, Warning is visible.
( Parameter C is segment length of rebar)

 

set param.PNG

0 Likes
Message 5 of 6

jeremytammik
Autodesk
Autodesk

It does not matter what parameter C is.

 

Your problem is parameter DB.

 

I suggest you work through the getting started material to gather a little bit more experience first, unless you have already done that.

 



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

Message 6 of 6

mr.engineer.aec
Advocate
Advocate

 Yes sir. 
Thank you very much.

0 Likes