I can't find sub class parameter in ThermalAsset that i created

I can't find sub class parameter in ThermalAsset that i created

Anonymous
Not applicable
689 Views
8 Replies
Message 1 of 9

I can't find sub class parameter in ThermalAsset that i created

Anonymous
Not applicable

Hello , 

 

I try to create a new ThermalAsset and i try to bindit to my matreial but when i want to set value to subclass parameters he can't find this property on this asset this my code can you help me please ?

 ThermalAsset thermal = new ThermalAsset(matName.TrimEnd(), ThermalMaterialType.Solid)
                                            {
                                                TransmitsLight = false,
                                                Permeability = permeabilite,
                                                Porosity = materiallocale.thermal_Porosite,
                                                Reflectivity = materiallocale.thermal_Reflectivite,
                                                ElectricalResistivity = electrique,
                                                SpecificHeat = heat,
                                                Density = density,
                                                ThermalConductivity = condivite,
                                                Emissivity = materiallocale.thermal_emissivite,
                                            };

                                            pst.get_Parameter(BuiltInParameter.PHY_MATERIAL_PARAM_SUBCLASS).Set(materiallocale.thermal_subclass);
                                            pst.get_Parameter(BuiltInParameter.PROPERTY_SET_KEYWORDS).Set(materiallocale.keynote);
                                            pst.get_Parameter(BuiltInParameter.MATERIAL_ASSET_PARAM_SOURCE).Set(materiallocale.thermal_source);

 

0 Likes
690 Views
8 Replies
Replies (8)
Message 2 of 9

MarryTookMyCoffe
Collaborator
Collaborator

If you what to set up thermalAsset to material, yuo have to use:
Snippet

material.SetMaterialAspectByPropertySet(MaterialAspect.Thermal, your asset ID )

 for more info you can look in this post:
https://forums.autodesk.com/t5/revit-api-forum/create-new-material-and-add-new-physical-and-thermal-...

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

Anonymous
Not applicable

Actually my problem is i can't map sub class parameter with my new assetand it's not how to bind it to my material  

 

this instrcution won't because it can't find the subclass property on my new asset

 myMaterial.get_Parameter(BuiltInParameter.PHY_MATERIAL_PARAM_SUBCLASS).Set(materiallocale.thermal_subclass);


@MarryTookMyCoffewrote:

If you what to set up thermalAsset to material, yuo have to use:
Snippet

material.SetMaterialAspectByPropertySet(MaterialAspect.Thermal, your asset ID )

 for more info you can look in this post:
https://forums.autodesk.com/t5/revit-api-forum/create-new-material-and-add-new-physical-and-thermal-...



0 Likes
Message 4 of 9

MarryTookMyCoffe
Collaborator
Collaborator

you need to give a more info, there is no way to test anything on your code.

do you use a RevitLookup?

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

Anonymous
Not applicable

THANK YOU for your help more details this is my test code i duplacte material i create new thermal asset during giving a value for the property sub class it will crash 

  string matName = "Test Material";
  Material myMaterial = null;
                                Material materialCSI = new FilteredElementCollector(doc).OfClass(typeof(Material)).Cast<Material>().Where(es => es.Name == matName.TrimEnd()).FirstOrDefault<Material>();
                              
                                if (materialCSI == null)
                                {
                                          
                                            materialCSI = new FilteredElementCollector(doc).OfClass(typeof(Material)).Cast<Material>().FirstOrDefault<Material>();

                                            // Duplicate material 
                                            myMaterial = materialCSI.Duplicate(matName.TrimEnd());
											
                                        using (Transaction tx = new Transaction(doc))
                                        {
                                            tx.Start("Add Materials");
                                            

                                            ThermalAsset thermal = new ThermalAsset(matName.TrimEnd(), ThermalMaterialType.Solid)
                                            {
                                                TransmitsLight = false,
                                                Permeability = 1,
                                                Porosity = 1,
                                                Reflectivity = 1,
                                                ElectricalResistivity = 1,
                                                SpecificHeat = 1,
                                                Density = 1,
                                                ThermalConductivity = 1,
                                                Emissivity = 1,
                                            };

                                            PropertySetElement pst = PropertySetElement.Create(doc, thermal);
                                            myMaterial.get_Parameter(BuiltInParameter.PHY_MATERIAL_PARAM_SUBCLASS).Set("sub class thermal");
                                            pst.get_Parameter(BuiltInParameter.PROPERTY_SET_KEYWORDS).Set("key note ");
                                         

     
                                            myMaterial.SetMaterialAspectByPropertySet(MaterialAspect.Thermal, pst.Id);
                                            //Assign the property set to the material.
                                            PropertySetElement pse = PropertySetElement.Create(doc, strucAsset);
                                            pse.get_Parameter(BuiltInParameter.PHY_MATERIAL_PARAM_SUBCLASS).Set("sub class physic");
                                            myMaterial.SetMaterialAspectByPropertySet(MaterialAspect.Structural, pse.Id);

                                            tx.Commit();

                                        }
									
								}
0 Likes
Message 6 of 9

MarryTookMyCoffe
Collaborator
Collaborator

change :

myMaterial.get_Parameter(BuiltInParameter.PHY_MATERIAL_PARAM_SUBCLASS).Set("sub class thermal");

to:

 

pst.get_Parameter(BuiltInParameter.PHY_MATERIAL_PARAM_SUBCLASS).Set("sub class thermal");

 

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

Anonymous
Not applicable

I tried that it didn't work 😞

0 Likes
Message 8 of 9

MarryTookMyCoffe
Collaborator
Collaborator

i did simple macro in revit and all propertysetelement I chose change. try first changing parameter is propertySetElement and then add it to a material

 

		public void material()
		{
						Document doc = this.Application.ActiveUIDocument.Document;
			FilteredElementCollector fec = new FilteredElementCollector(doc).OfClass(typeof(PropertySetElement));
			List<PropertySetElement> list = fec.Cast<PropertySetElement>().Where(es => es.Name=="Air").ToList();
			
			Transaction trans = new Transaction(doc);
			trans.Start("testr");
			foreach (PropertySetElement element in list) {
				element.get_Parameter(BuiltInParameter.PHY_MATERIAL_PARAM_SUBCLASS).Set("zmieniłem");
			}
			trans.Commit();
		}
-------------------------------------------------------------
--------------------------------|\/\/|------------------------
do not worry it only gonna take Autodesk 5 years to fix bug
0 Likes
Message 9 of 9

Anonymous
Not applicable

Hello! By any chance did you got to solve this issue? I am facing the exact same problem.

 

Best Regards,

JMGP

0 Likes