Edit in-place family material via Revit api

Edit in-place family material via Revit api

Anonymous
Not applicable
1,497 Views
3 Replies
Message 1 of 4

Edit in-place family material via Revit api

Anonymous
Not applicable

Greetings Revit Community

I would like to ask for help with my plug-in function, I will head straight into the issue

 

The goal:

1. get in-place Family instance

2. get the generic forms and iterate them to change the material of them, I only want simple change, different material with different color

 

The issue:

I could not edit the in-place family because of the API limit on editing this instance

I searched all around to find a way to change the material of the in-place family but no hope
from my search I found on this post 
https://forums.autodesk.com/t5/revit-api-forum/family-in-place-api/m-p/7082088/highlight/true#M22819
this is from 2019, while I understand it's not a priority for the development team, I would like to ask to give it more 

priority for this case, as many developers are facing the same issue from my search but different goals

 

if anyone knows a way to change in-place family instance generic forms material, I will appreciate it

thanks in advance for any help

1,498 Views
3 Replies
Replies (3)
Message 2 of 4

jeremy_tammik
Alumni
Alumni

To raise the priority of a new feature request, please ensure that it is listed in the Revit Idea Station.

 

Whenever you require new or enhanced Revit or Revit API functionality, the Revit Idea Station is the place to go.

 

Please search there for a corresponding wish list entry for the suggested functionality and add your comments to it, or create a new one, if none already exists:

 

https://forums.autodesk.com/t5/revit-ideas/idb-p/302

 

Tag it as an API wish:

 

https://forums.autodesk.com/t5/revit-ideas/idb-p/302/tab/most-recent/label-name/api

 

Ensuring that a wish gets as many votes as possible helps underline its importance to you and the rest of the developer community.

 

The Revit Idea Station is currently one of the main driving input forces for Revit API enhancements.

 

The Revit development team look there. Your comment here in the discussion forum might be overlooked.

 

Thank you!

 

That said, you may be able to programmatically modify the material of an individual face of some element geometry regardless of what kind of element it lives on. Some suggestions on controlling element colour and material are listed here:

 

https://thebuildingcoder.typepad.com/blog/about-the-author.html#5.24

 

A recent discussion here in the forum explains how to Use a different material on each face of a tessellated shape:

 

https://forums.autodesk.com/t5/revit-api-forum/using-different-material-on-each-face-of-a-tessellate...

 

Maybe that will provide a hint as well.

 

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
0 Likes
Message 3 of 4

Anonymous
Not applicable

Hey  

 

 

 

 //creating new material
                ElementId mt = Material.Create(doc, RandomString(10));
                Material material = doc.GetElement(mt) as Material;
                Color myColor = new Color(255, 192, 203);
                material.Color = myColor;

                FamilyInstance FI = elem as FamilyInstance;
                Family f = FI.Symbol.Family;
                ISet<ElementId> familySet = f.GetFamilySymbolIds();
               
                
                foreach (ElementId id in familySet)
                {
                    
                    Element el = doc.GetElement(id);

                    foreach(ElementId ids in el.GetMaterialIds(true))
                    {
                      //can't figure out next step here
                    }
                    
                }

 

 

 

 

0 Likes
Message 4 of 4

EATREVITPOOPCAD
Collaborator
Collaborator

I think I came across a post that has a function for what you are looking to do

 

https://forums.autodesk.com/t5/revit-api-forum/set-material-parameter-value/td-p/8227041

 

 public void SetMaterial(FamilySymbol fs)
{
               IList<Parameter> pars = fs.GetOrderedParameters();
                foreach (Parameter p in pars)
                {
                    if (p.Definition.Name == "Material")
                    {      
                        Material m = GetMaterial(doc, "Glass");
                        if (m!= null)
                        {
                            fs.Category.Material = m;
                            p.Set(m.Id);
                        }                   
                    }
                }
}

 

 

The definition of insanity is doing the same thing over and over again and expecting different results