Revit API Forum
Welcome to Autodesk’s Revit API Forums. Share your knowledge, ask questions, and explore popular Revit API topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Parameter

5 REPLIES 5
SOLVED
Reply
Message 1 of 6
Anonymous
708 Views, 5 Replies

Parameter

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?

5 REPLIES 5
Message 2 of 6
Mustafa.Salaheldin
in reply to: Anonymous

Please try the Element.GetParameters Method instead.


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

Mustafa Salaheldin


EESignature




Digital Integration Manager, DuPod

Facebook | Twitter | LinkedIn

Message 3 of 6
Anonymous
in reply to: Mustafa.Salaheldin

HI,

 

tahnks

 

can you make me a sample?

Message 4 of 6
Anonymous
in reply to: Anonymous

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

?

Message 5 of 6
Anonymous
in reply to: Anonymous

HI,

 

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

 

Message 6 of 6
Mustafa.Salaheldin
in reply to: Anonymous

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

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report