mirror of
https://github.com/jeremytammik/RevitSdkSamples.git
synced 2026-09-10 22:06:41 +00:00
added Revit 2022 SDK minus except *rvt and *rfa
This commit is contained in:
@@ -0,0 +1,81 @@
|
||||
//
|
||||
// (C) Copyright 2003-2019 by Autodesk, Inc.
|
||||
//
|
||||
// Permission to use, copy, modify, and distribute this software in
|
||||
// object code form for any purpose and without fee is hereby granted,
|
||||
// provided that the above copyright notice appears in all copies and
|
||||
// that both that copyright notice and the limited warranty and
|
||||
// restricted rights notice below appear in all supporting
|
||||
// documentation.
|
||||
//
|
||||
// AUTODESK PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS.
|
||||
// AUTODESK SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF
|
||||
// MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE. AUTODESK, INC.
|
||||
// DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE
|
||||
// UNINTERRUPTED OR ERROR FREE.
|
||||
//
|
||||
// Use, duplication, or disclosure by the U.S. Government is subject to
|
||||
// restrictions set forth in FAR 52.227-19 (Commercial Computer
|
||||
// Software - Restricted Rights) and DFAR 252.227-7013(c)(1)(ii)
|
||||
// (Rights in Technical Data and Computer Software), as applicable.
|
||||
//
|
||||
|
||||
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
//
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
//
|
||||
[assembly: AssemblyTitle("")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("")]
|
||||
[assembly: AssemblyCopyright("Copyright © Autodesk, Inc. 2009")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
//
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Revision and Build Numbers
|
||||
// by using the '*' as shown below:
|
||||
|
||||
[assembly: AssemblyVersion("1.0.*")]
|
||||
|
||||
//
|
||||
// In order to sign your assembly you must specify a key to use. Refer to the
|
||||
// Microsoft .NET Framework documentation for more information on assembly signing.
|
||||
//
|
||||
// Use the attributes below to control which key is used for signing.
|
||||
//
|
||||
// Notes:
|
||||
// (*) If no key is specified, the assembly is not signed.
|
||||
// (*) KeyName refers to a key that has been installed in the Crypto Service
|
||||
// Provider (CSP) on your machine. KeyFile refers to a file which contains
|
||||
// a key.
|
||||
// (*) If the KeyFile and the KeyName values are both specified, the
|
||||
// following processing occurs:
|
||||
// (1) If the KeyName can be found in the CSP, that key is used.
|
||||
// (2) If the KeyName does not exist and the KeyFile does exist, the key
|
||||
// in the KeyFile is installed into the CSP and used.
|
||||
// (*) In order to create a KeyFile, you can use the sn.exe (Strong Name) utility.
|
||||
// When specifying the KeyFile, the location of the KeyFile should be
|
||||
// relative to the project output directory which is
|
||||
// %Project Directory%\obj\<configuration>. For example, if your KeyFile is
|
||||
// located in the project directory, you would specify the AssemblyKeyFile
|
||||
// attribute as [assembly: AssemblyKeyFile("..\\..\\mykey.snk")]
|
||||
// (*) Delay Signing is an advanced option - see the Microsoft .NET Framework
|
||||
// documentation for more information on this.
|
||||
//
|
||||
[assembly: AssemblyDelaySign(false)]
|
||||
[assembly: AssemblyKeyFile("")]
|
||||
[assembly: AssemblyKeyName("")]
|
||||
@@ -0,0 +1,13 @@
|
||||
<?xml version="1.0"?>
|
||||
<RevitAddIns>
|
||||
<AddIn Type="Command">
|
||||
<Assembly>MaterialProperties.dll</Assembly>
|
||||
<ClientId>69ddbdbf-769b-4b24-a6c2-f1747929f54c</ClientId>
|
||||
<FullClassName>Revit.SDK.Samples.MaterialProperties.CS.MaterialProperties</FullClassName>
|
||||
<Text>Material Properties (CS)</Text>
|
||||
<Description>Get the material physical properties of the selected beam, column or brace.</Description>
|
||||
<VisibilityMode>AlwaysVisible</VisibilityMode>
|
||||
<VendorId>ADSK</VendorId>
|
||||
<VendorDescription>Autodesk, www.autodesk.com</VendorDescription>
|
||||
</AddIn>
|
||||
</RevitAddIns>
|
||||
@@ -0,0 +1,669 @@
|
||||
//
|
||||
// (C) Copyright 2003-2019 by Autodesk, Inc.
|
||||
//
|
||||
// Permission to use, copy, modify, and distribute this software in
|
||||
// object code form for any purpose and without fee is hereby granted,
|
||||
// provided that the above copyright notice appears in all copies and
|
||||
// that both that copyright notice and the limited warranty and
|
||||
// restricted rights notice below appear in all supporting
|
||||
// documentation.
|
||||
//
|
||||
// AUTODESK PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS.
|
||||
// AUTODESK SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF
|
||||
// MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE. AUTODESK, INC.
|
||||
// DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE
|
||||
// UNINTERRUPTED OR ERROR FREE.
|
||||
//
|
||||
// Use, duplication, or disclosure by the U.S. Government is subject to
|
||||
// restrictions set forth in FAR 52.227-19 (Commercial Computer
|
||||
// Software - Restricted Rights) and DFAR 252.227-7013(c)(1)(ii)
|
||||
// (Rights in Technical Data and Computer Software), as applicable.
|
||||
//
|
||||
|
||||
|
||||
using System;
|
||||
using System.Data;
|
||||
using System.Text;
|
||||
using System.Collections;
|
||||
using System.Windows.Forms;
|
||||
|
||||
using Autodesk.Revit;
|
||||
using Autodesk.Revit.DB;
|
||||
using Autodesk.Revit.DB.Structure;
|
||||
using Autodesk.Revit.UI;
|
||||
|
||||
using Material = Autodesk.Revit.DB.Material;
|
||||
|
||||
namespace Revit.SDK.Samples.MaterialProperties.CS
|
||||
{
|
||||
/// <summary>
|
||||
/// get the material physical properties of the selected beam, column or brace
|
||||
/// get all material types and their sub types to the user and then change the material type of the selected beam to the one chosen by the user
|
||||
/// with a selected concrete beam, column or brace, change its unit weight to 145 P/ft3
|
||||
/// </summary>
|
||||
[Autodesk.Revit.Attributes.Transaction(Autodesk.Revit.Attributes.TransactionMode.Manual)]
|
||||
[Autodesk.Revit.Attributes.Regeneration(Autodesk.Revit.Attributes.RegenerationOption.Manual)]
|
||||
[Autodesk.Revit.Attributes.Journaling(Autodesk.Revit.Attributes.JournalingMode.NoCommandData)]
|
||||
public class MaterialProperties : Autodesk.Revit.UI.IExternalCommand
|
||||
{
|
||||
const double ToMetricUnitWeight = 0.010764; //coefficient of converting unit weight from internal unit to metric unit
|
||||
const double ToMetricStress = 0.334554; //coefficient of converting stress from internal unit to metric unit
|
||||
const double ToImperialUnitWeight = 6.365827; //coefficient of converting unit weight from internal unit to imperial unit
|
||||
const double ChangedUnitWeight = 14.5; //the value of unit weight of selected component to be set
|
||||
|
||||
Autodesk.Revit.UI.UIApplication m_revit = null;
|
||||
Hashtable m_allMaterialMap = new Hashtable(); //hashtable contains all materials with index of their ElementId
|
||||
FamilyInstance m_selectedComponent = null; //selected beam, column or brace
|
||||
Parameter m_currentMaterial = null; //current material of selected beam, column or brace
|
||||
Material m_cacheMaterial;
|
||||
ArrayList m_steels = new ArrayList(); //arraylist of all materials belonging to steel type
|
||||
ArrayList m_concretes = new ArrayList(); //arraylist of all materials belonging to concrete type
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// get the material type of selected element
|
||||
/// </summary>
|
||||
public StructuralAssetClass CurrentType
|
||||
{
|
||||
get
|
||||
{
|
||||
Material material = CurrentMaterial as Material;
|
||||
int materialId = 0;
|
||||
if (material != null)
|
||||
{
|
||||
materialId = material.Id.IntegerValue;
|
||||
}
|
||||
if (materialId <= 0)
|
||||
{
|
||||
return StructuralAssetClass.Generic;
|
||||
}
|
||||
Autodesk.Revit.DB.Material materialElem = (Autodesk.Revit.DB.Material)m_allMaterialMap[materialId];
|
||||
if (null == materialElem)
|
||||
{
|
||||
return StructuralAssetClass.Generic;
|
||||
}
|
||||
return GetMaterialType(materialElem);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// get the material attribute of selected element
|
||||
/// </summary>
|
||||
public object CurrentMaterial
|
||||
{
|
||||
get
|
||||
{
|
||||
m_cacheMaterial = GetCurrentMaterial();
|
||||
return m_cacheMaterial;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// arraylist of all materials belonging to steel type
|
||||
/// </summary>
|
||||
public ArrayList SteelCollection
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_steels;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// arraylist of all materials belonging to concrete type
|
||||
/// </summary>
|
||||
public ArrayList ConcreteCollection
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_concretes;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// three basic material types in Revit
|
||||
/// </summary>
|
||||
public ArrayList MaterialTypes
|
||||
{
|
||||
get
|
||||
{
|
||||
ArrayList typeAL = new ArrayList();
|
||||
typeAL.Add("Undefined");
|
||||
typeAL.Add("Basic");
|
||||
typeAL.Add("Generic");
|
||||
typeAL.Add("Metal");
|
||||
typeAL.Add("Concrete");
|
||||
typeAL.Add("Wood");
|
||||
typeAL.Add("Liquid");
|
||||
typeAL.Add("Gas");
|
||||
typeAL.Add("Plastic");
|
||||
return typeAL;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Implement this method as an external command for Revit.
|
||||
/// </summary>
|
||||
/// <param name="commandData">An object that is passed to the external application
|
||||
/// which contains data related to the command,
|
||||
/// such as the application object and active view.</param>
|
||||
/// <param name="message">A message that can be set by the external application
|
||||
/// which will be displayed if a failure or cancellation is returned by
|
||||
/// the external command.</param>
|
||||
/// <param name="elements">A set of elements to which the external application
|
||||
/// can add elements that are to be highlighted in case of failure or cancellation.</param>
|
||||
/// <returns>Return the status of the external command.
|
||||
/// A result of Succeeded means that the API external method functioned as expected.
|
||||
/// Cancelled can be used to signify that the user cancelled the external operation
|
||||
/// at some point. Failure should be returned if the application is unable to proceed with
|
||||
/// the operation.</returns>
|
||||
public Autodesk.Revit.UI.Result Execute(ExternalCommandData commandData,
|
||||
ref string message, Autodesk.Revit.DB.ElementSet elements)
|
||||
{
|
||||
Autodesk.Revit.UI.UIApplication revit = commandData.Application;
|
||||
m_revit = revit;
|
||||
if (!Init())
|
||||
{
|
||||
// there must be exactly one beam, column or brace selected
|
||||
TaskDialog.Show("Revit", "You should select only one beam, structural column or brace.");
|
||||
return Autodesk.Revit.UI.Result.Failed;
|
||||
}
|
||||
|
||||
Transaction documentTransaction = new Transaction(commandData.Application.ActiveUIDocument.Document, "Document");
|
||||
documentTransaction.Start();
|
||||
MaterialPropertiesForm displayForm = new MaterialPropertiesForm(this);
|
||||
try
|
||||
{
|
||||
displayForm.ShowDialog();
|
||||
}
|
||||
catch
|
||||
{
|
||||
TaskDialog.Show("Revit", "Sorry that your command failed.");
|
||||
return Autodesk.Revit.UI.Result.Failed;
|
||||
}
|
||||
documentTransaction.Commit();
|
||||
return Autodesk.Revit.UI.Result.Succeeded;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// get a datatable contains parameters' information of certain element
|
||||
/// </summary>
|
||||
/// <param name="o">Revit element</param>
|
||||
/// <param name="substanceKind">the material type of this element</param>
|
||||
/// <returns>datatable contains parameters' names and values</returns>
|
||||
public DataTable GetParameterTable(object o, StructuralAssetClass substanceKind)
|
||||
{
|
||||
//create an empty datatable
|
||||
DataTable parameterTable = CreateTable();
|
||||
//if failed to convert object
|
||||
Autodesk.Revit.DB.Material material = o as Autodesk.Revit.DB.Material;
|
||||
if (material == null)
|
||||
{
|
||||
return parameterTable;
|
||||
}
|
||||
|
||||
Parameter temporaryAttribute = null; // hold each parameter
|
||||
string temporaryValue = ""; // hold each value
|
||||
|
||||
#region Get all material element parameters
|
||||
|
||||
//- Behavior
|
||||
temporaryAttribute = material.get_Parameter(BuiltInParameter.PHY_MATERIAL_PARAM_BEHAVIOR);
|
||||
switch (temporaryAttribute.AsInteger())
|
||||
{
|
||||
case 0:
|
||||
AddDataRow(temporaryAttribute.Definition.Name, "Isotropic", parameterTable);
|
||||
break;
|
||||
case 1:
|
||||
AddDataRow(temporaryAttribute.Definition.Name, "Orthotropic", parameterTable);
|
||||
break;
|
||||
default:
|
||||
AddDataRow(temporaryAttribute.Definition.Name, "None", parameterTable);
|
||||
break;
|
||||
}
|
||||
//- Young's Modulus
|
||||
temporaryAttribute = material.get_Parameter(BuiltInParameter.PHY_MATERIAL_PARAM_YOUNG_MOD1);
|
||||
temporaryValue = temporaryAttribute.AsValueString();
|
||||
AddDataRow(temporaryAttribute.Definition.Name, temporaryValue, parameterTable);
|
||||
temporaryAttribute = material.get_Parameter(BuiltInParameter.PHY_MATERIAL_PARAM_YOUNG_MOD2);
|
||||
temporaryValue = temporaryAttribute.AsValueString();
|
||||
AddDataRow(temporaryAttribute.Definition.Name, temporaryValue, parameterTable);
|
||||
temporaryAttribute = material.get_Parameter(BuiltInParameter.PHY_MATERIAL_PARAM_YOUNG_MOD3);
|
||||
temporaryValue = temporaryAttribute.AsValueString();
|
||||
AddDataRow(temporaryAttribute.Definition.Name, temporaryValue, parameterTable);
|
||||
|
||||
// - Poisson Modulus
|
||||
temporaryAttribute = material.get_Parameter(BuiltInParameter.PHY_MATERIAL_PARAM_POISSON_MOD1);
|
||||
temporaryValue = temporaryAttribute.AsValueString();
|
||||
AddDataRow(temporaryAttribute.Definition.Name, temporaryValue, parameterTable);
|
||||
temporaryAttribute = material.get_Parameter(BuiltInParameter.PHY_MATERIAL_PARAM_POISSON_MOD2);
|
||||
temporaryValue = temporaryAttribute.AsValueString();
|
||||
AddDataRow(temporaryAttribute.Definition.Name, temporaryValue, parameterTable);
|
||||
temporaryAttribute = material.get_Parameter(BuiltInParameter.PHY_MATERIAL_PARAM_POISSON_MOD3);
|
||||
temporaryValue = temporaryAttribute.AsValueString();
|
||||
AddDataRow(temporaryAttribute.Definition.Name, temporaryValue, parameterTable);
|
||||
|
||||
// - Shear Modulus
|
||||
temporaryAttribute = material.get_Parameter(BuiltInParameter.PHY_MATERIAL_PARAM_SHEAR_MOD1);
|
||||
temporaryValue = temporaryAttribute.AsValueString();
|
||||
AddDataRow(temporaryAttribute.Definition.Name, temporaryValue, parameterTable);
|
||||
temporaryAttribute = material.get_Parameter(BuiltInParameter.PHY_MATERIAL_PARAM_SHEAR_MOD2);
|
||||
temporaryValue = temporaryAttribute.AsValueString();
|
||||
AddDataRow(temporaryAttribute.Definition.Name, temporaryValue, parameterTable);
|
||||
temporaryAttribute = material.get_Parameter(BuiltInParameter.PHY_MATERIAL_PARAM_SHEAR_MOD3);
|
||||
temporaryValue = temporaryAttribute.AsValueString();
|
||||
AddDataRow(temporaryAttribute.Definition.Name, temporaryValue, parameterTable);
|
||||
|
||||
//- Thermal Expansion Coefficient
|
||||
temporaryAttribute = material.get_Parameter(BuiltInParameter.PHY_MATERIAL_PARAM_EXP_COEFF1);
|
||||
temporaryValue = temporaryAttribute.AsValueString();
|
||||
AddDataRow(temporaryAttribute.Definition.Name, temporaryValue, parameterTable);
|
||||
temporaryAttribute = material.get_Parameter(BuiltInParameter.PHY_MATERIAL_PARAM_EXP_COEFF2);
|
||||
temporaryValue = temporaryAttribute.AsValueString();
|
||||
AddDataRow(temporaryAttribute.Definition.Name, temporaryValue, parameterTable);
|
||||
temporaryAttribute = material.get_Parameter(BuiltInParameter.PHY_MATERIAL_PARAM_EXP_COEFF3);
|
||||
temporaryValue = temporaryAttribute.AsValueString();
|
||||
AddDataRow(temporaryAttribute.Definition.Name, temporaryValue, parameterTable);
|
||||
|
||||
//- Unit Weight
|
||||
temporaryAttribute = material.get_Parameter(BuiltInParameter.PHY_MATERIAL_PARAM_UNIT_WEIGHT);
|
||||
temporaryValue = temporaryAttribute.AsValueString();
|
||||
AddDataRow(temporaryAttribute.Definition.Name, temporaryValue, parameterTable);
|
||||
|
||||
//- Bending Reinforcement
|
||||
temporaryAttribute = material.get_Parameter(BuiltInParameter.PHY_MATERIAL_PARAM_BENDING_REINFORCEMENT);
|
||||
if (null != temporaryAttribute)
|
||||
{
|
||||
temporaryValue = temporaryAttribute.AsValueString();
|
||||
AddDataRow(temporaryAttribute.Definition.Name, temporaryValue, parameterTable);
|
||||
}
|
||||
|
||||
//- Shear Reinforcement
|
||||
temporaryAttribute = material.get_Parameter(BuiltInParameter.PHY_MATERIAL_PARAM_SHEAR_REINFORCEMENT);
|
||||
if (null != temporaryAttribute)
|
||||
{
|
||||
temporaryValue = temporaryAttribute.AsValueString();
|
||||
AddDataRow(temporaryAttribute.Definition.Name, temporaryValue, parameterTable);
|
||||
}
|
||||
|
||||
//- Resistance Calc Strength
|
||||
temporaryAttribute = material.get_Parameter(BuiltInParameter.PHY_MATERIAL_PARAM_RESISTANCE_CALC_STRENGTH);
|
||||
if (null != temporaryAttribute)
|
||||
{
|
||||
temporaryValue = temporaryAttribute.AsValueString();
|
||||
AddDataRow(temporaryAttribute.Definition.Name, temporaryValue, parameterTable);
|
||||
}
|
||||
|
||||
// For Steel only:
|
||||
if (StructuralAssetClass.Metal == substanceKind)
|
||||
{
|
||||
//- Minimum Yield Stress
|
||||
temporaryAttribute = material.get_Parameter(BuiltInParameter.PHY_MATERIAL_PARAM_MINIMUM_YIELD_STRESS);
|
||||
temporaryValue = temporaryAttribute.AsValueString();
|
||||
AddDataRow(temporaryAttribute.Definition.Name, temporaryValue, parameterTable);
|
||||
|
||||
//- Minimum Tensile Strength
|
||||
temporaryAttribute = material.get_Parameter(BuiltInParameter.PHY_MATERIAL_PARAM_MINIMUM_TENSILE_STRENGTH);
|
||||
temporaryValue = temporaryAttribute.AsValueString();
|
||||
AddDataRow(temporaryAttribute.Definition.Name, temporaryValue, parameterTable);
|
||||
|
||||
//- Reduction Factor
|
||||
temporaryAttribute = material.get_Parameter(BuiltInParameter.PHY_MATERIAL_PARAM_REDUCTION_FACTOR);
|
||||
temporaryValue = temporaryAttribute.AsValueString();
|
||||
AddDataRow(temporaryAttribute.Definition.Name, temporaryValue, parameterTable);
|
||||
}
|
||||
|
||||
// For Concrete only:
|
||||
if (StructuralAssetClass.Concrete == substanceKind)
|
||||
{
|
||||
//- Concrete Compression
|
||||
temporaryAttribute = material.get_Parameter(BuiltInParameter.PHY_MATERIAL_PARAM_CONCRETE_COMPRESSION);
|
||||
temporaryValue = temporaryAttribute.AsValueString();
|
||||
AddDataRow(temporaryAttribute.Definition.Name, temporaryValue, parameterTable);
|
||||
|
||||
//- Lightweight
|
||||
temporaryAttribute = material.get_Parameter(BuiltInParameter.PHY_MATERIAL_PARAM_LIGHT_WEIGHT);
|
||||
temporaryValue = temporaryAttribute.AsValueString();
|
||||
AddDataRow(temporaryAttribute.Definition.Name, temporaryValue, parameterTable);
|
||||
|
||||
//- Shear Strength Reduction
|
||||
temporaryAttribute = material.get_Parameter(BuiltInParameter.PHY_MATERIAL_PARAM_SHEAR_STRENGTH_REDUCTION);
|
||||
temporaryValue = temporaryAttribute.AsValueString();
|
||||
AddDataRow(temporaryAttribute.Definition.Name, temporaryValue, parameterTable);
|
||||
}
|
||||
#endregion
|
||||
return parameterTable;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Update cache material
|
||||
/// </summary>
|
||||
/// <param name="obj">new material</param>
|
||||
public void UpdateMaterial(object obj)
|
||||
{
|
||||
if (null == obj)
|
||||
{
|
||||
throw new ArgumentNullException();
|
||||
}
|
||||
{
|
||||
m_cacheMaterial = obj as Material;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// set the material of selected component
|
||||
/// </summary>
|
||||
public void SetMaterial()
|
||||
{
|
||||
if (null == m_cacheMaterial || null == m_currentMaterial)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Autodesk.Revit.DB.ElementId identity = m_cacheMaterial.Id;
|
||||
m_currentMaterial.Set(identity);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// change unit weight of selected component to 14.50 kN/m3
|
||||
/// </summary>
|
||||
public bool ChangeUnitWeight()
|
||||
{
|
||||
Autodesk.Revit.DB.Material material = GetCurrentMaterial();
|
||||
if (material == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
Parameter weightPara = material.get_Parameter(BuiltInParameter.PHY_MATERIAL_PARAM_UNIT_WEIGHT);
|
||||
|
||||
weightPara.Set(ChangedUnitWeight / ToMetricUnitWeight);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// firstly, check whether only one beam, column or brace is selected
|
||||
/// then initialize some member variables
|
||||
/// </summary>
|
||||
/// <returns>is the initialize successful</returns>
|
||||
private bool Init()
|
||||
{
|
||||
//selected 0 or more than 1 component
|
||||
if (m_revit.ActiveUIDocument.Selection.GetElementIds().Count != 1)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
GetSelectedComponent();
|
||||
//selected component isn't beam, column or brace
|
||||
if (m_selectedComponent == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
//initialize some member variables
|
||||
GetAllMaterial();
|
||||
return true;
|
||||
}
|
||||
catch
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// get current material of selected component
|
||||
/// </summary>
|
||||
private Autodesk.Revit.DB.Material GetCurrentMaterial()
|
||||
{
|
||||
if (null != m_cacheMaterial)
|
||||
return m_cacheMaterial;
|
||||
|
||||
int identityValue = 0;
|
||||
if (m_currentMaterial != null)
|
||||
identityValue = m_currentMaterial.AsElementId().IntegerValue; //get the value of current material's ElementId
|
||||
//material has no value
|
||||
if (identityValue <= 0)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
Autodesk.Revit.DB.Material material = (Autodesk.Revit.DB.Material)m_allMaterialMap[identityValue];
|
||||
|
||||
return material;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// get selected beam, column or brace
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
private void GetSelectedComponent()
|
||||
{
|
||||
ElementSet componentCollection = new ElementSet();
|
||||
foreach (ElementId elementId in m_revit.ActiveUIDocument.Selection.GetElementIds())
|
||||
{
|
||||
componentCollection.Insert(m_revit.ActiveUIDocument.Document.GetElement(elementId));
|
||||
}
|
||||
|
||||
if (componentCollection.Size != 1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//if the selection is a beam, column or brace, find out its parameters for display
|
||||
foreach (object o in componentCollection)
|
||||
{
|
||||
FamilyInstance component = o as FamilyInstance;
|
||||
if (component == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (component.StructuralType == StructuralType.Beam
|
||||
|| component.StructuralType == StructuralType.Brace
|
||||
|| component.StructuralType == StructuralType.Column)
|
||||
{
|
||||
//get selected beam, column or brace
|
||||
m_selectedComponent = component;
|
||||
}
|
||||
|
||||
//selection is a beam, column or brace, find out its parameters
|
||||
foreach (object p in component.Parameters)
|
||||
{
|
||||
Parameter attribute = p as Parameter;
|
||||
if (attribute == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
string parameterName = attribute.Definition.Name;
|
||||
// The "Beam Material" and "Column Material" family parameters have been replaced
|
||||
// by the built-in parameter "Structural Material".
|
||||
//if (parameterName == "Column Material" || parameterName == "Beam Material")
|
||||
if (parameterName == "Structural Material")
|
||||
{
|
||||
//get current material of selected component
|
||||
m_currentMaterial = attribute;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// get all materials exist in current document
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
private void GetAllMaterial()
|
||||
{
|
||||
FilteredElementCollector collector = new FilteredElementCollector(m_revit.ActiveUIDocument.Document);
|
||||
FilteredElementIterator i = collector.OfClass(typeof(Material)).GetElementIterator();
|
||||
i.Reset();
|
||||
bool moreValue = i.MoveNext();
|
||||
while (moreValue)
|
||||
{
|
||||
Autodesk.Revit.DB.Material material = i.Current as Autodesk.Revit.DB.Material;
|
||||
if (material == null)
|
||||
{
|
||||
moreValue = i.MoveNext();
|
||||
continue;
|
||||
}
|
||||
//get the type of the material
|
||||
StructuralAssetClass materialType = GetMaterialType(material);
|
||||
|
||||
//add materials to different ArrayList according to their types
|
||||
switch (materialType)
|
||||
{
|
||||
case StructuralAssetClass.Metal:
|
||||
{
|
||||
m_steels.Add(new MaterialMap(material));
|
||||
break;
|
||||
}
|
||||
case StructuralAssetClass.Concrete:
|
||||
{
|
||||
m_concretes.Add(new MaterialMap(material));
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
//map between materials and their elementId
|
||||
m_allMaterialMap.Add(material.Id.IntegerValue, material);
|
||||
moreValue = i.MoveNext();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create an empty table with parameter's name column and value column
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
private DataTable CreateTable()
|
||||
{
|
||||
// Create a new DataTable.
|
||||
DataTable propDataTable = new DataTable("ParameterTable");
|
||||
|
||||
// Create parameter column and add to the DataTable.
|
||||
DataColumn paraDataColumn = new DataColumn();
|
||||
paraDataColumn.DataType = System.Type.GetType("System.String");
|
||||
paraDataColumn.ColumnName = "Parameter";
|
||||
paraDataColumn.Caption = "Parameter";
|
||||
paraDataColumn.ReadOnly = true;
|
||||
// Add the column to the DataColumnCollection.
|
||||
propDataTable.Columns.Add(paraDataColumn);
|
||||
|
||||
// Create value column and add to the DataTable.
|
||||
DataColumn valueDataColumn = new DataColumn();
|
||||
valueDataColumn.DataType = System.Type.GetType("System.String");
|
||||
valueDataColumn.ColumnName = "Value";
|
||||
valueDataColumn.Caption = "Value";
|
||||
valueDataColumn.ReadOnly = false;
|
||||
propDataTable.Columns.Add(valueDataColumn);
|
||||
|
||||
return propDataTable;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// add one row to datatable of parameter
|
||||
/// </summary>
|
||||
/// <param name="parameterName">name of parameter</param>
|
||||
/// <param name="parameterValue">value of parameter</param>
|
||||
/// <param name="parameterTable">datatable to be added row</param>
|
||||
private void AddDataRow(string parameterName, string parameterValue, DataTable parameterTable)
|
||||
{
|
||||
DataRow newRow = parameterTable.NewRow();
|
||||
newRow["Parameter"] = parameterName;
|
||||
newRow["Value"] = parameterValue;
|
||||
parameterTable.Rows.Add(newRow);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the material type via giving material.
|
||||
/// According to my knowledge, the material type can be retrieved by two ways now:
|
||||
/// 1. If the PropertySetElement exists, retrieve it by PHY_MATERIAL_PARAM_CLASS parameter. (via PropertySetElement class)
|
||||
/// 2. If it's indenpendent, retrieve it by PHY_MATERIAL_PARAM_TYPE parameter(via Material class)
|
||||
/// </summary>
|
||||
/// <param name="material"></param>
|
||||
/// <returns></returns>
|
||||
private StructuralAssetClass GetMaterialType(Material material)
|
||||
{
|
||||
if (material.StructuralAssetId != ElementId.InvalidElementId)
|
||||
{
|
||||
PropertySetElement propElem = m_revit.ActiveUIDocument.Document.GetElement(material.StructuralAssetId) as PropertySetElement;
|
||||
Parameter propElemPara = propElem.get_Parameter(BuiltInParameter.PHY_MATERIAL_PARAM_CLASS);
|
||||
if (propElemPara != null)
|
||||
{
|
||||
return (StructuralAssetClass)propElemPara.AsInteger();
|
||||
}
|
||||
}
|
||||
return StructuralAssetClass.Undefined;
|
||||
//ElementId propElemId = material.GetMaterialAspectPropertySet(MaterialAspect.Structural);
|
||||
//if (ElementId.InvalidElementId == propElemId)
|
||||
//{
|
||||
// Parameter independentPara = material.get_Parameter(BuiltInParameter.PHY_MATERIAL_PARAM_TYPE);
|
||||
// if (null == independentPara)
|
||||
// {
|
||||
// return MaterialType.Generic;
|
||||
// }
|
||||
// return (MaterialType)independentPara.AsInteger();
|
||||
//}
|
||||
//PropertySetElement propElem = m_revit.ActiveUIDocument.Document.GetElement(propElemId) as PropertySetElement;
|
||||
//Parameter propElemPara = propElem.get_Parameter(BuiltInParameter.PHY_MATERIAL_PARAM_CLASS);
|
||||
//if (null == propElemPara)
|
||||
//{
|
||||
// return MaterialType.Generic;
|
||||
//}
|
||||
//return (MaterialType)propElemPara.AsInteger();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// assistant class contains material and its name
|
||||
/// </summary>
|
||||
public class MaterialMap
|
||||
{
|
||||
string m_materialName;
|
||||
Autodesk.Revit.DB.Material m_material;
|
||||
|
||||
/// <summary>
|
||||
/// constructor without parameter is forbidden
|
||||
/// </summary>
|
||||
private MaterialMap() { }
|
||||
|
||||
/// <summary>
|
||||
/// constructor
|
||||
/// </summary>
|
||||
/// <param name="material"></param>
|
||||
public MaterialMap(Autodesk.Revit.DB.Material material)
|
||||
{
|
||||
m_materialName = material.Name;
|
||||
m_material = material;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the material name
|
||||
/// </summary>
|
||||
public string MaterialName
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_materialName;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the material
|
||||
/// </summary>
|
||||
public Autodesk.Revit.DB.Material Material
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_material;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,148 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<ProjectType>Local</ProjectType>
|
||||
<ProductVersion>9.0.30729</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{4AD14A32-1CFA-4843-A645-E34FA2868F57}</ProjectGuid>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ApplicationIcon>
|
||||
</ApplicationIcon>
|
||||
<AssemblyKeyContainerName>
|
||||
</AssemblyKeyContainerName>
|
||||
<AssemblyName>MaterialProperties</AssemblyName>
|
||||
<AssemblyOriginatorKeyFile>
|
||||
</AssemblyOriginatorKeyFile>
|
||||
<DefaultClientScript>JScript</DefaultClientScript>
|
||||
<DefaultHTMLPageLayout>Grid</DefaultHTMLPageLayout>
|
||||
<DefaultTargetSchema>IE50</DefaultTargetSchema>
|
||||
<DelaySign>false</DelaySign>
|
||||
<OutputType>Library</OutputType>
|
||||
<RootNamespace>MaterialProperties</RootNamespace>
|
||||
<RunPostBuildEvent>OnBuildSuccess</RunPostBuildEvent>
|
||||
<StartupObject>
|
||||
</StartupObject>
|
||||
<FileUpgradeFlags>
|
||||
</FileUpgradeFlags>
|
||||
<UpgradeBackupLocation>
|
||||
</UpgradeBackupLocation>
|
||||
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
|
||||
<TargetFrameworkProfile />
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<AllowUnsafeBlocks>false</AllowUnsafeBlocks>
|
||||
<BaseAddress>285212672</BaseAddress>
|
||||
<CheckForOverflowUnderflow>false</CheckForOverflowUnderflow>
|
||||
<ConfigurationOverrideFile>
|
||||
</ConfigurationOverrideFile>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<DocumentationFile>
|
||||
</DocumentationFile>
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<FileAlignment>4096</FileAlignment>
|
||||
<NoStdLib>false</NoStdLib>
|
||||
<NoWarn>
|
||||
</NoWarn>
|
||||
<Optimize>false</Optimize>
|
||||
<RegisterForComInterop>false</RegisterForComInterop>
|
||||
<RemoveIntegerChecks>false</RemoveIntegerChecks>
|
||||
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<DebugType>full</DebugType>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<AllowUnsafeBlocks>false</AllowUnsafeBlocks>
|
||||
<BaseAddress>285212672</BaseAddress>
|
||||
<CheckForOverflowUnderflow>false</CheckForOverflowUnderflow>
|
||||
<ConfigurationOverrideFile>
|
||||
</ConfigurationOverrideFile>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<DocumentationFile>
|
||||
</DocumentationFile>
|
||||
<DebugSymbols>false</DebugSymbols>
|
||||
<FileAlignment>4096</FileAlignment>
|
||||
<NoStdLib>false</NoStdLib>
|
||||
<NoWarn>
|
||||
</NoWarn>
|
||||
<Optimize>true</Optimize>
|
||||
<RegisterForComInterop>false</RegisterForComInterop>
|
||||
<RemoveIntegerChecks>false</RemoveIntegerChecks>
|
||||
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<DebugType>none</DebugType>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<OutputPath>bin\x64\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<BaseAddress>285212672</BaseAddress>
|
||||
<FileAlignment>4096</FileAlignment>
|
||||
<DebugType>full</DebugType>
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
|
||||
<OutputPath>bin\x64\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<BaseAddress>285212672</BaseAddress>
|
||||
<Optimize>true</Optimize>
|
||||
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
|
||||
<FileAlignment>4096</FileAlignment>
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<RunPostBuildEvent>OnOutputUpdated</RunPostBuildEvent>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System">
|
||||
<Name>System</Name>
|
||||
</Reference>
|
||||
<Reference Include="System.Data">
|
||||
<Name>System.Data</Name>
|
||||
</Reference>
|
||||
<Reference Include="System.Drawing">
|
||||
<Name>System.Drawing</Name>
|
||||
</Reference>
|
||||
<Reference Include="System.Windows.Forms">
|
||||
<Name>System.Windows.Forms</Name>
|
||||
</Reference>
|
||||
<Reference Include="System.Xml">
|
||||
<Name>System.XML</Name>
|
||||
</Reference>
|
||||
<Reference Include="System.Core">
|
||||
<RequiredTargetFramework>3.5</RequiredTargetFramework>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="AssemblyInfo.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="MaterialProperties.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="MaterialPropertiesForm.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<EmbeddedResource Include="MaterialPropertiesForm.resx">
|
||||
<DependentUpon>MaterialPropertiesForm.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
<Import Project="$(SolutionDir)VSProps\SDKSamples.targets" />
|
||||
<PropertyGroup>
|
||||
<PreBuildEvent>
|
||||
</PreBuildEvent>
|
||||
<PostBuildEvent>set FILEFORSAMPLEREG="$(SolutionDir)..\..\..\..\Regression\API\SDKSamples\UpdateSampleDllForRegression.pl"
|
||||
if exist %25FILEFORSAMPLEREG%25 perl %25FILEFORSAMPLEREG%25 $(ProjectExt) "$(ProjectPath)" "$(TargetPath)" "$(SolutionDir)"</PostBuildEvent>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<ResolveAssemblyWarnOrErrorOnTargetArchitectureMismatch>None</ResolveAssemblyWarnOrErrorOnTargetArchitectureMismatch>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
@@ -0,0 +1,361 @@
|
||||
//
|
||||
// (C) Copyright 2003-2019 by Autodesk, Inc.
|
||||
//
|
||||
// Permission to use, copy, modify, and distribute this software in
|
||||
// object code form for any purpose and without fee is hereby granted,
|
||||
// provided that the above copyright notice appears in all copies and
|
||||
// that both that copyright notice and the limited warranty and
|
||||
// restricted rights notice below appear in all supporting
|
||||
// documentation.
|
||||
//
|
||||
// AUTODESK PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS.
|
||||
// AUTODESK SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF
|
||||
// MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE. AUTODESK, INC.
|
||||
// DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE
|
||||
// UNINTERRUPTED OR ERROR FREE.
|
||||
//
|
||||
// Use, duplication, or disclosure by the U.S. Government is subject to
|
||||
// restrictions set forth in FAR 52.227-19 (Commercial Computer
|
||||
// Software - Restricted Rights) and DFAR 252.227-7013(c)(1)(ii)
|
||||
// (Rights in Technical Data and Computer Software), as applicable.
|
||||
//
|
||||
|
||||
|
||||
using System;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Collections;
|
||||
using System.ComponentModel;
|
||||
using System.Windows.Forms;
|
||||
|
||||
using Autodesk.Revit.DB;
|
||||
using Autodesk.Revit.UI;
|
||||
|
||||
namespace Revit.SDK.Samples.MaterialProperties.CS
|
||||
{
|
||||
/// <summary>
|
||||
/// Summary description for MaterialPropFrm.
|
||||
/// </summary>
|
||||
public class MaterialPropertiesForm : System.Windows.Forms.Form
|
||||
{
|
||||
private System.Windows.Forms.Label typeLable;
|
||||
private System.Windows.Forms.ComboBox typeComboBox;
|
||||
private System.Windows.Forms.ComboBox subTypeComboBox;
|
||||
private System.Windows.Forms.Button okButton;
|
||||
private System.Windows.Forms.Button cancelButton;
|
||||
private System.Windows.Forms.Button applyButton;
|
||||
private System.Windows.Forms.Button changeButton;
|
||||
private System.Windows.Forms.DataGrid parameterDataGrid;
|
||||
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.Container components = null;
|
||||
|
||||
private MaterialPropertiesForm()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// material properties from
|
||||
/// </summary>
|
||||
/// <param name="dataBuffer">material properties from Revit</param>
|
||||
public MaterialPropertiesForm(MaterialProperties dataBuffer)
|
||||
{
|
||||
//
|
||||
// Required for Windows Form Designer support
|
||||
//
|
||||
InitializeComponent();
|
||||
parameterDataGrid.PreferredColumnWidth = parameterDataGrid.Width / 2 - 2;
|
||||
|
||||
m_dataBuffer = dataBuffer;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
if (components != null)
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
private MaterialProperties m_dataBuffer = null;
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.typeLable = new System.Windows.Forms.Label();
|
||||
this.typeComboBox = new System.Windows.Forms.ComboBox();
|
||||
this.subTypeComboBox = new System.Windows.Forms.ComboBox();
|
||||
this.parameterDataGrid = new System.Windows.Forms.DataGrid();
|
||||
this.okButton = new System.Windows.Forms.Button();
|
||||
this.cancelButton = new System.Windows.Forms.Button();
|
||||
this.applyButton = new System.Windows.Forms.Button();
|
||||
this.changeButton = new System.Windows.Forms.Button();
|
||||
((System.ComponentModel.ISupportInitialize)(this.parameterDataGrid)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// typeLable
|
||||
//
|
||||
this.typeLable.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.typeLable.Location = new System.Drawing.Point(24, 16);
|
||||
this.typeLable.Name = "typeLable";
|
||||
this.typeLable.Size = new System.Drawing.Size(80, 23);
|
||||
this.typeLable.TabIndex = 0;
|
||||
this.typeLable.Text = "Material Type:";
|
||||
//
|
||||
// typeComboBox
|
||||
//
|
||||
this.typeComboBox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.typeComboBox.Location = new System.Drawing.Point(112, 16);
|
||||
this.typeComboBox.Name = "typeComboBox";
|
||||
this.typeComboBox.Size = new System.Drawing.Size(264, 21);
|
||||
this.typeComboBox.TabIndex = 2;
|
||||
this.typeComboBox.SelectedIndexChanged += new System.EventHandler(this.typeComboBox_SelectedIndexChanged);
|
||||
//
|
||||
// subTypeComboBox
|
||||
//
|
||||
this.subTypeComboBox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.subTypeComboBox.Location = new System.Drawing.Point(112, 48);
|
||||
this.subTypeComboBox.MaxDropDownItems = 30;
|
||||
this.subTypeComboBox.Name = "subTypeComboBox";
|
||||
this.subTypeComboBox.Size = new System.Drawing.Size(264, 21);
|
||||
this.subTypeComboBox.TabIndex = 3;
|
||||
this.subTypeComboBox.SelectedIndexChanged += new System.EventHandler(this.subTypeComboBox_SelectedIndexChanged);
|
||||
//
|
||||
// parameterDataGrid
|
||||
//
|
||||
this.parameterDataGrid.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.parameterDataGrid.CaptionVisible = false;
|
||||
this.parameterDataGrid.DataMember = "";
|
||||
this.parameterDataGrid.HeaderForeColor = System.Drawing.SystemColors.ControlText;
|
||||
this.parameterDataGrid.Location = new System.Drawing.Point(16, 88);
|
||||
this.parameterDataGrid.Name = "parameterDataGrid";
|
||||
this.parameterDataGrid.ReadOnly = true;
|
||||
this.parameterDataGrid.RowHeadersVisible = false;
|
||||
this.parameterDataGrid.Size = new System.Drawing.Size(480, 380);
|
||||
this.parameterDataGrid.TabIndex = 4;
|
||||
//
|
||||
// okButton
|
||||
//
|
||||
this.okButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.okButton.Location = new System.Drawing.Point(104, 480);
|
||||
this.okButton.Name = "okButton";
|
||||
this.okButton.Size = new System.Drawing.Size(75, 23);
|
||||
this.okButton.TabIndex = 5;
|
||||
this.okButton.Text = "&OK";
|
||||
this.okButton.Click += new System.EventHandler(this.okButton_Click);
|
||||
//
|
||||
// cancelButton
|
||||
//
|
||||
this.cancelButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.cancelButton.Location = new System.Drawing.Point(192, 480);
|
||||
this.cancelButton.Name = "cancelButton";
|
||||
this.cancelButton.Size = new System.Drawing.Size(75, 23);
|
||||
this.cancelButton.TabIndex = 6;
|
||||
this.cancelButton.Text = "&Cancel";
|
||||
this.cancelButton.Click += new System.EventHandler(this.cancelButton_Click);
|
||||
//
|
||||
// applyButton
|
||||
//
|
||||
this.applyButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.applyButton.Location = new System.Drawing.Point(280, 480);
|
||||
this.applyButton.Name = "applyButton";
|
||||
this.applyButton.Size = new System.Drawing.Size(75, 23);
|
||||
this.applyButton.TabIndex = 7;
|
||||
this.applyButton.Text = "&Apply";
|
||||
this.applyButton.Click += new System.EventHandler(this.applyButton_Click);
|
||||
//
|
||||
// changeButton
|
||||
//
|
||||
this.changeButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.changeButton.Location = new System.Drawing.Point(368, 480);
|
||||
this.changeButton.Name = "changeButton";
|
||||
this.changeButton.Size = new System.Drawing.Size(128, 23);
|
||||
this.changeButton.TabIndex = 8;
|
||||
this.changeButton.Text = "Change &Unit Weight";
|
||||
this.changeButton.Click += new System.EventHandler(this.changeButton_Click);
|
||||
//
|
||||
// MaterialPropertiesForm
|
||||
//
|
||||
this.AcceptButton = this.okButton;
|
||||
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
|
||||
this.CancelButton = this.cancelButton;
|
||||
this.ClientSize = new System.Drawing.Size(512, 512);
|
||||
this.Controls.Add(this.changeButton);
|
||||
this.Controls.Add(this.applyButton);
|
||||
this.Controls.Add(this.cancelButton);
|
||||
this.Controls.Add(this.okButton);
|
||||
this.Controls.Add(this.parameterDataGrid);
|
||||
this.Controls.Add(this.subTypeComboBox);
|
||||
this.Controls.Add(this.typeComboBox);
|
||||
this.Controls.Add(this.typeLable);
|
||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
|
||||
this.MaximizeBox = false;
|
||||
this.MinimizeBox = false;
|
||||
this.Name = "MaterialPropertiesForm";
|
||||
this.ShowInTaskbar = false;
|
||||
this.Text = "Material Properties";
|
||||
this.Load += new System.EventHandler(this.MaterialPropFrm_Load);
|
||||
((System.ComponentModel.ISupportInitialize)(this.parameterDataGrid)).EndInit();
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void MaterialPropFrm_Load(object sender, System.EventArgs e)
|
||||
{
|
||||
LoadCurrentMaterial();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void typeComboBox_SelectedIndexChanged(object sender, System.EventArgs e)
|
||||
{
|
||||
if ((StructuralAssetClass)typeComboBox.SelectedIndex == StructuralAssetClass.Metal)
|
||||
{
|
||||
applyButton.Enabled = true;
|
||||
changeButton.Enabled = true;
|
||||
subTypeComboBox.Enabled = true;
|
||||
subTypeComboBox.DataSource = m_dataBuffer.SteelCollection;
|
||||
subTypeComboBox.DisplayMember = "MaterialName";
|
||||
subTypeComboBox.ValueMember = "Material";
|
||||
parameterDataGrid.DataSource = m_dataBuffer.GetParameterTable(subTypeComboBox.SelectedValue, (StructuralAssetClass)typeComboBox.SelectedIndex);
|
||||
}
|
||||
else if ((StructuralAssetClass)typeComboBox.SelectedIndex == StructuralAssetClass.Concrete)
|
||||
{
|
||||
applyButton.Enabled = true;
|
||||
changeButton.Enabled = true;
|
||||
subTypeComboBox.Enabled = true;
|
||||
subTypeComboBox.DataSource = m_dataBuffer.ConcreteCollection;
|
||||
subTypeComboBox.DisplayMember = "MaterialName";
|
||||
subTypeComboBox.ValueMember = "Material";
|
||||
parameterDataGrid.DataSource = m_dataBuffer.GetParameterTable(subTypeComboBox.SelectedValue, (StructuralAssetClass)typeComboBox.SelectedIndex);
|
||||
}
|
||||
else
|
||||
{
|
||||
applyButton.Enabled = false;
|
||||
changeButton.Enabled = false;
|
||||
subTypeComboBox.DataSource = new ArrayList();
|
||||
subTypeComboBox.Enabled = false;
|
||||
parameterDataGrid.DataSource = new DataTable();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// change the content in datagrid according to selected material type
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void subTypeComboBox_SelectedIndexChanged(object sender, System.EventArgs e)
|
||||
{
|
||||
if (null != subTypeComboBox.SelectedValue)
|
||||
{
|
||||
m_dataBuffer.UpdateMaterial(subTypeComboBox.SelectedValue);
|
||||
}
|
||||
|
||||
parameterDataGrid.DataSource = m_dataBuffer.GetParameterTable(subTypeComboBox.SelectedValue, (StructuralAssetClass)typeComboBox.SelectedIndex);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// close form
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void cancelButton_Click(object sender, System.EventArgs e)
|
||||
{
|
||||
this.Close();
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// set selected element's material to current selection and close form
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void okButton_Click(object sender, System.EventArgs e)
|
||||
{
|
||||
if (null != subTypeComboBox.SelectedValue)
|
||||
{
|
||||
m_dataBuffer.UpdateMaterial(subTypeComboBox.SelectedValue);
|
||||
m_dataBuffer.SetMaterial();
|
||||
}
|
||||
this.Close();
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// set selected element's material to current selection
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void applyButton_Click(object sender, System.EventArgs e)
|
||||
{
|
||||
if (null != subTypeComboBox.SelectedValue)
|
||||
{
|
||||
m_dataBuffer.UpdateMaterial(subTypeComboBox.SelectedValue);
|
||||
m_dataBuffer.SetMaterial();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// change unit weight all instances of the elements that use this material
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void changeButton_Click(object sender, System.EventArgs e)
|
||||
{
|
||||
TaskDialog.Show("Revit", "This will change the unit weight of all instances that use this material in current document.");
|
||||
|
||||
if (!m_dataBuffer.ChangeUnitWeight())
|
||||
{
|
||||
TaskDialog.Show("Revit", "Failed to change the unit weight.");
|
||||
return;
|
||||
}
|
||||
LoadCurrentMaterial();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// update display data to selected element's material
|
||||
/// </summary>
|
||||
private void LoadCurrentMaterial()
|
||||
{
|
||||
typeComboBox.DataSource = m_dataBuffer.MaterialTypes;
|
||||
|
||||
typeComboBox.SelectedIndex = (int)m_dataBuffer.CurrentType;
|
||||
|
||||
if (null == m_dataBuffer.CurrentMaterial || (m_dataBuffer.CurrentType != StructuralAssetClass.Metal
|
||||
&& m_dataBuffer.CurrentType != StructuralAssetClass.Concrete))
|
||||
{
|
||||
return;
|
||||
}
|
||||
Autodesk.Revit.DB.Material tmp = m_dataBuffer.CurrentMaterial as Autodesk.Revit.DB.Material;
|
||||
if (null == tmp)
|
||||
return;
|
||||
|
||||
subTypeComboBox.SelectedValue = tmp;
|
||||
parameterDataGrid.DataSource = m_dataBuffer.GetParameterTable(subTypeComboBox.SelectedValue, (StructuralAssetClass)typeComboBox.SelectedIndex);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
||||
Binary file not shown.
@@ -0,0 +1,55 @@
|
||||
'
|
||||
' (C) Copyright 2003-2019 by Autodesk, Inc.
|
||||
'
|
||||
' Permission to use, copy, modify, and distribute this software in
|
||||
' object code form for any purpose and without fee is hereby granted,
|
||||
' provided that the above copyright notice appears in all copies and
|
||||
' that both that copyright notice and the limited warranty and
|
||||
' restricted rights notice below appear in all supporting
|
||||
' documentation.
|
||||
'
|
||||
' AUTODESK PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS.
|
||||
' AUTODESK SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF
|
||||
' MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE. AUTODESK, INC.
|
||||
' DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE
|
||||
' UNINTERRUPTED OR ERROR FREE.
|
||||
'
|
||||
' Use, duplication, or disclosure by the U.S. Government is subject to
|
||||
' restrictions set forth in FAR 52.227-19 (Commercial Computer
|
||||
' Software - Restricted Rights) and DFAR 252.227-7013(c)(1)(ii)
|
||||
' (Rights in Technical Data and Computer Software), as applicable.
|
||||
'
|
||||
|
||||
|
||||
Imports System
|
||||
Imports System.Reflection
|
||||
Imports System.Runtime.InteropServices
|
||||
|
||||
' General Information about an assembly is controlled through the following
|
||||
' set of attributes. Change these attribute values to modify the information
|
||||
' associated with an assembly.
|
||||
|
||||
' Review the values of the assembly attributes
|
||||
|
||||
<Assembly: AssemblyTitle("")>
|
||||
<Assembly: AssemblyDescription("")>
|
||||
<Assembly: AssemblyCompany("")>
|
||||
<Assembly: AssemblyProduct("")>
|
||||
<Assembly: AssemblyCopyright("")>
|
||||
<Assembly: AssemblyTrademark("")>
|
||||
<Assembly: CLSCompliant(True)>
|
||||
|
||||
'The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
<Assembly: Guid("1F23E609-C617-4B43-937E-5E7A1A4DF6E4")>
|
||||
|
||||
' Version information for an assembly consists of the following four values:
|
||||
'
|
||||
' Major Version
|
||||
' Minor Version
|
||||
' Build Number
|
||||
' Revision
|
||||
'
|
||||
' You can specify all the values or you can default the Build and Revision Numbers
|
||||
' by using the '*' as shown below:
|
||||
|
||||
<Assembly: AssemblyVersion("1.0.*")>
|
||||
@@ -0,0 +1,13 @@
|
||||
<?xml version="1.0"?>
|
||||
<RevitAddIns>
|
||||
<AddIn Type="Command">
|
||||
<Assembly>MaterialProperties.dll</Assembly>
|
||||
<ClientId>69ddbdbf-769b-4b24-a6c2-f1747929f54c</ClientId>
|
||||
<FullClassName>Revit.SDK.Samples.MaterialProperties.VB.NET.MaterialProperties</FullClassName>
|
||||
<Text>Material Properties (VB)</Text>
|
||||
<Description>Get the material physical properties of the selected beam, column or brace.</Description>
|
||||
<VisibilityMode>AlwaysVisible</VisibilityMode>
|
||||
<VendorId>ADSK</VendorId>
|
||||
<VendorDescription>Autodesk, www.autodesk.com</VendorDescription>
|
||||
</AddIn>
|
||||
</RevitAddIns>
|
||||
@@ -0,0 +1,573 @@
|
||||
'
|
||||
' (C) Copyright 2003-2019 by Autodesk, Inc.
|
||||
'
|
||||
' Permission to use, copy, modify, and distribute this software in
|
||||
' object code form for any purpose and without fee is hereby granted,
|
||||
' provided that the above copyright notice appears in all copies and
|
||||
' that both that copyright notice and the limited warranty and
|
||||
' restricted rights notice below appear in all supporting
|
||||
' documentation.
|
||||
'
|
||||
' AUTODESK PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS.
|
||||
' AUTODESK SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF
|
||||
' MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE. AUTODESK, INC.
|
||||
' DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE
|
||||
' UNINTERRUPTED OR ERROR FREE.
|
||||
'
|
||||
' Use, duplication, or disclosure by the U.S. Government is subject to
|
||||
' restrictions set forth in FAR 52.227-19 (Commercial Computer
|
||||
' Software - Restricted Rights) and DFAR 252.227-7013(c)(1)(ii)
|
||||
' (Rights in Technical Data and Computer Software), as applicable.
|
||||
'
|
||||
|
||||
|
||||
Imports System
|
||||
Imports System.Data
|
||||
Imports System.Text
|
||||
Imports System.Windows.Forms
|
||||
Imports System.Collections
|
||||
|
||||
Imports Autodesk.Revit.DB
|
||||
Imports Autodesk.Revit.UI
|
||||
Imports Autodesk.Revit.DB.Structure
|
||||
|
||||
' All Autodesk Revit external commands must support this interface
|
||||
|
||||
|
||||
''' <summary>
|
||||
''' Get the material physical properties of the selected beam, column or brace.
|
||||
''' Get all material types and their sub types to the user
|
||||
''' and then change the material type of the selected beam to the one chosen by the user.
|
||||
''' With a selected concrete beam, column or brace, change its unit weight to 145 P/ft3.
|
||||
''' </summary>
|
||||
''' <remarks></remarks>
|
||||
<Autodesk.Revit.Attributes.Transaction(Autodesk.Revit.Attributes.TransactionMode.Manual)> _
|
||||
<Autodesk.Revit.Attributes.Regeneration(Autodesk.Revit.Attributes.RegenerationOption.Manual)> _
|
||||
<Autodesk.Revit.Attributes.Journaling(Autodesk.Revit.Attributes.JournalingMode.NoCommandData)> _
|
||||
Public Class MaterialProperties
|
||||
Implements Autodesk.Revit.UI.IExternalCommand
|
||||
|
||||
'coefficient of converting unit weight from internal unit to metric unit
|
||||
Const ToMetricUnitWeight As Double = 0.010764
|
||||
'coefficient of converting stress from internal unit to metric unit
|
||||
Const ToMetricStress As Double = 0.334554
|
||||
'coefficient of converting unit weight from internal unit to imperial unit
|
||||
Const ToImperialUnitWeight As Double = 6.365827
|
||||
'the value of unit weight of selected component to be set
|
||||
Const ChangedUnitWeight As Double = 14.5
|
||||
|
||||
Dim m_revit As Autodesk.Revit.UI.UIApplication = Nothing
|
||||
'hashtable contains all materials with index of their ElementId
|
||||
Dim m_allMaterialMap As Hashtable = New Hashtable
|
||||
|
||||
'selected beam, column or brace
|
||||
Dim m_selectedComponent As Autodesk.Revit.DB.FamilyInstance = Nothing
|
||||
|
||||
'current material of selected beam, column or brace
|
||||
Dim m_currentMaterial As Parameter = Nothing
|
||||
|
||||
'arraylist of all materials belonging to steel type
|
||||
Dim m_steels As ArrayList = New ArrayList
|
||||
|
||||
'arraylist of all materials belonging to concrete type
|
||||
Dim m_concretes As ArrayList = New ArrayList
|
||||
|
||||
ReadOnly Property CurrentType() As StructuralAssetClass
|
||||
Get
|
||||
Dim materialId As Integer = 0
|
||||
|
||||
If Not m_currentMaterial Is Nothing Then
|
||||
materialId = m_currentMaterial.AsElementId().IntegerValue
|
||||
End If
|
||||
|
||||
If materialId <= 0 Then
|
||||
Return StructuralAssetClass.Generic
|
||||
End If
|
||||
|
||||
Dim materialElem As Autodesk.Revit.DB.Material = _
|
||||
CType(m_allMaterialMap(materialId), Autodesk.Revit.DB.Material)
|
||||
|
||||
If Nothing Is materialElem Then
|
||||
Return StructuralAssetClass.Generic
|
||||
End If
|
||||
|
||||
Return GetMaterialType(materialElem)
|
||||
End Get
|
||||
|
||||
End Property
|
||||
|
||||
'get the material attribute of selected element
|
||||
ReadOnly Property CurrentMaterial() As Object
|
||||
Get
|
||||
Dim materialElem As Autodesk.Revit.DB.Material = GetCurrentMaterial()
|
||||
If materialElem Is Nothing Then
|
||||
Return Nothing
|
||||
End If
|
||||
Return materialElem
|
||||
|
||||
End Get
|
||||
End Property
|
||||
|
||||
'arraylist of all materials belonging to steel type
|
||||
ReadOnly Property SteelCollection() As ArrayList
|
||||
Get
|
||||
Return m_steels
|
||||
|
||||
End Get
|
||||
End Property
|
||||
|
||||
'arraylist of all materials belonging to concrete type
|
||||
ReadOnly Property ConcreteCollection() As ArrayList
|
||||
Get
|
||||
Return m_concretes
|
||||
End Get
|
||||
End Property
|
||||
|
||||
'three basic material types in Revit
|
||||
ReadOnly Property MaterialTypes() As ArrayList
|
||||
Get
|
||||
Dim typeAL As ArrayList = New ArrayList
|
||||
typeAL.Add("Undefined")
|
||||
typeAL.Add("Basic")
|
||||
typeAL.Add("Generic")
|
||||
typeAL.Add("Metal")
|
||||
typeAL.Add("Concrete")
|
||||
typeAL.Add("Wood")
|
||||
typeAL.Add("Liquid")
|
||||
typeAL.Add("Gas")
|
||||
typeAL.Add("Plastic")
|
||||
Return typeAL
|
||||
End Get
|
||||
End Property
|
||||
|
||||
''' <summary>
|
||||
''' Implement this method as an external command for Revit.
|
||||
''' </summary>
|
||||
''' <param name="commandData">An object that is passed to the external application
|
||||
''' which contains data related to the command,
|
||||
''' such as the application object and active view.</param>
|
||||
''' <param name="message">A message that can be set by the external application
|
||||
''' which will be displayed if a failure or cancellation is returned by
|
||||
''' the external command.</param>
|
||||
''' <param name="elements">A set of elements to which the external application
|
||||
''' can add elements that are to be highlighted in case of failure or cancellation.</param>
|
||||
''' <returns>Return the status of the external command.
|
||||
''' A result of Succeeded means that the API external method functioned as expected.
|
||||
''' Cancelled can be used to signify that the user canceled the external operation
|
||||
''' at some point. Failure should be returned if the application is unable to proceed with
|
||||
''' the operation.</returns>
|
||||
Public Function Execute(ByVal commandData As Autodesk.Revit.UI.ExternalCommandData, _
|
||||
ByRef message As String, _
|
||||
ByVal elements As Autodesk.Revit.DB.ElementSet) As _
|
||||
Autodesk.Revit.UI.Result Implements Autodesk.Revit.UI.IExternalCommand.Execute
|
||||
|
||||
Dim revit As Autodesk.Revit.UI.UIApplication = commandData.Application
|
||||
Dim documentTransaction As Autodesk.Revit.DB.Transaction = New Autodesk.Revit.DB.Transaction(commandData.Application.ActiveUIDocument.Document, "Document")
|
||||
|
||||
m_revit = revit
|
||||
If Not (Init()) Then
|
||||
'there must be exactly one beam, column or brace selected
|
||||
TaskDialog.Show("Revit", "You should select only one beam, structural column or brace.")
|
||||
Return Autodesk.Revit.UI.Result.Failed
|
||||
End If
|
||||
|
||||
documentTransaction.Start()
|
||||
|
||||
Dim displayForm As MaterialPropertiesForm = New MaterialPropertiesForm(Me)
|
||||
Try
|
||||
displayForm.ShowDialog()
|
||||
Catch ex As Exception
|
||||
TaskDialog.Show("Revit", "Sorry that your command failed.")
|
||||
Return Autodesk.Revit.UI.Result.Failed
|
||||
End Try
|
||||
documentTransaction.Commit()
|
||||
Return Autodesk.Revit.UI.Result.Succeeded
|
||||
End Function
|
||||
|
||||
'get a datatable contains parameters' information of certain element
|
||||
Public Function GetParameterTable(ByVal o As System.Object, _
|
||||
ByVal substanceKind As StructuralAssetClass) As DataTable
|
||||
'create an empty data table
|
||||
Dim parameterTable As DataTable = CreateTable()
|
||||
|
||||
'if failed to convert object
|
||||
If TypeOf o Is Autodesk.Revit.DB.Material Then
|
||||
Dim material As Autodesk.Revit.DB.Material = _
|
||||
CType(o, Autodesk.Revit.DB.Material)
|
||||
Dim temporaryAttribute As Parameter = Nothing
|
||||
Dim temporaryValue As String = ""
|
||||
|
||||
'Get all material element parameters
|
||||
Dim formatter As String = "#0.000000"
|
||||
' Behavior
|
||||
temporaryAttribute = material.Parameter(BuiltInParameter.PHY_MATERIAL_PARAM_BEHAVIOR)
|
||||
Select Case temporaryAttribute.AsInteger()
|
||||
Case 0
|
||||
AddDataRow(temporaryAttribute.Definition.Name, "Isotropic", parameterTable)
|
||||
Case 1
|
||||
AddDataRow(temporaryAttribute.Definition.Name, "Orthotropic", parameterTable)
|
||||
Case Else
|
||||
AddDataRow(temporaryAttribute.Definition.Name, "None", parameterTable)
|
||||
End Select
|
||||
|
||||
'Young's Modulus
|
||||
temporaryAttribute = material.Parameter(BuiltInParameter.PHY_MATERIAL_PARAM_YOUNG_MOD1)
|
||||
temporaryValue = temporaryAttribute.AsValueString()
|
||||
AddDataRow(temporaryAttribute.Definition.Name, temporaryValue, parameterTable)
|
||||
temporaryAttribute = material.Parameter(BuiltInParameter.PHY_MATERIAL_PARAM_YOUNG_MOD2)
|
||||
temporaryValue = temporaryAttribute.AsValueString()
|
||||
AddDataRow(temporaryAttribute.Definition.Name, temporaryValue, parameterTable)
|
||||
temporaryAttribute = material.Parameter(BuiltInParameter.PHY_MATERIAL_PARAM_YOUNG_MOD3)
|
||||
temporaryValue = temporaryAttribute.AsValueString()
|
||||
AddDataRow(temporaryAttribute.Definition.Name, temporaryValue, parameterTable)
|
||||
|
||||
'Poisson Modulus
|
||||
temporaryAttribute = material.Parameter(BuiltInParameter.PHY_MATERIAL_PARAM_POISSON_MOD1)
|
||||
temporaryValue = temporaryAttribute.AsValueString()
|
||||
AddDataRow(temporaryAttribute.Definition.Name, temporaryValue, parameterTable)
|
||||
temporaryAttribute = material.Parameter(BuiltInParameter.PHY_MATERIAL_PARAM_POISSON_MOD2)
|
||||
temporaryValue = temporaryAttribute.AsValueString()
|
||||
AddDataRow(temporaryAttribute.Definition.Name, temporaryValue, parameterTable)
|
||||
temporaryAttribute = material.Parameter(BuiltInParameter.PHY_MATERIAL_PARAM_POISSON_MOD3)
|
||||
temporaryValue = temporaryAttribute.AsValueString()
|
||||
AddDataRow(temporaryAttribute.Definition.Name, temporaryValue, parameterTable)
|
||||
|
||||
'Shear Modulus
|
||||
temporaryAttribute = _
|
||||
material.Parameter(BuiltInParameter.PHY_MATERIAL_PARAM_SHEAR_MOD1)
|
||||
temporaryValue = temporaryAttribute.AsValueString()
|
||||
AddDataRow(temporaryAttribute.Definition.Name, temporaryValue, parameterTable)
|
||||
temporaryAttribute = material.Parameter(BuiltInParameter.PHY_MATERIAL_PARAM_SHEAR_MOD2)
|
||||
temporaryValue = temporaryAttribute.AsValueString()
|
||||
AddDataRow(temporaryAttribute.Definition.Name, temporaryValue, parameterTable)
|
||||
temporaryAttribute = material.Parameter(BuiltInParameter.PHY_MATERIAL_PARAM_SHEAR_MOD3)
|
||||
temporaryValue = temporaryAttribute.AsValueString()
|
||||
AddDataRow(temporaryAttribute.Definition.Name, temporaryValue, parameterTable)
|
||||
|
||||
' Thermal Expansion Coefficient
|
||||
temporaryAttribute = material.Parameter(BuiltInParameter.PHY_MATERIAL_PARAM_EXP_COEFF1)
|
||||
temporaryValue = temporaryAttribute.AsValueString()
|
||||
AddDataRow(temporaryAttribute.Definition.Name, temporaryValue, parameterTable)
|
||||
temporaryAttribute = material.Parameter(BuiltInParameter.PHY_MATERIAL_PARAM_EXP_COEFF2)
|
||||
temporaryValue = temporaryAttribute.AsValueString()
|
||||
AddDataRow(temporaryAttribute.Definition.Name, temporaryValue, parameterTable)
|
||||
temporaryAttribute = material.Parameter(BuiltInParameter.PHY_MATERIAL_PARAM_EXP_COEFF3)
|
||||
temporaryValue = temporaryAttribute.AsValueString()
|
||||
AddDataRow(temporaryAttribute.Definition.Name, temporaryValue, parameterTable)
|
||||
|
||||
' Unit Weight
|
||||
temporaryAttribute = material.Parameter(BuiltInParameter.PHY_MATERIAL_PARAM_UNIT_WEIGHT)
|
||||
temporaryValue = temporaryAttribute.AsValueString()
|
||||
AddDataRow(temporaryAttribute.Definition.Name, temporaryValue, parameterTable)
|
||||
|
||||
' Bending Reinforcement
|
||||
temporaryAttribute = _
|
||||
material.Parameter(BuiltInParameter.PHY_MATERIAL_PARAM_BENDING_REINFORCEMENT)
|
||||
If Not (temporaryAttribute Is Nothing) Then
|
||||
temporaryValue = temporaryAttribute.AsValueString()
|
||||
AddDataRow(temporaryAttribute.Definition.Name, temporaryValue, parameterTable)
|
||||
End If
|
||||
|
||||
' Shear Reinforcement
|
||||
temporaryAttribute = _
|
||||
material.Parameter(BuiltInParameter.PHY_MATERIAL_PARAM_SHEAR_REINFORCEMENT)
|
||||
If Not (temporaryAttribute Is Nothing) Then
|
||||
temporaryValue = temporaryAttribute.AsValueString()
|
||||
AddDataRow(temporaryAttribute.Definition.Name, temporaryValue, parameterTable)
|
||||
End If
|
||||
|
||||
' Resistance Calc Strength
|
||||
temporaryAttribute = _
|
||||
material.Parameter(BuiltInParameter.PHY_MATERIAL_PARAM_RESISTANCE_CALC_STRENGTH)
|
||||
If Not (temporaryAttribute Is Nothing) Then
|
||||
temporaryValue = temporaryAttribute.AsValueString()
|
||||
AddDataRow(temporaryAttribute.Definition.Name, temporaryValue, parameterTable)
|
||||
End If
|
||||
|
||||
'For Steel only:
|
||||
If substanceKind = StructuralAssetClass.Metal Then
|
||||
' Minimum Yield Stress
|
||||
temporaryAttribute = _
|
||||
material.Parameter(BuiltInParameter.PHY_MATERIAL_PARAM_MINIMUM_YIELD_STRESS)
|
||||
temporaryValue = temporaryAttribute.AsValueString()
|
||||
AddDataRow(temporaryAttribute.Definition.Name, temporaryValue, parameterTable)
|
||||
|
||||
' Minimum Tensile Strength
|
||||
temporaryAttribute = _
|
||||
material.Parameter(BuiltInParameter.PHY_MATERIAL_PARAM_MINIMUM_TENSILE_STRENGTH)
|
||||
temporaryValue = temporaryAttribute.AsValueString()
|
||||
AddDataRow(temporaryAttribute.Definition.Name, temporaryValue, parameterTable)
|
||||
|
||||
' Reduction Factor
|
||||
temporaryAttribute = _
|
||||
material.Parameter(BuiltInParameter.PHY_MATERIAL_PARAM_REDUCTION_FACTOR)
|
||||
temporaryValue = temporaryAttribute.AsValueString()
|
||||
AddDataRow(temporaryAttribute.Definition.Name, temporaryValue, parameterTable)
|
||||
End If
|
||||
|
||||
'For Concrete only:
|
||||
If substanceKind = StructuralAssetClass.Concrete Then
|
||||
' Concrete Compression
|
||||
temporaryAttribute = _
|
||||
material.Parameter(BuiltInParameter.PHY_MATERIAL_PARAM_CONCRETE_COMPRESSION)
|
||||
temporaryValue = temporaryAttribute.AsValueString()
|
||||
AddDataRow(temporaryAttribute.Definition.Name, temporaryValue, parameterTable)
|
||||
|
||||
' Lightweight
|
||||
temporaryAttribute _
|
||||
= material.Parameter(BuiltInParameter.PHY_MATERIAL_PARAM_LIGHT_WEIGHT)
|
||||
temporaryValue = temporaryAttribute.AsValueString()
|
||||
AddDataRow(temporaryAttribute.Definition.Name, temporaryValue, parameterTable)
|
||||
|
||||
' Shear Strength Reduction
|
||||
temporaryAttribute = _
|
||||
material.Parameter(BuiltInParameter.PHY_MATERIAL_PARAM_SHEAR_STRENGTH_REDUCTION)
|
||||
temporaryValue = temporaryAttribute.AsValueString()
|
||||
AddDataRow(temporaryAttribute.Definition.Name, temporaryValue, parameterTable)
|
||||
End If
|
||||
|
||||
Else
|
||||
Return parameterTable
|
||||
End If
|
||||
|
||||
Return parameterTable
|
||||
End Function
|
||||
|
||||
'set the material of selected component
|
||||
Sub SetMaterial(ByVal o As Object)
|
||||
|
||||
If m_currentMaterial Is Nothing Then
|
||||
Return
|
||||
End If
|
||||
|
||||
If (TypeOf o Is Autodesk.Revit.DB.Material) Then
|
||||
Dim material As Autodesk.Revit.DB.Material
|
||||
material = o
|
||||
Dim identity As Autodesk.Revit.DB.ElementId = material.Id
|
||||
m_currentMaterial.Set(identity)
|
||||
End If
|
||||
|
||||
End Sub
|
||||
|
||||
'change unit weight of selected component to 14.50 kN/m3
|
||||
Public Function ChangeUnitWeight() As Boolean
|
||||
Dim material As Autodesk.Revit.DB.Material = GetCurrentMaterial()
|
||||
If material Is Nothing Then
|
||||
Return False
|
||||
End If
|
||||
|
||||
Dim weightPara As Parameter = _
|
||||
material.Parameter(BuiltInParameter.PHY_MATERIAL_PARAM_UNIT_WEIGHT)
|
||||
weightPara.Set(ChangedUnitWeight / ToMetricUnitWeight)
|
||||
|
||||
Return True
|
||||
End Function
|
||||
|
||||
'get current material of selected component
|
||||
Private Function GetCurrentMaterial() As Autodesk.Revit.DB.Material
|
||||
'get the value of current material's ElementId
|
||||
Dim identityValue As Integer = 0
|
||||
|
||||
If Not m_currentMaterial Is Nothing Then
|
||||
identityValue = m_currentMaterial.AsElementId().IntegerValue
|
||||
End If
|
||||
|
||||
'material has no value
|
||||
If (identityValue <= 0) Then
|
||||
Return Nothing
|
||||
End If
|
||||
Dim material As Autodesk.Revit.DB.Material = _
|
||||
CType(m_allMaterialMap(identityValue), Autodesk.Revit.DB.Material)
|
||||
Return material
|
||||
End Function
|
||||
|
||||
'firstly, check whether only one beam, column or brace is selected then initialize some member variables
|
||||
Private Function Init() As Boolean
|
||||
'selected 0 or more than 1 component
|
||||
If m_revit.ActiveUIDocument.Selection.GetElementIds().Count <> 1 Then
|
||||
Return False
|
||||
End If
|
||||
|
||||
Try
|
||||
GetSelectedComponent()
|
||||
'selected component isn't beam, column or brace
|
||||
If m_selectedComponent Is Nothing Then
|
||||
Return False
|
||||
End If
|
||||
|
||||
'initialize some member variables
|
||||
GetAllMaterial()
|
||||
Return True
|
||||
Catch ex As Exception
|
||||
Return False
|
||||
|
||||
End Try
|
||||
End Function
|
||||
|
||||
'get selected beam, column or brace
|
||||
Private Sub GetSelectedComponent()
|
||||
Dim componentCollection As Autodesk.Revit.DB.ElementSet = New Autodesk.Revit.DB.ElementSet()
|
||||
Dim elementId As Autodesk.Revit.DB.ElementId
|
||||
For Each elementId In m_revit.ActiveUIDocument.Selection.GetElementIds()
|
||||
componentCollection.Insert(m_revit.ActiveUIDocument.Document.GetElement(elementId))
|
||||
Next
|
||||
If (componentCollection.Size <> 1) Then
|
||||
Return
|
||||
End If
|
||||
|
||||
'if the selection is a beam, column or brace, find out its parameters for display
|
||||
Dim o As Object
|
||||
For Each o In componentCollection
|
||||
If TypeOf o Is Autodesk.Revit.DB.FamilyInstance Then
|
||||
Dim component As Autodesk.Revit.DB.FamilyInstance = o
|
||||
'selection is a beam, column or brace, find out its parameters
|
||||
If component.StructuralType = Autodesk.Revit.DB.Structure.StructuralType.Beam _
|
||||
Or component.StructuralType = Autodesk.Revit.DB.Structure.StructuralType.Brace _
|
||||
Or component.StructuralType = Autodesk.Revit.DB.Structure.StructuralType.Column Then
|
||||
'get selected beam, column or brace
|
||||
m_selectedComponent = component
|
||||
End If
|
||||
Dim p As Object
|
||||
For Each p In component.Parameters
|
||||
If TypeOf p Is Parameter Then
|
||||
Dim attribute As Parameter = p
|
||||
Dim parameterName As String = attribute.Definition.Name
|
||||
'' The "Beam Material" and "Column Material" family parameters have been replaced
|
||||
'' by the built-in parameter "Structural Material".
|
||||
''If parameterName = "Column Material" Or parameterName = "Beam Material" Then
|
||||
If parameterName = "Structural Material" Then
|
||||
'get current material of selected component
|
||||
m_currentMaterial = attribute
|
||||
Exit For
|
||||
End If
|
||||
End If
|
||||
Next p
|
||||
End If
|
||||
Next o
|
||||
|
||||
End Sub
|
||||
|
||||
'get all materials exist in current document
|
||||
Private Sub GetAllMaterial()
|
||||
Dim collector As Autodesk.Revit.DB.FilteredElementCollector = New Autodesk.Revit.DB.FilteredElementCollector(m_revit.ActiveUIDocument.Document)
|
||||
Dim i As Autodesk.Revit.DB.FilteredElementIterator = collector.OfClass(GetType(Autodesk.Revit.DB.Material)).GetElementIterator()
|
||||
i.Reset()
|
||||
Dim moreValue As Boolean = i.MoveNext()
|
||||
While moreValue
|
||||
If TypeOf i.Current Is Autodesk.Revit.DB.Material Then
|
||||
Dim material As Autodesk.Revit.DB.Material = i.Current
|
||||
Dim materialType As StructuralAssetClass = GetMaterialType(material)
|
||||
|
||||
'add materials to different ArrayList according to their types
|
||||
Select Case materialType
|
||||
Case StructuralAssetClass.Metal
|
||||
m_steels.Add(New MaterialMap(material))
|
||||
Case StructuralAssetClass.Concrete
|
||||
m_concretes.Add(New MaterialMap(material))
|
||||
Case Else
|
||||
End Select
|
||||
'map between materials and their elementId
|
||||
m_allMaterialMap.Add(material.Id.IntegerValue, material)
|
||||
End If
|
||||
moreValue = i.MoveNext()
|
||||
End While
|
||||
End Sub
|
||||
|
||||
'Create an empty table with parameter's name column and value column
|
||||
Private Function CreateTable() As DataTable
|
||||
'Create a new DataTable.
|
||||
Dim propDataTable As DataTable = New DataTable("ParameterTable")
|
||||
|
||||
'Create parameter column and add to the DataTable.
|
||||
Dim paraDataColumn As DataColumn = New DataColumn
|
||||
paraDataColumn.DataType = System.Type.GetType("System.String")
|
||||
paraDataColumn.ColumnName = "Parameter"
|
||||
paraDataColumn.Caption = "Parameter"
|
||||
paraDataColumn.ReadOnly = True
|
||||
propDataTable.Columns.Add(paraDataColumn)
|
||||
|
||||
'Create value column and add to the DataTable.
|
||||
Dim valueDataColumn As DataColumn = New DataColumn
|
||||
valueDataColumn.DataType = System.Type.GetType("System.String")
|
||||
valueDataColumn.ColumnName = "Value"
|
||||
valueDataColumn.Caption = "Value"
|
||||
valueDataColumn.ReadOnly = True
|
||||
propDataTable.Columns.Add(valueDataColumn)
|
||||
|
||||
Return propDataTable
|
||||
|
||||
End Function
|
||||
|
||||
'add one row to datatable of parameter
|
||||
Private Sub AddDataRow(ByVal parameterName As String, _
|
||||
ByVal parameterValue As String, ByVal parameterTable As DataTable)
|
||||
Dim newRow As DataRow = parameterTable.NewRow()
|
||||
newRow("Parameter") = parameterName
|
||||
newRow("Value") = parameterValue
|
||||
parameterTable.Rows.Add(newRow)
|
||||
End Sub
|
||||
|
||||
'Get the material type via giving material.
|
||||
'According to my knowledge, the material type can be retrieved by two ways now:
|
||||
'1. If the PropertySetElement exists, retrieve it by PHY_MATERIAL_PARAM_CLASS parameter. (via PropertySetElement class)
|
||||
'2. If it's indenpendent, retrieve it by PHY_MATERIAL_PARAM_TYPE parameter(via Material class)
|
||||
Private Function GetMaterialType(ByVal material As Autodesk.Revit.DB.Material) As StructuralAssetClass
|
||||
If (material.StructuralAssetId <> Autodesk.Revit.DB.ElementId.InvalidElementId) Then
|
||||
Dim propElem As Autodesk.Revit.DB.PropertySetElement = _
|
||||
CType(m_revit.ActiveUIDocument.Document.GetElement(material.StructuralAssetId), Autodesk.Revit.DB.PropertySetElement)
|
||||
Dim propElemPara As Parameter = propElem.Parameter(BuiltInParameter.PHY_MATERIAL_PARAM_CLASS)
|
||||
If Not propElemPara Is Nothing Then
|
||||
Return CType(propElemPara.AsInteger(), StructuralAssetClass)
|
||||
End If
|
||||
End If
|
||||
Return StructuralAssetClass.Generic
|
||||
'Dim propElemId As Autodesk.Revit.DB.ElementId = material.GetMaterialAspectPropertySet(MaterialAspect.Structural)
|
||||
'If (Autodesk.Revit.DB.ElementId.InvalidElementId = propElemId) Then
|
||||
' Dim independentPara As Parameter = material.Parameter(BuiltInParameter.PHY_MATERIAL_PARAM_TYPE)
|
||||
' If Nothing Is independentPara Then
|
||||
' Return MaterialType.Generic
|
||||
' End If
|
||||
' Return CType(independentPara.AsInteger(), MaterialType)
|
||||
'End If
|
||||
|
||||
'Dim propElem As Autodesk.Revit.DB.PropertySetElement = _
|
||||
' CType(m_revit.ActiveUIDocument.Document.GetElement(propElemId), Autodesk.Revit.DB.PropertySetElement)
|
||||
'Dim propElemPara As Parameter = propElem.Parameter(BuiltInParameter.PHY_MATERIAL_PARAM_CLASS)
|
||||
'If Nothing Is propElemPara Then
|
||||
' Return MaterialType.Generic
|
||||
'End If
|
||||
'Return CType(propElemPara.AsInteger(), MaterialType)
|
||||
End Function
|
||||
End Class
|
||||
|
||||
''' <summary>
|
||||
''' Assistant class contains material and its name
|
||||
''' </summary>
|
||||
''' <remarks></remarks>
|
||||
Public Class MaterialMap
|
||||
Dim m_materialName As String
|
||||
Dim m_material As Autodesk.Revit.DB.Material
|
||||
'constructor without parameter is forbidden
|
||||
Private Sub New()
|
||||
End Sub
|
||||
|
||||
'constructor
|
||||
Public Sub New(ByVal material As Autodesk.Revit.DB.Material)
|
||||
m_materialName = material.Name
|
||||
m_material = material
|
||||
End Sub
|
||||
|
||||
'Get material name
|
||||
Public ReadOnly Property MaterialName() As String
|
||||
Get
|
||||
Return m_materialName
|
||||
End Get
|
||||
End Property
|
||||
|
||||
'Get material
|
||||
Public ReadOnly Property Material() As Autodesk.Revit.DB.Material
|
||||
Get
|
||||
Return m_material
|
||||
End Get
|
||||
End Property
|
||||
End Class
|
||||
@@ -0,0 +1,154 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<ProjectType>Local</ProjectType>
|
||||
<ProductVersion>9.0.30729</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{A4DABB0B-29A5-4749-BBD5-224D942E718E}</ProjectGuid>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ApplicationIcon>
|
||||
</ApplicationIcon>
|
||||
<AssemblyKeyContainerName>
|
||||
</AssemblyKeyContainerName>
|
||||
<AssemblyName>MaterialProperties</AssemblyName>
|
||||
<AssemblyOriginatorKeyFile>
|
||||
</AssemblyOriginatorKeyFile>
|
||||
<AssemblyOriginatorKeyMode>None</AssemblyOriginatorKeyMode>
|
||||
<DefaultClientScript>JScript</DefaultClientScript>
|
||||
<DefaultHTMLPageLayout>Grid</DefaultHTMLPageLayout>
|
||||
<DefaultTargetSchema>IE50</DefaultTargetSchema>
|
||||
<DelaySign>false</DelaySign>
|
||||
<OutputType>Library</OutputType>
|
||||
<OptionCompare>Binary</OptionCompare>
|
||||
<OptionExplicit>On</OptionExplicit>
|
||||
<OptionStrict>Off</OptionStrict>
|
||||
<RootNamespace>Revit.SDK.Samples.MaterialProperties.VB.NET</RootNamespace>
|
||||
<StartupObject>Revit.SDK.Samples.MaterialProperties.VB.NET.%28None%29</StartupObject>
|
||||
<FileUpgradeFlags>
|
||||
</FileUpgradeFlags>
|
||||
<MyType>Windows</MyType>
|
||||
<UpgradeBackupLocation>
|
||||
</UpgradeBackupLocation>
|
||||
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
|
||||
<TargetFrameworkProfile />
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<OutputPath>bin\</OutputPath>
|
||||
<DocumentationFile>
|
||||
</DocumentationFile>
|
||||
<BaseAddress>285212672</BaseAddress>
|
||||
<ConfigurationOverrideFile>
|
||||
</ConfigurationOverrideFile>
|
||||
<DefineConstants>
|
||||
</DefineConstants>
|
||||
<DefineDebug>true</DefineDebug>
|
||||
<DefineTrace>true</DefineTrace>
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<Optimize>false</Optimize>
|
||||
<RegisterForComInterop>false</RegisterForComInterop>
|
||||
<RemoveIntegerChecks>false</RemoveIntegerChecks>
|
||||
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
|
||||
<WarningLevel>1</WarningLevel>
|
||||
<NoWarn>42016,42017,42018,42019,42032</NoWarn>
|
||||
<DebugType>full</DebugType>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<OutputPath>bin\</OutputPath>
|
||||
<DocumentationFile>
|
||||
</DocumentationFile>
|
||||
<BaseAddress>285212672</BaseAddress>
|
||||
<ConfigurationOverrideFile>
|
||||
</ConfigurationOverrideFile>
|
||||
<DefineConstants>
|
||||
</DefineConstants>
|
||||
<DefineDebug>false</DefineDebug>
|
||||
<DefineTrace>true</DefineTrace>
|
||||
<DebugSymbols>false</DebugSymbols>
|
||||
<Optimize>true</Optimize>
|
||||
<RegisterForComInterop>false</RegisterForComInterop>
|
||||
<RemoveIntegerChecks>false</RemoveIntegerChecks>
|
||||
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
|
||||
<WarningLevel>1</WarningLevel>
|
||||
<NoWarn>42016,42017,42018,42019,42032</NoWarn>
|
||||
<DebugType>none</DebugType>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DefineDebug>true</DefineDebug>
|
||||
<DefineTrace>true</DefineTrace>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<BaseAddress>285212672</BaseAddress>
|
||||
<WarningLevel>1</WarningLevel>
|
||||
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
|
||||
<NoWarn>42016,42017,42018,42019,42032</NoWarn>
|
||||
<DebugType>full</DebugType>
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
|
||||
<DefineTrace>true</DefineTrace>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<BaseAddress>285212672</BaseAddress>
|
||||
<Optimize>true</Optimize>
|
||||
<WarningLevel>1</WarningLevel>
|
||||
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
|
||||
<NoWarn>42016,42017,42018,42019,42032</NoWarn>
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System">
|
||||
<Name>System</Name>
|
||||
</Reference>
|
||||
<Reference Include="System.Data">
|
||||
<Name>System.Data</Name>
|
||||
</Reference>
|
||||
<Reference Include="System.Drawing">
|
||||
<Name>System.Drawing</Name>
|
||||
</Reference>
|
||||
<Reference Include="System.Windows.Forms">
|
||||
<Name>System.Windows.Forms</Name>
|
||||
</Reference>
|
||||
<Reference Include="System.Xml">
|
||||
<Name>System.XML</Name>
|
||||
</Reference>
|
||||
<Reference Include="System.Core">
|
||||
<RequiredTargetFramework>3.5</RequiredTargetFramework>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Import Include="Microsoft.VisualBasic" />
|
||||
<Import Include="System" />
|
||||
<Import Include="System.Collections" />
|
||||
<Import Include="System.Data" />
|
||||
<Import Include="System.Diagnostics" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="AssemblyInfo.vb">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="MaterialProperties.vb">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="MaterialPropertiesForm.vb">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<EmbeddedResource Include="MaterialPropertiesForm.resx">
|
||||
<DependentUpon>MaterialPropertiesForm.vb</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Folder Include="My Project\" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(SolutionDir)VSProps\SDKSamples.VB.targets" />
|
||||
<PropertyGroup>
|
||||
<PreBuildEvent>
|
||||
</PreBuildEvent>
|
||||
<PostBuildEvent>set FILEFORSAMPLEREG="$(SolutionDir)..\..\..\..\Regression\API\SDKSamples\UpdateSampleDllForRegression.pl"
|
||||
if exist %25FILEFORSAMPLEREG%25 perl %25FILEFORSAMPLEREG%25 $(ProjectExt) "$(ProjectPath)" "$(TargetPath)" "$(SolutionDir)"</PostBuildEvent>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<ResolveAssemblyWarnOrErrorOnTargetArchitectureMismatch>None</ResolveAssemblyWarnOrErrorOnTargetArchitectureMismatch>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
@@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
||||
@@ -0,0 +1,287 @@
|
||||
'
|
||||
' (C) Copyright 2003-2019 by Autodesk, Inc.
|
||||
'
|
||||
' Permission to use, copy, modify, and distribute this software in
|
||||
' object code form for any purpose and without fee is hereby granted,
|
||||
' provided that the above copyright notice appears in all copies and
|
||||
' that both that copyright notice and the limited warranty and
|
||||
' restricted rights notice below appear in all supporting
|
||||
' documentation.
|
||||
'
|
||||
' AUTODESK PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS.
|
||||
' AUTODESK SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF
|
||||
' MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE. AUTODESK, INC.
|
||||
' DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE
|
||||
' UNINTERRUPTED OR ERROR FREE.
|
||||
'
|
||||
' Use, duplication, or disclosure by the U.S. Government is subject to
|
||||
' restrictions set forth in FAR 52.227-19 (Commercial Computer
|
||||
' Software - Restricted Rights) and DFAR 252.227-7013(c)(1)(ii)
|
||||
' (Rights in Technical Data and Computer Software), as applicable.
|
||||
'
|
||||
|
||||
Imports System
|
||||
Imports System.Data
|
||||
Imports System.Drawing
|
||||
Imports System.Collections
|
||||
Imports System.ComponentModel
|
||||
Imports System.Windows.Forms
|
||||
Imports Autodesk.Revit.DB
|
||||
|
||||
'Summary description for MaterialPropFrm.
|
||||
Public Class MaterialPropertiesForm
|
||||
Inherits System.Windows.Forms.Form
|
||||
|
||||
#Region " Windows Form Designer generated code "
|
||||
|
||||
Public Sub New(ByVal dataBuffer As MaterialProperties)
|
||||
MyBase.New()
|
||||
|
||||
'This call is required by the Windows Form Designer.
|
||||
InitializeComponent()
|
||||
|
||||
m_dataBuffer = dataBuffer
|
||||
|
||||
End Sub
|
||||
|
||||
'Form overrides dispose to clean up the component list.
|
||||
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
|
||||
If disposing Then
|
||||
If Not (components Is Nothing) Then
|
||||
components.Dispose()
|
||||
End If
|
||||
End If
|
||||
MyBase.Dispose(disposing)
|
||||
End Sub
|
||||
|
||||
'Required by the Windows Form Designer
|
||||
Private components As System.ComponentModel.IContainer
|
||||
|
||||
'NOTE: The following procedure is required by the Windows Form Designer
|
||||
'It can be modified using the Windows Form Designer.
|
||||
'Do not modify it using the code editor.
|
||||
Friend WithEvents changeButton As System.Windows.Forms.Button
|
||||
Friend WithEvents applyButton As System.Windows.Forms.Button
|
||||
Friend WithEvents okButton As System.Windows.Forms.Button
|
||||
Friend WithEvents parameterDataGrid As System.Windows.Forms.DataGrid
|
||||
Friend WithEvents subTypeComboBox As System.Windows.Forms.ComboBox
|
||||
Friend WithEvents typeComboBox As System.Windows.Forms.ComboBox
|
||||
Friend WithEvents typeLable As System.Windows.Forms.Label
|
||||
Friend WithEvents exitButton As System.Windows.Forms.Button
|
||||
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
|
||||
Me.changeButton = New System.Windows.Forms.Button
|
||||
Me.applyButton = New System.Windows.Forms.Button
|
||||
Me.exitButton = New System.Windows.Forms.Button
|
||||
Me.okButton = New System.Windows.Forms.Button
|
||||
Me.parameterDataGrid = New System.Windows.Forms.DataGrid
|
||||
Me.subTypeComboBox = New System.Windows.Forms.ComboBox
|
||||
Me.typeComboBox = New System.Windows.Forms.ComboBox
|
||||
Me.typeLable = New System.Windows.Forms.Label
|
||||
CType(Me.parameterDataGrid, System.ComponentModel.ISupportInitialize).BeginInit()
|
||||
Me.SuspendLayout()
|
||||
'
|
||||
'changeButton
|
||||
'
|
||||
Me.changeButton.Location = New System.Drawing.Point(353, 455)
|
||||
Me.changeButton.Name = "changeButton"
|
||||
Me.changeButton.Size = New System.Drawing.Size(128, 23)
|
||||
Me.changeButton.TabIndex = 16
|
||||
Me.changeButton.Text = "Change &Unit Weight"
|
||||
'
|
||||
'applyButton
|
||||
'
|
||||
Me.applyButton.Location = New System.Drawing.Point(267, 455)
|
||||
Me.applyButton.Name = "applyButton"
|
||||
Me.applyButton.Size = New System.Drawing.Size(75, 23)
|
||||
Me.applyButton.TabIndex = 15
|
||||
Me.applyButton.Text = "&Apply"
|
||||
'
|
||||
'exitButton
|
||||
'
|
||||
Me.exitButton.DialogResult = System.Windows.Forms.DialogResult.Cancel
|
||||
Me.exitButton.Location = New System.Drawing.Point(173, 455)
|
||||
Me.exitButton.Name = "exitButton"
|
||||
Me.exitButton.Size = New System.Drawing.Size(75, 23)
|
||||
Me.exitButton.TabIndex = 14
|
||||
Me.exitButton.Text = "&Cancel"
|
||||
'
|
||||
'okButton
|
||||
'
|
||||
Me.okButton.Location = New System.Drawing.Point(87, 455)
|
||||
Me.okButton.Name = "okButton"
|
||||
Me.okButton.Size = New System.Drawing.Size(75, 23)
|
||||
Me.okButton.TabIndex = 13
|
||||
Me.okButton.Text = "&OK"
|
||||
'
|
||||
'parameterDataGrid
|
||||
'
|
||||
Me.parameterDataGrid.CaptionVisible = False
|
||||
Me.parameterDataGrid.DataMember = ""
|
||||
Me.parameterDataGrid.HeaderForeColor = System.Drawing.SystemColors.ControlText
|
||||
Me.parameterDataGrid.Location = New System.Drawing.Point(12, 69)
|
||||
Me.parameterDataGrid.Name = "parameterDataGrid"
|
||||
Me.parameterDataGrid.ReadOnly = True
|
||||
Me.parameterDataGrid.RowHeadersVisible = False
|
||||
Me.parameterDataGrid.Size = New System.Drawing.Size(480, 380)
|
||||
Me.parameterDataGrid.TabIndex = 12
|
||||
'
|
||||
'subTypeComboBox
|
||||
'
|
||||
Me.subTypeComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList
|
||||
Me.subTypeComboBox.Location = New System.Drawing.Point(100, 42)
|
||||
Me.subTypeComboBox.Name = "subTypeComboBox"
|
||||
Me.subTypeComboBox.Size = New System.Drawing.Size(264, 21)
|
||||
Me.subTypeComboBox.TabIndex = 11
|
||||
'
|
||||
'typeComboBox
|
||||
'
|
||||
Me.typeComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList
|
||||
Me.typeComboBox.Location = New System.Drawing.Point(100, 7)
|
||||
Me.typeComboBox.Name = "typeComboBox"
|
||||
Me.typeComboBox.Size = New System.Drawing.Size(264, 21)
|
||||
Me.typeComboBox.TabIndex = 10
|
||||
'
|
||||
'typeLable
|
||||
'
|
||||
Me.typeLable.Location = New System.Drawing.Point(13, 7)
|
||||
Me.typeLable.Name = "typeLable"
|
||||
Me.typeLable.Size = New System.Drawing.Size(80, 23)
|
||||
Me.typeLable.TabIndex = 9
|
||||
Me.typeLable.Text = "Material Type:"
|
||||
'
|
||||
'MaterialPropertiesForm
|
||||
'
|
||||
Me.AcceptButton = Me.okButton
|
||||
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
|
||||
Me.CancelButton = Me.exitButton
|
||||
Me.ClientSize = New System.Drawing.Size(502, 481)
|
||||
Me.Controls.Add(Me.changeButton)
|
||||
Me.Controls.Add(Me.applyButton)
|
||||
Me.Controls.Add(Me.exitButton)
|
||||
Me.Controls.Add(Me.okButton)
|
||||
Me.Controls.Add(Me.parameterDataGrid)
|
||||
Me.Controls.Add(Me.subTypeComboBox)
|
||||
Me.Controls.Add(Me.typeComboBox)
|
||||
Me.Controls.Add(Me.typeLable)
|
||||
Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog
|
||||
Me.MaximizeBox = False
|
||||
Me.MinimizeBox = False
|
||||
Me.Name = "MaterialPropertiesForm"
|
||||
Me.ShowInTaskbar = False
|
||||
Me.Text = "Material Properties"
|
||||
CType(Me.parameterDataGrid, System.ComponentModel.ISupportInitialize).EndInit()
|
||||
Me.ResumeLayout(False)
|
||||
|
||||
End Sub
|
||||
|
||||
#End Region
|
||||
Dim m_dataBuffer As MaterialProperties = Nothing
|
||||
|
||||
'set selected element's material to current selection and close form
|
||||
Private Sub okButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles okButton.Click
|
||||
If Not (subTypeComboBox.SelectedValue Is Nothing) Then
|
||||
m_dataBuffer.SetMaterial(subTypeComboBox.SelectedValue)
|
||||
End If
|
||||
Me.Close()
|
||||
End Sub
|
||||
|
||||
'close form
|
||||
Private Sub cancelButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles exitButton.Click
|
||||
Me.Close()
|
||||
End Sub
|
||||
|
||||
'set selected element's material to current selection
|
||||
Private Sub applyButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles applyButton.Click
|
||||
If Not (subTypeComboBox.SelectedValue Is Nothing) Then
|
||||
m_dataBuffer.SetMaterial(subTypeComboBox.SelectedValue)
|
||||
End If
|
||||
End Sub
|
||||
|
||||
'change unit weight all instances of the elements that use this material
|
||||
Private Sub changeButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles changeButton.Click
|
||||
Autodesk.Revit.UI.TaskDialog.Show("Revit", "This will change the unit weight of all instances that use this material in current document.")
|
||||
|
||||
If Not (m_dataBuffer.ChangeUnitWeight()) Then
|
||||
Autodesk.Revit.UI.TaskDialog.Show("Revit", "Failed to change the unit weight.")
|
||||
Return
|
||||
End If
|
||||
LoadCurrentMaterial()
|
||||
End Sub
|
||||
|
||||
' when typeComboBox changed, then update the subTypeCombobox
|
||||
Private Sub typeComboBox_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles typeComboBox.SelectedIndexChanged
|
||||
If (CType(typeComboBox.SelectedIndex, StructuralAssetClass) = StructuralAssetClass.Metal) Then
|
||||
applyButton.Enabled = True
|
||||
changeButton.Enabled = True
|
||||
subTypeComboBox.Enabled = True
|
||||
subTypeComboBox.DataSource = m_dataBuffer.SteelCollection
|
||||
subTypeComboBox.DisplayMember = "MaterialName"
|
||||
subTypeComboBox.ValueMember = "Material"
|
||||
parameterDataGrid.DataSource = m_dataBuffer.GetParameterTable(subTypeComboBox.SelectedValue, CType(typeComboBox.SelectedIndex, StructuralAssetClass))
|
||||
ElseIf (CType(typeComboBox.SelectedIndex, StructuralAssetClass) = StructuralAssetClass.Concrete) Then
|
||||
applyButton.Enabled = True
|
||||
changeButton.Enabled = True
|
||||
subTypeComboBox.Enabled = True
|
||||
subTypeComboBox.DataSource = m_dataBuffer.ConcreteCollection
|
||||
subTypeComboBox.DisplayMember = "MaterialName"
|
||||
subTypeComboBox.ValueMember = "Material"
|
||||
parameterDataGrid.DataSource = m_dataBuffer.GetParameterTable(subTypeComboBox.SelectedValue, CType(typeComboBox.SelectedIndex, StructuralAssetClass))
|
||||
Else
|
||||
applyButton.Enabled = False
|
||||
changeButton.Enabled = False
|
||||
subTypeComboBox.DataSource = New ArrayList
|
||||
subTypeComboBox.Enabled = False
|
||||
parameterDataGrid.DataSource = New DataTable
|
||||
End If
|
||||
|
||||
If typeComboBox.SelectedIndex = CInt(m_dataBuffer.CurrentType) Then
|
||||
If (m_dataBuffer.CurrentMaterial Is Nothing Or (m_dataBuffer.CurrentType <> StructuralAssetClass.Metal And m_dataBuffer.CurrentType <> StructuralAssetClass.Concrete)) Then
|
||||
Return
|
||||
End If
|
||||
|
||||
Dim tmp As Autodesk.Revit.DB.Material
|
||||
tmp = m_dataBuffer.CurrentMaterial
|
||||
If (tmp Is Nothing) Then
|
||||
Return
|
||||
End If
|
||||
subTypeComboBox.SelectedValue = tmp
|
||||
parameterDataGrid.DataSource = m_dataBuffer.GetParameterTable(subTypeComboBox.SelectedValue, _
|
||||
CType(typeComboBox.SelectedIndex, StructuralAssetClass))
|
||||
ElseIf subTypeComboBox.Items.Count = 0 Then
|
||||
parameterDataGrid.DataSource = New DataTable
|
||||
End If
|
||||
End Sub
|
||||
|
||||
'change the content in datagrid according to selected material type
|
||||
Private Sub subTypeComboBox_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles subTypeComboBox.SelectedIndexChanged
|
||||
If subTypeComboBox.SelectedValue Is Nothing Then
|
||||
parameterDataGrid.DataSource = New DataTable
|
||||
End If
|
||||
parameterDataGrid.DataSource = m_dataBuffer.GetParameterTable(subTypeComboBox.SelectedValue, CType(typeComboBox.SelectedIndex, StructuralAssetClass))
|
||||
End Sub
|
||||
|
||||
'update display data to selected element's material
|
||||
Private Sub LoadCurrentMaterial()
|
||||
typeComboBox.DataSource = m_dataBuffer.MaterialTypes
|
||||
typeComboBox.SelectedIndex = CInt(m_dataBuffer.CurrentType)
|
||||
If (m_dataBuffer.CurrentMaterial Is Nothing Or (m_dataBuffer.CurrentType <> StructuralAssetClass.Metal And m_dataBuffer.CurrentType <> StructuralAssetClass.Concrete)) Then
|
||||
Return
|
||||
End If
|
||||
|
||||
|
||||
Dim tmp As Autodesk.Revit.DB.Material
|
||||
tmp = m_dataBuffer.CurrentMaterial
|
||||
If (tmp Is Nothing) Then
|
||||
Return
|
||||
End If
|
||||
subTypeComboBox.SelectedValue = tmp
|
||||
parameterDataGrid.DataSource = m_dataBuffer.GetParameterTable(subTypeComboBox.SelectedValue, _
|
||||
CType(typeComboBox.SelectedIndex, StructuralAssetClass))
|
||||
End Sub
|
||||
|
||||
' when the form loading, then load the current material of your selected beam, column or brace
|
||||
Private Sub MaterialPropertiesForm_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
|
||||
parameterDataGrid.PreferredColumnWidth = parameterDataGrid.Width / 2 - 2
|
||||
LoadCurrentMaterial()
|
||||
End Sub
|
||||
End Class
|
||||
Binary file not shown.
Reference in New Issue
Block a user