Parameter

Parameter

Anonymous
Not applicable
840 Views
5 Replies
Message 1 of 6

Parameter

Anonymous
Not applicable

Hi, 

I have a problem to migrate an old dll to 2016 / 2017.

The problem is on this line:

 

Dim Sh_Data1 As Parameter = csheet.Parameter("Data")

 

Data is a shared parameter, on Revit 2015 work correctly, on Revit 2017 I receive this error:

 

Not valid CAST from "Data" string to Integer type

 

How I can solve it?

0 Likes
Accepted solutions (1)
841 Views
5 Replies
Replies (5)
Message 2 of 6

Mustafa.Salaheldin
Collaborator
Collaborator

Please try the Element.GetParameters Method instead.


¯\_(ツ)_/¯
Let it work like a charm.

Mustafa Salaheldin


EESignature




Digital Integration Manager, DuPod

Facebook | Twitter | LinkedIn

0 Likes
Message 3 of 6

Anonymous
Not applicable

HI,

 

tahnks

 

can you make me a sample?

0 Likes
Message 4 of 6

Anonymous
Not applicable
Dim Sh_Data1 As IList(Of Parameter) = csheet.GetParameters("Data")

?

0 Likes
Message 5 of 6

Anonymous
Not applicable

HI,

 

Thanks, now work correctly, but When I use it on the current sheet, Sh_Data1 contains 2 items with the some value, why?

 

0 Likes
Message 6 of 6

Mustafa.Salaheldin
Collaborator
Collaborator
Accepted solution

This is so natural. Please read the following quote from the API guide:

 

"Multiple matches of parameters with the same name can occur because shared parameters or project parameters can be bound to an element category even if there is a built-in parameter with the same name already.

If this method is used to find built-in parameters the code will not be portable to other languages of Revit (because built-in parameter names are translated, and this method matches the translation).

For the reasons above this method should be used sparingly and when portability across multiple languages is not a requirement.

Safer approaches include:

  • get_Parameter(Guid) to get a shared parameter by stored guid.
  • get_Parameter(BuiltInParameter) to find a built-in parameter in a language-independent way."

¯\_(ツ)_/¯
Let it work like a charm.

Mustafa Salaheldin


EESignature




Digital Integration Manager, DuPod

Facebook | Twitter | LinkedIn

0 Likes