Creating a material with category assigned

Creating a material with category assigned

GeomGym
Advocate Advocate
518 Views
1 Reply
Message 1 of 2

Creating a material with category assigned

GeomGym
Advocate
Advocate

Hi,

 

How do I assume a category to a generated material.  My code with the current result attached (v2013).

 

Thanks in advance,

 

Jon

 

Document doc = commandData.Application.ActiveUIDocument.Document;
			Application app = commandData.Application.Application;
			Transaction trn = new Transaction(doc, "ggTest");
			trn.Start();
			
			ElementId id = Autodesk.Revit.DB.Material.Create(doc, "STEEL"); 
			Material material = doc.GetElement(id) as Material;

			StructuralAsset strucAsset = new StructuralAsset("My Property Set", StructuralAssetClass.Metal);
			PropertySetElement pse = PropertySetElement.Create(doc, strucAsset);
			material.SetMaterialAspectByPropertySet(MaterialAspect.Structural, pse.Id);

			doc.Regenerate();
			trn.Commit();
			return Result.Succeeded;

 130510 material category.png

0 Likes
Accepted solutions (1)
519 Views
1 Reply
Reply (1)
Message 2 of 2

Joe.Ye
Alumni
Alumni
Accepted solution
HI Jon,

the Category property can be changed Material.MaterialClass property.


Joe Ye
Contractor
Developer Technical Services
Autodesk Developer Network