0

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

Roberto Pegoraro
  • 1,313
  • 2
  • 16
  • 31
JPais
  • 115
  • 2
  • 14

2 Answers2

0

Yes, you can use the Revit API to create shared parameters in the Forge Design Automation context. Fore easier testing, I suggest you implement and test the required functionality in normal desktop Revit before moving to the Design Automation context. The Building Coder provides more hints in the corresponding topic group on DA4R – Design Automation for Revit.

Jeremy Tammik
  • 7,333
  • 2
  • 12
  • 17
0

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.

Xiaodong Liang
  • 2,051
  • 2
  • 9
  • 14