Revit API Forum
Welcome to Autodesk’s Revit API Forums. Share your knowledge, ask questions, and explore popular Revit API topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Assign Material to generic model framing instance

3 REPLIES 3
SOLVED
Reply
Message 1 of 4
GeomGym
2549 Views, 3 Replies

Assign Material to generic model framing instance

Hi All,

 

Can someone please advise how to assign the structural material to an instance created from a generic model family, type set to Framing?  I've tried a few like property StructuralMaterialId or BuiltInParameter.MATERIAL_ID_PARAM

with no luck.  I can manually set it.

I can post a revit file if needed.

 

Thanks in advance,

 

Jon

 

131005 assign material.png

3 REPLIES 3
Message 2 of 4
Anonymous
in reply to: GeomGym

I too am struggling with this issue.  I've got a framing family composed of multiple nested generics that all have associated material parameters.  I need to be able to assign/change the material through the API.  I can do it manually though the UI, and it works beautifully.  It's just a giant pain in the --- to keep having to do it this way.

Message 3 of 4
saikat
in reply to: GeomGym

Here is something I tried quickly and it seemed to work fine. For testing purposes, I have hard coded the 'Carbon Steel' material ID in the code and used that ElementId in the material assignment process:

 

UIApplication uiApp = commandData.Application;

 

UIDocumentuiDoc = uiApp.ActiveUIDocument;

 

foreach (Element ele in

uiApp.ActiveUIDocument.Selection.Elements)

{

FamilyInstance box = ele asFamilyInstance;

 

if (null!= box)

{

using (Transaction trans = newTransaction(uiDoc.Document, "SetMaterial"))

{

trans.Start();

box.get_Parameter(

BuiltInParameter.STRUCTURAL_MATERIAL_PARAM).Set(newElementId(164753));

trans.Commit();

}

}

}

 

and eventually was able to see this:

 

material.JPG

 



Saikat Bhattacharya
Senior Manager - Technology Consulting
Message 4 of 4
GeomGym
in reply to: saikat

Thanks for the reply, that indeed does seem to be the solution.  

 

Cheers,

 

Jon

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Rail Community