Create new material and add new Physical and Thermal assets with values.

Create new material and add new Physical and Thermal assets with values.

Anonymous
Not applicable
5,655 Views
8 Replies
Message 1 of 9

Create new material and add new Physical and Thermal assets with values.

Anonymous
Not applicable

Hi, this is my first post here.

I am trying to create new material and then add (like with the + button) new Thermal and Physical assets with filled data.

 

1. I create the matherial

 

 

transaction.Start("CreateMaterial");
// Create new material
var newMaterial = Material.Create(doc, "JustCreated");
                               
// Add attach to class
transaction.Commit();

 

 

2. Create Thermal Asset

 

var thermal = new ThermalAsset("Thermal1", ThermalMaterialType.Solid)
                {
                    TransmitsLight = false,
                    Permeability = 200.00,
                    Porosity = 300.00,
                    Reflectivity = 100.00,
                    ElectricalResistivity = 11.00
                };

                PropertySetElement.Create(doc, thermal);

2.1. Wondering how I can get the list of predefined assets just to Duplicate one for the material.

 

3. Cannot create a Physical Asset the same way

 

4. Cannot assign this Asset to the Material

 

Can someone share some experience, thank you?

 

 

0 Likes
Accepted solutions (1)
5,656 Views
8 Replies
Replies (8)
Message 2 of 9

jeremytammik
Autodesk
Autodesk

No experience, I'm sorry to say.

 

However, please note that the API access to materials was very limited in the past and was finally completely opened up in Revit 2018.1:

 

http://thebuildingcoder.typepad.com/blog/2017/08/revit-20181-and-the-visual-materials-api.html

 

If you can base your add-in on that version, everything should be easy, and you can use the new SDK sample to see how it is done.

 

Cheers,

 

Jeremy



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

0 Likes
Message 3 of 9

MarryTookMyCoffe
Collaborator
Collaborator
Accepted solution

try to look on this posts:
https://forums.autodesk.com/t5/revit-api-forum/how-can-i-set-a-density-to-a-material-using-c-code/m-...
I was showing how create material add asset and detect if there is one.

 

-------------------------------------------------------------
--------------------------------|\/\/|------------------------
do not worry it only gonna take Autodesk 5 years to fix bug
0 Likes
Message 4 of 9

jeremytammik
Autodesk
Autodesk

Many thanks to MarryTookMyCoffe for both this answer and the previous one referred to.

 

Can you please confirm that this approach solves your issue?

 

Once I have it confirmed, I would like to edit both as a post in The Building Coder.

 

It would be great if you could include a snippet of your own code showing exactly how you make use of this.

 

Thank you!

 

Cheers,

 

Jeremy



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

0 Likes
Message 5 of 9

Anonymous
Not applicable

First of all thank you all for your help, and sorry for my late answer (was on a vacation). The solution provided works great for me. This is how my example code looks like:

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

                // Create new material
                var newMaterial = Material.Create(doc, "JustCreated1");
                var material = doc.GetElement(newMaterial) as Material;

                var thAsset = new ThermalAsset("Thermal1", ThermalMaterialType.Solid);
                thAsset.Name = "yourname";
                thAsset.Behavior = StructuralBehavior.Isotropic;
                thAsset.ThermalConductivity = 0.00;
                thAsset.SpecificHeatOfVaporization = 0.0;
                thAsset.Porosity = 0.0;
                thAsset.Density = 0.0;
                thAsset.Emissivity = 0.0;
                thAsset.Reflectivity = 0.0;
                thAsset.Permeability = 0.0;
                thAsset.ElectricalResistivity = 0.0;
                thAsset.Compressibility = 0.0;

                var pse = PropertySetElement.Create(doc, thAsset);

                material.SetMaterialAspectByPropertySet(MaterialAspect.Thermal, pse.Id);

                var strAsset = new StructuralAsset("Thermal1", StructuralAssetClass.Generic);
                
                strAsset.Name = "yourname";
                strAsset.Behavior = StructuralBehavior.Isotropic;
                strAsset.YoungModulus = new XYZ(0, 0, 0);
                strAsset.Density = 0.0;

                var pses = PropertySetElement.Create(doc, strAsset);

                material.SetMaterialAspectByPropertySet(MaterialAspect.Structural, pses.Id);

                // Add attach to class
                transaction.Commit();
            }
0 Likes
Message 6 of 9

Anonymous
Not applicable

is it possible to add a new material in an already existing Revit Material Library?

0 Likes
Message 7 of 9

jeremytammik
Autodesk
Autodesk
0 Likes
Message 8 of 9

Anonymous
Not applicable

Hi @jeremytammik! I've read your post, the answer seems to be negative, it's not possible to add new material in an already existing Revit Material Library. If I'm still right, the post was written in 2013, in the last two versions of API I heard some improvements from that side. Could you help me please?

0 Likes
Message 9 of 9

Anonymous
Not applicable

@jeremytammik do you have some news about what @Anonymous wrote in his last post?

0 Likes