I am working on a project where I need to create an element (example a wall) and add shared parameters to it in Forge API.
I created the wall using Design automation API for Revit, but since there is no UI in Design Automation API, I was not able to create parameters
Is there a method like the below code, which we were able to write within transaction in Revit API.
if (element.LookupParameter(param).IsReadOnly == false)
{
if (!type.Name.Equals("Double"))
{
if (!string.IsNullOrEmpty(value.ToString()))
element.LookupParameter(param).Set(value.ToString());
}
else
{
if (!double.IsNaN((double)value))
element.LookupParameter(param).Set((double)value);
}
}
Is it possible to create instance and type parameters for a particular element in Design Automation API or do I have to use some other Forge API?
It would be great if someone could guide me with this.
Thank you
I happened to have produced a demo to work with shared parameters by Design Automation. The source project is available at https://github.com/xiaodongliang/Revit-room-space-with-Forge-viewer
It is based on the skeleton of our learn forge tutorial. The related codes to add share parameter are these lines: https://github.com/xiaodongliang/Revit-room-space-with-Forge-viewer/blob/master/updateRVTParam/Commands.cs#L259-L269
//add shared parameter definition
AddSetOfSharedParameters(rvtDoc);
//......
//......
//add shared parameter to the specific shape
using (Transaction tx = new Transaction(rvtDoc))
{
tx.Start("Change P");
Element readyDS = rvtDoc.GetElement(roomId);
Parameter p = readyDS.LookupParameter("RoomNumber");
if (p != null)
{
p.Set(room.Number.ToString());
}
tx.Commit();
}
Hope it helps.