Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Copyright(c) 2017 CODESIGN TOKYO
- // Permission is hereby granted, free of charge, to any person obtaining a
- // copy of this software and associated documentation files (the
- // "Software"), to deal in the Software without restriction, including
- // without limitation the rights to use, copy, modify, merge, publish,
- // distribute, sublicense, and/or sell copies of the Software, and to
- // permit persons to whom the Software is furnished to do so, subject to
- // the following conditions:
- // The above copyright notice and this permission notice shall be
- // included in all copies or substantial portions of the Software.
- // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
- // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
- // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using Autodesk.Revit.DB;
- using Autodesk.Revit.UI;
- using Autodesk.Revit.UI.Selection;
- using Autodesk.Revit.ApplicationServices;
- using Autodesk.Revit.Attributes;
- namespace MEP
- {
- [Autodesk.Revit.Attributes.Transaction(Autodesk.Revit.Attributes.TransactionMode.Manual)]
- [Autodesk.Revit.DB.Macros.AddInId("5990BE6F-0359-4BE5-8F0E-338C0C036520")]
- public partial class ThisDocument
- {
- private void Module_Startup(object sender, EventArgs e)
- {
- }
- private void Module_Shutdown(object sender, EventArgs e)
- {
- }
- #region Revit Macros generated code
- private void InternalStartup()
- {
- this.Startup += new System.EventHandler(Module_Startup);
- this.Shutdown += new System.EventHandler(Module_Shutdown);
- }
- #endregion
- public void ReadMaterialParam()
- {
- UIApplication uiapp = this.Application;
- UIDocument uidoc = uiapp.ActiveUIDocument;
- Application app = uiapp.Application as Application;
- Document doc = uidoc.Document;
- Selection sel = uidoc.Selection;
- ICollection<ElementId> selIds = sel.GetElementIds();
- if (0 == selIds.Count)
- {
- // If no elements selected.
- TaskDialog.Show("Revit","You haven't selected any elements.");
- }
- else
- {
- foreach(ElementId id in selIds)
- {
- Element elem = doc.GetElement(id);
- Wall wall = elem as Wall;
- if ( wall == null)
- {
- TaskDialog.Show("Revit","Please select wall.");
- }
- else
- {
- CompoundStructure cs = wall.WallType.GetCompoundStructure();
- int layerIndex = cs.GetFirstCoreLayerIndex();
- IList<CompoundStructureLayer> csLayers = cs.GetLayers();
- foreach(CompoundStructureLayer csLayer in csLayers)
- {
- ElementId elemId = csLayer.MaterialId;
- Material material = doc.GetElement(elemId) as Material;
- // Retrieve ThermalAssset information
- // Refer to Revit API help: PropertySetElement.GetThermalAsset Method
- ElementId thermalAssetId = material.ThermalAssetId;
- if (thermalAssetId != ElementId.InvalidElementId)
- {
- PropertySetElement pse = doc.GetElement(thermalAssetId)
- as PropertySetElement;
- if (pse != null)
- {
- ThermalAsset asset = pse.GetThermalAsset();
- // Check the thermal material type and only read if solid
- if (asset.ThermalMaterialType == ThermalMaterialType.Solid)
- {
- // Get the properties which are supported in solid type
- bool isTransmitsLight = asset.TransmitsLight;
- double permeability = asset.Permeability;
- double porosity = asset.Porosity;
- double reflectivity = asset.Reflectivity;
- double resistivity = asset.ElectricalResistivity;
- StructuralBehavior behavior = asset.Behavior;
- // Get the other properties.
- double heatOfVaporization = asset.SpecificHeatOfVaporization;
- double emissivity = asset.Emissivity;
- double conductivity = asset.ThermalConductivity;
- double density = asset.Density;
- TaskDialog.Show(
- "Revit",
- "TransmitsLight: "+ isTransmitsLight +"\r\n" +
- "Permeability: "+ permeability +"\r\n" +
- "Porosity: "+ porosity +"\r\n" +
- "Reflectivity: "+ reflectivity +"\r\n" +
- "ElectricalResistivity: "+ resistivity +"\r\n" +
- "Behavior: "+ behavior +"\r\n" +
- "SpecificHeatOfVaporization: "+ heatOfVaporization +"\r\n" +
- "Emissivity: "+ emissivity +"\r\n" +
- "ThermalConductivity: "+ conductivity +"\r\n" +
- "Density: "+ density
- );
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement