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.
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
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.
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);
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
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 ?
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