0

I am trying to access via RevitAPI the data that is contained for particular asset. For instance I want to manipulate the Identity Data and get and eventually set some data for Manufacturer, Model, Cost and URL. How can I achieve the same for the other Assets?

enter image description here

I am reading the Materials:

public IEnumerable<Material> GetMaterials(Document doc)
    {
        collector = new FilteredElementCollector(doc);

        return collector.OfClass(typeof(Material)).OfType<Material>();
    }

And then the Parameters:

public IEnumerable<Parameter> GetMaterialParameters(Material material)
    {
        List<Parameter> parameters = new List<Parameter>();
        var localParameters = material.ParametersMap;

        foreach (Parameter localParameter in localParameters)
        {
            parameters.Add(localParameter);
        }

        return parameters;
    }

but still can't find where those properties are exposed.

Ivan Stefanov
  • 65
  • 1
  • 1
  • 7

2 Answers2

0

What you really need is the Visual Materials API that was introduced in Revit 2018.1, the newest update:

It is much harder and maybe impossible to achieve what you want in earlier versions.

Here are pointers to some more or less futile attempts:

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

Finally this is how I managed to edit the parameters.

private void AssignProductData_OnClick(object sender, RoutedEventArgs e)
    {
        var material = (MaterialItem)MaterialsCombo.SelectedItem;

        using (var transaction = new Transaction(doc))
        {
            transaction.Start("ChangeName");

            var parameterManufacturer = material.Material.get_Parameter(BuiltInParameter.ALL_MODEL_MANUFACTURER);
            parameterManufacturer.Set("Brand New Product");

            var parameterCost = material.Material.get_Parameter(BuiltInParameter.ALL_MODEL_COST);
            parameterCost.Set(1099.99);

            var parameterModel = material.Material.get_Parameter(BuiltInParameter.ALL_MODEL_MODEL);
            parameterModel.Set("R1223123KJNSDAS9089");

            var parameterUrl = material.Material.get_Parameter(BuiltInParameter.ALL_MODEL_URL);
            parameterUrl.Set("http://www.site.no/products/R1223123KJNSDAS9089");

            transaction.Commit();
        }
    }
Ivan Stefanov
  • 65
  • 1
  • 1
  • 7