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: 

Get Parameter from DB

7 REPLIES 7
Reply
Message 1 of 8
Anonymous
1673 Views, 7 Replies

Get Parameter from DB

Would it be possible to get a Parameter object from the DB without having to extract it from a Element?

 

I want to use a Parameter filter. But for the ParameterValueProvider we need to give it a Element ID of the Parameter. But i dont have the Parameter as a object, i have it's name and GUID (shared parameter). So i would like to load the Parameter and pass it's ID to the ParameterValueProvider.

7 REPLIES 7
Message 2 of 8
jeremy_tammik
in reply to: Anonymous

Dear Michal,

 

I believe you need an element with the parameter attached to it in order to determine the parameter id.

 

Sorry about that.

 

Cheers,

 

Jeremy

Jeremy Tammik, Developer Advocacy and Support, The Building Coder, Autodesk Developer Network, ADN Open
Message 3 of 8
m.vallee
in reply to: jeremy_tammik

Hi,

 

I am facing the exact same issue. I don't have any element in my coordination "main" model project so I can't get the Parameter objects and their IDs to pass them to filters. The most frustrating is that I have their name, GUID, ..., because I have just created them.

 

May I have to create a temporary object, use it to get the parameter IDs, then delete it ? It seems like buying a Ferrari to cross the street.

 

 

Message 4 of 8
FAIR59
in reply to: m.vallee

I haven't tried it myself, but I think you can pass the Id of a SharedParameterElement to the ParameterValueProvider.

 

            SharedParameterElement paramElem =   SharedParameterElement.Lookup(doc, yourGUID);
Message 5 of 8
IbrahimNaeem
in reply to: Anonymous

Hi,

try out the following:

sqlc = new SqlCeCommand("Select GUID from table", cs);
da = new SqlCeDataAdapter(sqlc);
DataTable dt = new DataTable();
da.Fill(dt);
Guid g = System.Guid.Empty; 
Parameter par = null;
Element rom = roomset.First<Element>();
Foreach(DataRow dr in dt.Rows)
  {
   String backup = dr["GUID"].ToString();
    g = mew Guid(backup);
   par = rom.get_Parameter(g);
  Definition def = par.Definition;
  } 

This is a snapshot of working tool I did before. Hope it helps!

 

Thanks, Ibrahim Naeem 

Message 6 of 8
m.vallee
in reply to: FAIR59

That worked perfectly, many thanks.

 

Now I am looking for the exact same thing but for project (ie non-shared) parameters.

How to obtain their Ids when no corresponding item has been placed in the project ?

Message 8 of 8
m.vallee
in reply to: jeremytammik

Thanks Jeremy.

 

To sum up, the key to success is to use ParameterElement (for project parameters) and SharedParameterElement (obviously for shared parameters) classes inside filtered element collectors.

 

Maxime

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

Post to forums  

Autodesk DevCon in Munich May 28-29th


Rail Community