Announcement

Collapse
No announcement yet.

Revit API - Renaming a material asset name or information with the assigned jpg name

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Revit API - Renaming a material asset name or information with the assigned jpg name

    Team,

    I'm working with our internal developer on some custom Revit applications and we are in need of some help. We are currently developing a color scheme app and when our designers insert the color scheme into a project some materials absorb other materials appearances because they share the same asset name. We are trying to write a section of code that allows us to rename each materials assest name with the assigned jpg name (for each material in the color scheme) before it's pushed into the project material browser. That way we don't need to physically go in and rename all the materials in all of the color schemes.

    Example:
    CURRENT SITUATION
    - Material 1 Name = Flooring - Tan
    - Material Asset Name = Default
    - Material JPG Assigned = Interface-Monochrome -Castor.JPG

    - Material 2 Name =Flooring Grey
    - Material Asset Name = Default
    - Material JPG Assigned = Interface-Monochrome -Flannel 101838.jpg

    After code is implemented then it will look like this...

    IDEAL SITUATION:
    - Material 1 Name = Flooring - Tan
    - Material Asset Name = Interface-Monochrome -Castor.JPG
    - Material JPG Assigned = Interface-Monochrome -Castor.JPG

    - Material 2 Name =Flooring Brown
    - Material Asset Name = Interface-Monochrome -Flannel 101838.jpg
    - Material JPG Assigned = Interface-Monochrome -Flannel 101838.jpg

    Does that make sense?

    #2
    Last time I looked the Materials API was still fairly restricted. I'm fairly certain what you want it is possible, through either Dynamo or the API but I don't know much past that :hide:
    Revit for newbies - A starting point for RFO


    chad
    BEER: Better, Efficient, Elegant, Repeatable.

    Comment


      #3
      @sgrant

      How are you getting access to the assigned jpeg name?
      The assigned jpeg would be stored in the appearance asset, and if you have an appearance asset assigned to multiple materials, those materials will have the same texture.

      Would turning off the "color by appearance" be a viable solution for you? This way the appearance asset will be ignored in non-render views.

      To gain access to the appearance asset, one way is to start with the material itself. Once you have the Appearance asset element, you can choose to duplicate and rename the asset. See C# code below for reference.


      Code:
                      //3 types of assets
                      //have access to asset element ID from material - then get element
                      //matElem is the Material Element
                      ElementId idAppearance = matElem.AppearanceAssetId;
                      ElementId idPhysical = matElem.StructuralAssetId;
                      ElementId idThermal = matElem.ThermalAssetId;
                      
                      //get material asset element
                      appAssetEle = doc.GetElement(idAppearance);
                      physAssetEle = doc.GetElement(idPhysical);
                      therAssetEle = doc.GetElement(idThermal);
      
      
                      //get material asset name if asset exists
                      if (appAssetEle != null) { appAssetName = appAssetEle.Name; }    //AppearaceAsset Name
                      if (physAssetEle != null) { physAssetName = physAssetEle.Name; } //StructuralAsset Name
                      if (therAssetEle != null) { therAssetName = therAssetEle.Name; } //ThermalAsset Name
      www.polyninestudio.com | @Twitter |[email protected]

      FIND AND REPLACE MATERIALS FOR REVIT PLUGIN: www.polyninestudio.com/findreplacematerialsrevit.html

      Comment

      Related Topics

      Collapse

      Working...
      X