mirror of
https://github.com/jeremytammik/RevitSdkSamples.git
synced 2026-08-18 03:19:17 +00:00
added Revit 2022 SDK minus except *rvt and *rfa
This commit is contained in:
@@ -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