cleaned up old snapshots

This commit is contained in:
Jeremy Tammik
2024-12-12 10:25:07 +01:00
parent 68ae00cc40
commit abf2f07f8a
13206 changed files with 0 additions and 3608007 deletions
@@ -0,0 +1,55 @@
'
' (C) Copyright 2003-2009 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,539 @@
'
' (C) Copyright 2003-2009 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
Imports Autodesk.Revit.Elements
Imports Autodesk.Revit.Parameters
Imports Autodesk.Revit.Structural.Enums
' All Autodesk Revit external commands must support this interface
'three basic material types in Revit
Public Enum MaterialType
Generic = 0
Concrete
Steel
End Enum
''' <summary>
''' Get the material physical properties of the selecte 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>
Public Class MaterialProperties
Implements Autodesk.Revit.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.Application = 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.Elements.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 MaterialType
Get
Dim materialId As Integer = 0
If Not m_currentMaterial Is Nothing Then
materialId = m_currentMaterial.AsElementId().Value
End If
If materialId <= 0 Then
Return MaterialType.Generic
End If
Dim materialElem As Autodesk.Revit.Elements.Material = _
CType(m_allMaterialMap(materialId), Autodesk.Revit.Elements.Material)
If Nothing Is materialElem Then
Return MaterialType.Generic
End If
Dim materialPara As Parameter = _
materialElem.Parameter(BuiltInParameter.PHY_MATERIAL_PARAM_TYPE)
If Nothing Is materialPara Then
Return MaterialType.Generic
End If
Return CType(materialPara.AsInteger(), MaterialType)
End Get
End Property
'get the material attribute of selected element
ReadOnly Property CurrentMaterial() As Object
Get
Dim materialElem As Autodesk.Revit.Elements.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("Generic")
typeAL.Add("Concrete")
typeAL.Add("Steel")
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 cancelled 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.ExternalCommandData, _
ByRef message As String, _
ByVal elements As Autodesk.Revit.ElementSet) As _
Autodesk.Revit.IExternalCommand.Result Implements Autodesk.Revit.IExternalCommand.Execute
Dim revit As Autodesk.Revit.Application = commandData.Application
m_revit = revit
If Not (Init()) Then
'there must be exactly one beam, column or brace selected
MessageBox.Show("You should select only one beam, structural column or brace.")
Return Autodesk.Revit.IExternalCommand.Result.Failed
End If
Dim displayForm As MaterialPropertiesForm = New MaterialPropertiesForm(Me)
Try
displayForm.ShowDialog()
Catch ex As Exception
MessageBox.Show("Sorry that your command failed.")
Return Autodesk.Revit.IExternalCommand.Result.Failed
End Try
Return Autodesk.Revit.IExternalCommand.Result.Succeeded
End Function
'get a datatable contains parameters' information of certain element
Public Function GetParameterTable(ByVal o As System.Object, _
ByVal substanceKind As MaterialType) As DataTable
'create an empty data table
Dim parameterTable As DataTable = CreateTable()
'if failed to convert object
If TypeOf o Is Autodesk.Revit.Elements.Material Then
Dim material As Autodesk.Revit.Elements.Material = _
CType(o, Autodesk.Revit.Elements.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)
' Damping Ratio
temporaryAttribute = material.Parameter(BuiltInParameter.PHY_MATERIAL_PARAM_DAMPING_RATIO)
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 Strengt
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 = MaterialType.Steel 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 = MaterialType.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.Elements.Material) Then
Dim material As Autodesk.Revit.Elements.Material
material = o
Dim identity As Autodesk.Revit.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.Elements.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.Elements.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().Value
End If
'material has no value
If (identityValue <= 0) Then
Return Nothing
End If
Dim material As Autodesk.Revit.Elements.Material = _
CType(m_allMaterialMap(identityValue), Autodesk.Revit.Elements.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.ActiveDocument.Selection.Elements.Size <> 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 ElementSet = m_revit.ActiveDocument.Selection.Elements
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.Elements.FamilyInstance Then
Dim component As Autodesk.Revit.Elements.FamilyInstance = o
'selection is a beam, column or brace, find out its parameters
If component.StructuralType = StructuralType.Beam _
Or component.StructuralType = StructuralType.Brace _
Or component.StructuralType = 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
If parameterName = "Column Material" Or parameterName = "Beam 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 i As ElementIterator = m_revit.ActiveDocument.Elements
Dim moreValue As Boolean = i.MoveNext()
While moreValue
If TypeOf i.Current Is Autodesk.Revit.Elements.Material Then
Dim material As Autodesk.Revit.Elements.Material = i.Current
Dim materialAttribute As _
Parameter = material.Parameter(BuiltInParameter.PHY_MATERIAL_PARAM_TYPE)
If Not (materialAttribute Is Nothing) Then
'add materials to different ArrayList according to their types
Select Case CType(materialAttribute.AsInteger(), MaterialType)
Case MaterialType.Steel
m_steels.Add(New MaterialMap(material))
Case MaterialType.Concrete
m_concretes.Add(New MaterialMap(material))
Case Else
End Select
'map between materials and their elementId
m_allMaterialMap.Add(material.Id.Value, material)
End If
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
End Class
''' <summary>
''' Assistant class contains material and it's name
''' </summary>
''' <remarks></remarks>
Public Class MaterialMap
Dim m_materialName As String
Dim m_material As Autodesk.Revit.Elements.Material
'constructor without parameter is forbidden
Private Sub New()
End Sub
'constructor
Public Sub New(ByVal material As Autodesk.Revit.Elements.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.Elements.Material
Get
Return m_material
End Get
End Property
End Class
@@ -0,0 +1,130 @@
<Project ToolsVersion="3.5" 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>v3.5</TargetFrameworkVersion>
</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>false</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>false</TreatWarningsAsErrors>
<WarningLevel>1</WarningLevel>
<NoWarn>42016,42017,42018,42019,42032</NoWarn>
<DebugType>none</DebugType>
</PropertyGroup>
<ItemGroup>
<Reference Include="RevitAPI, Version=10.0.0.0, Culture=neutral, processorArchitecture=x86">
<SpecificVersion>False</SpecificVersion>
<HintPath>C:\Program Files\Autodesk Revit Architecture 2010\Program\RevitAPI.dll</HintPath>
<Private>False</Private>
</Reference>
<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="$(MSBuildToolsPath)\Microsoft.VisualBasic.targets" />
<PropertyGroup>
<PreBuildEvent>
</PreBuildEvent>
<PostBuildEvent>
</PostBuildEvent>
</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,285 @@
'
' (C) Copyright 2003-2009 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
'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
MessageBox.Show("This will change unit weight of all instances that use this material.")
If Not (m_dataBuffer.ChangeUnitWeight()) Then
MessageBox.Show("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, MaterialType) = MaterialType.Steel) 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, MaterialType))
ElseIf (CType(typeComboBox.SelectedIndex, MaterialType) = MaterialType.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, MaterialType))
ElseIf (CType(typeComboBox.SelectedIndex, MaterialType) = MaterialType.Generic) Then
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 = MaterialType.Generic) Then
Return
End If
Dim tmp As Autodesk.Revit.Elements.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, MaterialType))
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, MaterialType))
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 = MaterialType.Generic) Then
Return
End If
Dim tmp As Autodesk.Revit.Elements.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, MaterialType))
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
@@ -0,0 +1,6 @@
[ExternalCommands]
ECCount=1
ECName1=Material Properties (VB)
ECClassName1=Revit.SDK.Samples.MaterialProperties.VB.NET.MaterialProperties
ECAssembly1=MaterialProperties.dll
ECDescription1= Get the material physical properties of the selected beam, column or brace.