Advertisement
Guest User

Untitled

a guest
Jan 16th, 2017
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.04 KB | None | 0 0
  1. // Copyright(c) 2017 CODESIGN TOKYO
  2.  
  3. // Permission is hereby granted, free of charge, to any person obtaining a
  4. // copy of this software and associated documentation files (the
  5. // "Software"), to deal in the Software without restriction, including
  6. // without limitation the rights to use, copy, modify, merge, publish,
  7. // distribute, sublicense, and/or sell copies of the Software, and to
  8. // permit persons to whom the Software is furnished to do so, subject to
  9. // the following conditions:
  10.  
  11. // The above copyright notice and this permission notice shall be
  12. // included in all copies or substantial portions of the Software.
  13.  
  14. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  15. // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  16. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  17. // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  18. // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  19. // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  20. // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  21.  
  22. using System;
  23. using System.Collections.Generic;
  24. using System.Linq;
  25.  
  26. using Autodesk.Revit.DB;
  27. using Autodesk.Revit.UI;
  28. using Autodesk.Revit.UI.Selection;
  29. using Autodesk.Revit.ApplicationServices;
  30. using Autodesk.Revit.Attributes;
  31.  
  32. namespace MEP
  33. {
  34. [Autodesk.Revit.Attributes.Transaction(Autodesk.Revit.Attributes.TransactionMode.Manual)]
  35. [Autodesk.Revit.DB.Macros.AddInId("5990BE6F-0359-4BE5-8F0E-338C0C036520")]
  36. public partial class ThisDocument
  37. {
  38. private void Module_Startup(object sender, EventArgs e)
  39. {
  40.  
  41. }
  42.  
  43. private void Module_Shutdown(object sender, EventArgs e)
  44. {
  45.  
  46. }
  47.  
  48. #region Revit Macros generated code
  49. private void InternalStartup()
  50. {
  51. this.Startup += new System.EventHandler(Module_Startup);
  52. this.Shutdown += new System.EventHandler(Module_Shutdown);
  53. }
  54. #endregion
  55. public void ReadMaterialParam()
  56. {
  57.  
  58. UIApplication uiapp = this.Application;
  59. UIDocument uidoc = uiapp.ActiveUIDocument;
  60. Application app = uiapp.Application as Application;
  61. Document doc = uidoc.Document;
  62.  
  63. Selection sel = uidoc.Selection;
  64. ICollection<ElementId> selIds = sel.GetElementIds();
  65.  
  66. if (0 == selIds.Count)
  67. {
  68. // If no elements selected.
  69. TaskDialog.Show("Revit","You haven't selected any elements.");
  70. }
  71. else
  72. {
  73.  
  74. foreach(ElementId id in selIds)
  75. {
  76. Element elem = doc.GetElement(id);
  77.  
  78. Wall wall = elem as Wall;
  79. if ( wall == null)
  80. {
  81. TaskDialog.Show("Revit","Please select wall.");
  82. }
  83. else
  84. {
  85. CompoundStructure cs = wall.WallType.GetCompoundStructure();
  86.  
  87. int layerIndex = cs.GetFirstCoreLayerIndex();
  88.  
  89. IList<CompoundStructureLayer> csLayers = cs.GetLayers();
  90.  
  91. foreach(CompoundStructureLayer csLayer in csLayers)
  92. {
  93. ElementId elemId = csLayer.MaterialId;
  94. Material material = doc.GetElement(elemId) as Material;
  95.  
  96. // Retrieve ThermalAssset information
  97. // Refer to Revit API help: PropertySetElement.GetThermalAsset Method
  98.  
  99. ElementId thermalAssetId = material.ThermalAssetId;
  100. if (thermalAssetId != ElementId.InvalidElementId)
  101. {
  102. PropertySetElement pse = doc.GetElement(thermalAssetId)
  103. as PropertySetElement;
  104. if (pse != null)
  105. {
  106. ThermalAsset asset = pse.GetThermalAsset();
  107.  
  108. // Check the thermal material type and only read if solid
  109. if (asset.ThermalMaterialType == ThermalMaterialType.Solid)
  110. {
  111. // Get the properties which are supported in solid type
  112. bool isTransmitsLight = asset.TransmitsLight;
  113. double permeability = asset.Permeability;
  114. double porosity = asset.Porosity;
  115. double reflectivity = asset.Reflectivity;
  116. double resistivity = asset.ElectricalResistivity;
  117. StructuralBehavior behavior = asset.Behavior;
  118.  
  119. // Get the other properties.
  120. double heatOfVaporization = asset.SpecificHeatOfVaporization;
  121. double emissivity = asset.Emissivity;
  122. double conductivity = asset.ThermalConductivity;
  123. double density = asset.Density;
  124.  
  125. TaskDialog.Show(
  126. "Revit",
  127. "TransmitsLight: "+ isTransmitsLight +"\r\n" +
  128. "Permeability: "+ permeability +"\r\n" +
  129. "Porosity: "+ porosity +"\r\n" +
  130. "Reflectivity: "+ reflectivity +"\r\n" +
  131. "ElectricalResistivity: "+ resistivity +"\r\n" +
  132. "Behavior: "+ behavior +"\r\n" +
  133. "SpecificHeatOfVaporization: "+ heatOfVaporization +"\r\n" +
  134. "Emissivity: "+ emissivity +"\r\n" +
  135. "ThermalConductivity: "+ conductivity +"\r\n" +
  136. "Density: "+ density
  137. );
  138. }
  139.  
  140. }
  141. }
  142. }
  143. }
  144. }
  145. }
  146. }
  147. }
  148. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement