mirror of
https://github.com/jeremytammik/RevitSdkSamples.git
synced 2026-09-18 10:31:32 +00:00
added Revit 2022 SDK minus except *rvt and *rfa
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
'
|
||||
' (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("A9C2EE87-A679-4703-B07D-D30D1AE84AB0")>
|
||||
|
||||
' 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" encoding="utf-8"?>
|
||||
<RevitAddIns>
|
||||
<AddIn Type="Command">
|
||||
<Assembly>CreateBeamsColumnsBraces.dll</Assembly>
|
||||
<ClientId>f406b5ee-73b9-4e67-ad88-a809d84e2ad6</ClientId>
|
||||
<FullClassName>Revit.SDK.Samples.CreateBeamsColumnsBraces.VB.NET.Command</FullClassName>
|
||||
<Text>Create beams, columns and braces (VB)</Text>
|
||||
<Description>Create beams, columns and braces.</Description>
|
||||
<VisibilityMode>AlwaysVisible</VisibilityMode>
|
||||
<VendorId>ADSK</VendorId>
|
||||
<VendorDescription>Autodesk, www.autodesk.com</VendorDescription>
|
||||
</AddIn>
|
||||
</RevitAddIns>
|
||||
@@ -0,0 +1,475 @@
|
||||
'
|
||||
' (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 ITS 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.IO
|
||||
Imports System.Collections
|
||||
Imports System.Windows.Forms
|
||||
|
||||
Imports Autodesk.Revit
|
||||
Imports Autodesk.Revit.DB.Events
|
||||
Imports Autodesk.Revit.DB
|
||||
Imports Autodesk.Revit.UI
|
||||
Imports Autodesk.Revit.DB.Structure
|
||||
Imports Autodesk.Revit.Creation
|
||||
|
||||
' Create Beams, Columns & Braces according to user's input information
|
||||
<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 Command
|
||||
Implements IExternalCommand 'ToDo: Add Implements Clauses for implementation methods of these interface(s)
|
||||
Private m_revit As Autodesk.Revit.UI.UIApplication = Nothing
|
||||
|
||||
Private m_columnMaps As New ArrayList 'list of columns' type
|
||||
Private m_beamMaps As New ArrayList 'list of beams' type
|
||||
Private m_braceMaps As New ArrayList 'list of braces' type
|
||||
Private levels As New SortedList 'list of list sorted by their elevations
|
||||
Private m_matrixUV(,) As Autodesk.Revit.DB.UV '2D coordinates of matrix
|
||||
|
||||
''' <summary>
|
||||
''' list of all type of columns
|
||||
''' </summary>
|
||||
''' <value></value>
|
||||
''' <returns></returns>
|
||||
''' <remarks></remarks>
|
||||
Public ReadOnly Property ColumnMaps() As ArrayList
|
||||
Get
|
||||
Return m_columnMaps
|
||||
End Get
|
||||
End Property
|
||||
|
||||
''' <summary>
|
||||
''' list of all type of beams
|
||||
''' </summary>
|
||||
''' <value></value>
|
||||
''' <returns></returns>
|
||||
''' <remarks></remarks>
|
||||
Public ReadOnly Property BeamMaps() As ArrayList
|
||||
Get
|
||||
Return m_beamMaps
|
||||
End Get
|
||||
End Property
|
||||
|
||||
''' <summary>
|
||||
''' list of all type of braces
|
||||
''' </summary>
|
||||
''' <value></value>
|
||||
''' <returns></returns>
|
||||
''' <remarks></remarks>
|
||||
Public ReadOnly Property BraceMaps() As ArrayList
|
||||
Get
|
||||
Return m_braceMaps
|
||||
End Get
|
||||
End Property
|
||||
|
||||
''' <summary>
|
||||
''' Implement this method as an external command for Revit.
|
||||
''' </summary>
|
||||
''' <param name="revit">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 revit 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
|
||||
m_revit = revit.Application
|
||||
Dim tran As Autodesk.Revit.DB.Transaction = New Autodesk.Revit.DB.Transaction(m_revit.ActiveUIDocument.Document, "CreateBeamsColumnsBraces")
|
||||
tran.Start()
|
||||
|
||||
Try
|
||||
'if initialize failed return Result.Failed
|
||||
Dim initializeOK As Boolean = Initialize()
|
||||
If Not initializeOK Then
|
||||
tran.RollBack()
|
||||
Return Autodesk.Revit.UI.Result.Failed
|
||||
End If
|
||||
|
||||
Dim displayForm As New CreateBeamsColumnsBracesForm(Me)
|
||||
Using (displayForm)
|
||||
If displayForm.ShowDialog() <> DialogResult.OK Then
|
||||
tran.RollBack()
|
||||
Return Autodesk.Revit.UI.Result.Cancelled
|
||||
End If
|
||||
End Using
|
||||
|
||||
tran.Commit()
|
||||
Return Autodesk.Revit.UI.Result.Succeeded
|
||||
Catch ex As Exception
|
||||
message = ex.Message
|
||||
tran.RollBack()
|
||||
Return Autodesk.Revit.UI.Result.Failed
|
||||
End Try
|
||||
|
||||
End Function
|
||||
|
||||
''' <summary>
|
||||
''' check the number of floors is less than the number of levels,
|
||||
''' create beams, columns abd braces according to selected types
|
||||
''' </summary>
|
||||
''' <param name="columnObject">type of column</param>
|
||||
''' <param name="beamObject">type of beam</param>
|
||||
''' <param name="braceObject">type of brace</param>
|
||||
''' <param name="floorNumber">number of floor</param>
|
||||
''' <returns>number of floors is less than the number of levels and create successfully then return true</returns>
|
||||
''' <remarks></remarks>
|
||||
Public Function AddInstance(ByVal columnObject As Object, ByVal beamObject As Object, ByVal braceObject As Object, ByVal floorNumber As Integer) As Boolean
|
||||
'whether floor number less than levels number
|
||||
If floorNumber >= levels.Count Then
|
||||
Autodesk.Revit.UI.TaskDialog.Show("Revit", "The number of levels must be added.", "Revit")
|
||||
Return False
|
||||
End If
|
||||
|
||||
Dim columnSymbol As Autodesk.Revit.DB.FamilySymbol = Nothing
|
||||
|
||||
If TypeOf columnObject Is Autodesk.Revit.DB.FamilySymbol Then
|
||||
columnSymbol = columnObject
|
||||
End If
|
||||
|
||||
Dim beamSymbol As Autodesk.Revit.DB.FamilySymbol = Nothing
|
||||
If TypeOf beamObject Is Autodesk.Revit.DB.FamilySymbol Then
|
||||
beamSymbol = beamObject
|
||||
End If
|
||||
|
||||
Dim braceSymbol As Autodesk.Revit.DB.FamilySymbol = Nothing
|
||||
If TypeOf braceObject Is Autodesk.Revit.DB.FamilySymbol Then
|
||||
braceSymbol = braceObject
|
||||
End If
|
||||
|
||||
'any symbol is null then the command failed
|
||||
If columnSymbol Is Nothing OrElse beamSymbol Is Nothing OrElse braceSymbol Is Nothing Then
|
||||
Return False
|
||||
End If
|
||||
|
||||
Try
|
||||
|
||||
For k As Integer = 0 To floorNumber - 1 'iterate levels from lower one to higher
|
||||
Dim baseLevel As Autodesk.Revit.DB.Level = levels.GetByIndex(k)
|
||||
Dim topLevel As Autodesk.Revit.DB.Level = levels.GetByIndex((k + 1))
|
||||
|
||||
'place column of this level
|
||||
Dim point2D As Autodesk.Revit.DB.UV
|
||||
For Each point2D In m_matrixUV
|
||||
PlaceColumn(point2D, columnSymbol, baseLevel, topLevel)
|
||||
Next point2D
|
||||
|
||||
Dim matrixXSize As Integer = m_matrixUV.GetLength(0) 'length of matrix's x range
|
||||
Dim matrixYSize As Integer = m_matrixUV.GetLength(1) 'length of matrix's y range
|
||||
'iterate coordinate both in x direction and y direction and create beams and braces
|
||||
For j As Integer = 0 To matrixYSize - 1
|
||||
|
||||
For i As Integer = 0 To matrixXSize - 1
|
||||
'create beams and braces in x direction
|
||||
If i <> matrixXSize - 1 Then
|
||||
PlaceBrace(m_matrixUV(i, j), m_matrixUV(i + 1, j), baseLevel, topLevel, braceSymbol, True)
|
||||
End If
|
||||
'create beams and braces in y direction
|
||||
If j <> matrixYSize - 1 Then
|
||||
PlaceBrace(m_matrixUV(i, j), m_matrixUV(i, j + 1), baseLevel, topLevel, braceSymbol, False)
|
||||
End If
|
||||
Next i
|
||||
Next j
|
||||
|
||||
For j As Integer = 0 To matrixYSize - 1
|
||||
|
||||
For i As Integer = 0 To matrixXSize - 1
|
||||
'create beams and braces in x direction
|
||||
If i <> matrixXSize - 1 Then
|
||||
PlaceBeam(m_matrixUV(i, j), m_matrixUV(i + 1, j), baseLevel, topLevel, beamSymbol)
|
||||
End If
|
||||
'create beams and braces in y direction
|
||||
If j <> matrixYSize - 1 Then
|
||||
PlaceBeam(m_matrixUV(i, j), m_matrixUV(i, j + 1), baseLevel, topLevel, beamSymbol)
|
||||
End If
|
||||
Next i
|
||||
Next j
|
||||
Next k
|
||||
Catch
|
||||
Return False
|
||||
End Try
|
||||
|
||||
Return True
|
||||
End Function
|
||||
|
||||
''' <summary>
|
||||
''' generate 2D coordinates of matrix according to parameters
|
||||
''' </summary>
|
||||
''' <param name="xNumber">Number of Columns in the X direction</param>
|
||||
''' <param name="yNumber">Number of Columns in the Y direction</param>
|
||||
''' <param name="distance">Distance between columns</param>
|
||||
''' <remarks></remarks>
|
||||
Public Sub CreateMatrix(ByVal xNumber As Integer, ByVal yNumber As Integer, ByVal distance As Double)
|
||||
m_matrixUV = New Autodesk.Revit.DB.UV(xNumber - 1, yNumber - 1) {}
|
||||
|
||||
Dim i As Integer
|
||||
For i = 0 To xNumber - 1
|
||||
Dim j As Integer
|
||||
For j = 0 To yNumber - 1
|
||||
m_matrixUV(i, j) = New Autodesk.Revit.DB.UV(i * distance, j * distance)
|
||||
Next j
|
||||
Next i
|
||||
End Sub
|
||||
|
||||
''' <summary>
|
||||
''' iterate all the symbols of levels, columns, beams and braces
|
||||
''' </summary>
|
||||
''' <returns>A value that signifies if the initialization was successful for true or failed for false</returns>
|
||||
''' <remarks></remarks>
|
||||
Private Function Initialize() As Boolean
|
||||
Try
|
||||
'get elements in the document which type == Level or type == Family
|
||||
Dim filter1 As Autodesk.Revit.DB.ElementClassFilter
|
||||
Dim filter2 As Autodesk.Revit.DB.ElementClassFilter
|
||||
filter1 = New Autodesk.Revit.DB.ElementClassFilter(GetType(Autodesk.Revit.DB.Level))
|
||||
filter2 = New Autodesk.Revit.DB.ElementClassFilter(GetType(Autodesk.Revit.DB.Family))
|
||||
Dim orFilter As Autodesk.Revit.DB.LogicalOrFilter
|
||||
orFilter = New Autodesk.Revit.DB.LogicalOrFilter(filter1, filter2)
|
||||
Dim collector As Autodesk.Revit.DB.FilteredElementCollector
|
||||
collector = New Autodesk.Revit.DB.FilteredElementCollector(m_revit.ActiveUIDocument.Document)
|
||||
collector.WherePasses(orFilter)
|
||||
Dim i As IEnumerator
|
||||
i = collector.GetElementIterator
|
||||
|
||||
i.Reset()
|
||||
Dim moreElement As Boolean = i.MoveNext()
|
||||
While moreElement
|
||||
Dim o As Object = i.Current
|
||||
|
||||
'add level to list
|
||||
Dim level As Autodesk.Revit.DB.Level
|
||||
level = Nothing
|
||||
If TypeOf o Is Autodesk.Revit.DB.Level Then
|
||||
level = CType(o, Autodesk.Revit.DB.Level)
|
||||
End If '
|
||||
|
||||
If Not (level Is Nothing) Then
|
||||
levels.Add(level.Elevation, level)
|
||||
GoTo nextLoop
|
||||
End If
|
||||
|
||||
Dim f As Autodesk.Revit.DB.Family = Nothing
|
||||
If TypeOf o Is Autodesk.Revit.DB.Family Then
|
||||
f = o
|
||||
End If
|
||||
|
||||
If f Is Nothing Then
|
||||
GoTo nextLoop
|
||||
End If
|
||||
|
||||
Dim symbol As Object
|
||||
Dim symbolId As ElementId
|
||||
For Each symbolId In f.GetFamilySymbolIds()
|
||||
symbol = m_revit.ActiveUIDocument.Document.GetElement(symbolId)
|
||||
Dim familyType As Autodesk.Revit.DB.FamilySymbol = symbol '
|
||||
|
||||
If familyType Is Nothing Then
|
||||
GoTo nextLoop
|
||||
End If
|
||||
If familyType.Category Is Nothing Then
|
||||
GoTo nextLoop
|
||||
End If
|
||||
|
||||
'add symbols of beams and braces to lists
|
||||
Dim categoryName As String = familyType.Category.Name
|
||||
If "Structural Framing" = categoryName Then
|
||||
m_beamMaps.Add(New SymbolMap(familyType))
|
||||
m_braceMaps.Add(New SymbolMap(familyType))
|
||||
ElseIf "Structural Columns" = categoryName Then
|
||||
m_columnMaps.Add(New SymbolMap(familyType))
|
||||
End If
|
||||
Next symbolId
|
||||
nextLoop:
|
||||
moreElement = i.MoveNext()
|
||||
End While
|
||||
Catch
|
||||
Return False
|
||||
End Try
|
||||
Return True
|
||||
End Function
|
||||
|
||||
''' <summary>
|
||||
''' create column of certain type in certain position
|
||||
''' </summary>
|
||||
''' <param name="point2D">2D coordinate of the col umn</param>
|
||||
''' <param name="columnType">type of column</param>
|
||||
''' <param name="baseLevel">the base level of the column</param>
|
||||
''' <param name="topLevel">the top level of the column</param>
|
||||
''' <remarks></remarks>
|
||||
Private Sub PlaceColumn(ByVal point2D As Autodesk.Revit.DB.UV, ByVal columnType As Autodesk.Revit.DB.FamilySymbol, ByVal baseLevel As Autodesk.Revit.DB.Level, ByVal topLevel As Autodesk.Revit.DB.Level)
|
||||
'create column of certain type in certain level and start point
|
||||
Dim point As New Autodesk.Revit.DB.XYZ(point2D.U, point2D.V, 0)
|
||||
Dim structuralType As Autodesk.Revit.DB.Structure.StructuralType
|
||||
structuralType = Autodesk.Revit.DB.Structure.StructuralType.Column
|
||||
If Not (columnType.IsActive) Then
|
||||
columnType.Activate()
|
||||
End If
|
||||
Dim column As Autodesk.Revit.DB.FamilyInstance = m_revit.ActiveUIDocument.Document.Create.NewFamilyInstance(point, columnType, topLevel, structuralType)
|
||||
|
||||
'set baselevel & toplevel of the column
|
||||
If Not (column Is Nothing) Then
|
||||
Dim baseLevelParameter As Parameter = column.Parameter(Autodesk.Revit.DB.BuiltInParameter.FAMILY_BASE_LEVEL_PARAM)
|
||||
Dim topLevelParameter As Parameter = column.Parameter(Autodesk.Revit.DB.BuiltInParameter.FAMILY_TOP_LEVEL_PARAM)
|
||||
Dim topOffsetParameter As Parameter = column.Parameter(BuiltInParameter.FAMILY_TOP_LEVEL_OFFSET_PARAM)
|
||||
Dim baseOffsetParameter As Parameter = column.Parameter(BuiltInParameter.FAMILY_BASE_LEVEL_OFFSET_PARAM)
|
||||
|
||||
If Not (baseLevelParameter Is Nothing) Then
|
||||
Dim baseLevelId As Autodesk.Revit.DB.ElementId
|
||||
baseLevelId = baseLevel.Id
|
||||
baseLevelParameter.Set(baseLevelId)
|
||||
End If
|
||||
|
||||
If Not (topLevelParameter Is Nothing) Then
|
||||
Dim topLevelId As Autodesk.Revit.DB.ElementId
|
||||
topLevelId = topLevel.Id
|
||||
topLevelParameter.Set(topLevelId)
|
||||
End If
|
||||
|
||||
If Not (topOffsetParameter Is Nothing) Then
|
||||
topOffsetParameter.Set(0.0)
|
||||
End If
|
||||
|
||||
If Not (baseOffsetParameter Is Nothing) Then
|
||||
baseOffsetParameter.Set(0.0)
|
||||
End If
|
||||
End If
|
||||
End Sub
|
||||
|
||||
''' <summary>
|
||||
''' create beam of certain type in certain position
|
||||
''' </summary>
|
||||
''' <param name="point2D1">one point of the location line in 2D</param>
|
||||
''' <param name="point2D2">another point of the location line in 2D</param>
|
||||
''' <param name="baseLevel">the base level of the beam</param>
|
||||
''' <param name="topLevel">the top level of the beam</param>
|
||||
''' <param name="beamType">type of beam</param>
|
||||
''' <remarks></remarks>
|
||||
Private Sub PlaceBeam(ByVal point2D1 As Autodesk.Revit.DB.UV, ByVal point2D2 As Autodesk.Revit.DB.UV, ByVal baseLevel As Autodesk.Revit.DB.Level, ByVal topLevel As Autodesk.Revit.DB.Level, ByVal beamType As Autodesk.Revit.DB.FamilySymbol)
|
||||
Dim height As Double = topLevel.Elevation
|
||||
Dim startPoint As New Autodesk.Revit.DB.XYZ(point2D1.U, point2D1.V, height)
|
||||
Dim endPoint As New Autodesk.Revit.DB.XYZ(point2D2.U, point2D2.V, height)
|
||||
Dim line As Line = Autodesk.Revit.DB.Line.CreateBound(startPoint, endPoint)
|
||||
Dim structuralType As Autodesk.Revit.DB.Structure.StructuralType = Autodesk.Revit.DB.Structure.StructuralType.Beam
|
||||
If Not (beamType.IsActive) Then
|
||||
beamType.Activate()
|
||||
End If
|
||||
m_revit.ActiveUIDocument.Document.Create.NewFamilyInstance(line, beamType, topLevel, structuralType)
|
||||
End Sub
|
||||
|
||||
''' <summary>
|
||||
''' create brace of certain type in certain position between two adjacent columns
|
||||
''' </summary>
|
||||
''' <param name="point2D1">one point of the location line in 2D</param>
|
||||
''' <param name="point2D2">another point of the location line in 2D</param>
|
||||
''' <param name="baseLevel">the base level of the brace</param>
|
||||
''' <param name="topLevel">the top level of the brace</param>
|
||||
''' <param name="braceType">type of beam</param>
|
||||
''' <param name="isXDirection">whether the location line is in x direction</param>
|
||||
''' <remarks></remarks>
|
||||
Private Sub PlaceBrace(ByVal point2D1 As Autodesk.Revit.DB.UV, ByVal point2D2 As Autodesk.Revit.DB.UV, ByVal baseLevel As Autodesk.Revit.DB.Level, ByVal topLevel As Autodesk.Revit.DB.Level, ByVal braceType As Autodesk.Revit.DB.FamilySymbol, ByVal isXDirection As Boolean)
|
||||
'get the start points and end points of location lines of two braces
|
||||
Dim topHeight As Double = topLevel.Elevation
|
||||
Dim baseHeight As Double = baseLevel.Elevation
|
||||
Dim middleElevation As Double = (topHeight + baseHeight) / 2
|
||||
Dim middleHeight As Double = (topHeight + baseHeight) / 2
|
||||
Dim startPoint As New Autodesk.Revit.DB.XYZ(point2D1.U, point2D1.V, middleElevation)
|
||||
Dim endPoint As New Autodesk.Revit.DB.XYZ(point2D2.U, point2D2.V, middleElevation)
|
||||
Dim middlePoint As Autodesk.Revit.DB.XYZ
|
||||
If isXDirection Then
|
||||
middlePoint = New Autodesk.Revit.DB.XYZ((point2D1.U + point2D2.U) / 2, point2D2.V, topHeight)
|
||||
Else
|
||||
middlePoint = New Autodesk.Revit.DB.XYZ(point2D2.U, (point2D1.V + point2D2.V) / 2, topHeight)
|
||||
End If
|
||||
|
||||
'create two brace and set their location line
|
||||
Dim structuralType As Autodesk.Revit.DB.Structure.StructuralType = Autodesk.Revit.DB.Structure.StructuralType.Brace
|
||||
Dim levelId As Autodesk.Revit.DB.ElementId = topLevel.Id
|
||||
Dim startLevelId As Autodesk.Revit.DB.ElementId = baseLevel.Id
|
||||
Dim endLevelId As Autodesk.Revit.DB.ElementId = topLevel.Id
|
||||
Dim line1 As Line = Autodesk.Revit.DB.Line.CreateBound(startPoint, middlePoint)
|
||||
If Not (braceType.IsActive) Then
|
||||
braceType.Activate()
|
||||
End If
|
||||
Dim firstBrace As Autodesk.Revit.DB.FamilyInstance = m_revit.ActiveUIDocument.Document.Create.NewFamilyInstance(line1, braceType, baseLevel, structuralType)
|
||||
|
||||
Dim referenceLevel1 As Parameter = firstBrace.Parameter(BuiltInParameter.INSTANCE_REFERENCE_LEVEL_PARAM)
|
||||
If Not (referenceLevel1 Is Nothing) Then
|
||||
referenceLevel1.Set(levelId)
|
||||
End If
|
||||
|
||||
Dim line2 As Line = Autodesk.Revit.DB.Line.CreateBound(endPoint, middlePoint)
|
||||
Dim secondBrace As Autodesk.Revit.DB.FamilyInstance = m_revit.ActiveUIDocument.Document.Create.NewFamilyInstance(line2, braceType, baseLevel, structuralType)
|
||||
|
||||
Dim referenceLevel2 As Parameter = secondBrace.Parameter(BuiltInParameter.INSTANCE_REFERENCE_LEVEL_PARAM)
|
||||
If Not (referenceLevel2 Is Nothing) Then
|
||||
referenceLevel2.Set(levelId)
|
||||
End If
|
||||
End Sub
|
||||
End Class
|
||||
|
||||
''' <summary>
|
||||
''' assistant class contains the symbol and its name
|
||||
''' </summary>
|
||||
''' <remarks></remarks>
|
||||
Public Class SymbolMap
|
||||
Private m_symbolName As String = ""
|
||||
Private m_symbol As Autodesk.Revit.DB.FamilySymbol = Nothing
|
||||
|
||||
''' <summary>
|
||||
''' constructor without parameter is forbidden
|
||||
''' </summary>
|
||||
''' <remarks></remarks>
|
||||
Private Sub New()
|
||||
End Sub
|
||||
|
||||
''' <summary>
|
||||
''' constructor
|
||||
''' </summary>
|
||||
''' <param name="symbol">family symbol</param>
|
||||
''' <remarks></remarks>
|
||||
Public Sub New(ByVal symbol As Autodesk.Revit.DB.FamilySymbol)
|
||||
m_symbol = symbol
|
||||
Dim familyName As String = ""
|
||||
If Not (symbol.Family Is Nothing) Then
|
||||
familyName = symbol.Family.Name
|
||||
End If
|
||||
m_symbolName = familyName + " : " + symbol.Name
|
||||
End Sub
|
||||
|
||||
Public ReadOnly Property SymbolName() As String
|
||||
Get
|
||||
Return m_symbolName
|
||||
End Get
|
||||
End Property
|
||||
|
||||
Public ReadOnly Property ElementType() As Autodesk.Revit.DB.FamilySymbol
|
||||
Get
|
||||
Return m_symbol
|
||||
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>{66A80C53-6DD3-4826-A7C3-426B22F9DF62}</ProjectGuid>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ApplicationIcon>
|
||||
</ApplicationIcon>
|
||||
<AssemblyKeyContainerName>
|
||||
</AssemblyKeyContainerName>
|
||||
<AssemblyName>CreateBeamsColumnsBraces</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.CreateBeamsColumnsBraces.VB.NET</RootNamespace>
|
||||
<StartupObject>Revit.SDK.Samples.CreateBeamsColumnsBraces.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>CreateBeamsColumnsBraces.xml</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>CreateBeamsColumnsBraces.xml</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>
|
||||
<DocumentationFile>CreateBeamsColumnsBraces.xml</DocumentationFile>
|
||||
<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>
|
||||
<DocumentationFile>CreateBeamsColumnsBraces.xml</DocumentationFile>
|
||||
<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="CreateBeamsColumnsBraces.vb">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="CreateBeamsColumnsBracesForm.vb">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<EmbeddedResource Include="CreateBeamsColumnsBracesForm.resx">
|
||||
<DependentUpon>CreateBeamsColumnsBracesForm.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,429 @@
|
||||
'
|
||||
' (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 ITS 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.Windows.Forms
|
||||
|
||||
Public Class CreateBeamsColumnsBracesForm
|
||||
Inherits System.Windows.Forms.Form
|
||||
|
||||
#Region " Windows Form Designer generated code "
|
||||
|
||||
Public Sub New()
|
||||
MyBase.New()
|
||||
|
||||
'This call is required by the Windows Form Designer.
|
||||
InitializeComponent()
|
||||
|
||||
'Add any initialization after the InitializeComponent() call
|
||||
|
||||
End Sub
|
||||
|
||||
Private m_dataBuffer As Command = Nothing
|
||||
|
||||
Public Sub New(ByVal dataBuffer As Command)
|
||||
'
|
||||
' Required for Windows Form Designer support
|
||||
'
|
||||
InitializeComponent()
|
||||
|
||||
m_dataBuffer = dataBuffer
|
||||
End Sub 'New
|
||||
|
||||
'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 floornumberTextBox As System.Windows.Forms.TextBox
|
||||
Friend WithEvents DistanceTextBox As System.Windows.Forms.TextBox
|
||||
Friend WithEvents YTextBox As System.Windows.Forms.TextBox
|
||||
Friend WithEvents XTextBox As System.Windows.Forms.TextBox
|
||||
Friend WithEvents braceComboBox As System.Windows.Forms.ComboBox
|
||||
Friend WithEvents beamComboBox As System.Windows.Forms.ComboBox
|
||||
Friend WithEvents columnComboBox As System.Windows.Forms.ComboBox
|
||||
Friend WithEvents OKButton As System.Windows.Forms.Button
|
||||
Friend WithEvents cancelButton1 As System.Windows.Forms.Button
|
||||
Friend WithEvents floornumberLabel As System.Windows.Forms.Label
|
||||
Friend WithEvents XLabel As System.Windows.Forms.Label
|
||||
Friend WithEvents YLabel As System.Windows.Forms.Label
|
||||
Friend WithEvents DistanceLabel As System.Windows.Forms.Label
|
||||
Friend WithEvents braceLabel As System.Windows.Forms.Label
|
||||
Friend WithEvents beamLabel As System.Windows.Forms.Label
|
||||
Friend WithEvents columnLabel As System.Windows.Forms.Label
|
||||
Friend WithEvents unitLabel As System.Windows.Forms.Label
|
||||
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
|
||||
Me.cancelButton1 = New System.Windows.Forms.Button
|
||||
Me.floornumberLabel = New System.Windows.Forms.Label
|
||||
Me.XLabel = New System.Windows.Forms.Label
|
||||
Me.YLabel = New System.Windows.Forms.Label
|
||||
Me.DistanceLabel = New System.Windows.Forms.Label
|
||||
Me.floornumberTextBox = New System.Windows.Forms.TextBox
|
||||
Me.DistanceTextBox = New System.Windows.Forms.TextBox
|
||||
Me.YTextBox = New System.Windows.Forms.TextBox
|
||||
Me.XTextBox = New System.Windows.Forms.TextBox
|
||||
Me.braceLabel = New System.Windows.Forms.Label
|
||||
Me.beamLabel = New System.Windows.Forms.Label
|
||||
Me.columnLabel = New System.Windows.Forms.Label
|
||||
Me.braceComboBox = New System.Windows.Forms.ComboBox
|
||||
Me.beamComboBox = New System.Windows.Forms.ComboBox
|
||||
Me.columnComboBox = New System.Windows.Forms.ComboBox
|
||||
Me.OKButton = New System.Windows.Forms.Button
|
||||
Me.unitLabel = New System.Windows.Forms.Label
|
||||
Me.SuspendLayout()
|
||||
'
|
||||
'cancelButton1
|
||||
'
|
||||
Me.cancelButton1.DialogResult = System.Windows.Forms.DialogResult.Cancel
|
||||
Me.cancelButton1.Location = New System.Drawing.Point(376, 207)
|
||||
Me.cancelButton1.Name = "cancelButton1"
|
||||
Me.cancelButton1.Size = New System.Drawing.Size(75, 23)
|
||||
Me.cancelButton1.TabIndex = 9
|
||||
Me.cancelButton1.Text = "&Cancel"
|
||||
'
|
||||
'floornumberLabel
|
||||
'
|
||||
Me.floornumberLabel.Location = New System.Drawing.Point(16, 183)
|
||||
Me.floornumberLabel.Name = "floornumberLabel"
|
||||
Me.floornumberLabel.Size = New System.Drawing.Size(144, 23)
|
||||
Me.floornumberLabel.TabIndex = 33
|
||||
Me.floornumberLabel.Text = "Number of Floors:"
|
||||
'
|
||||
'XLabel
|
||||
'
|
||||
Me.XLabel.Location = New System.Drawing.Point(16, 71)
|
||||
Me.XLabel.Name = "XLabel"
|
||||
Me.XLabel.Size = New System.Drawing.Size(200, 23)
|
||||
Me.XLabel.TabIndex = 32
|
||||
Me.XLabel.Text = "Number of Columns in the X Direction:"
|
||||
'
|
||||
'YLabel
|
||||
'
|
||||
Me.YLabel.Location = New System.Drawing.Point(16, 127)
|
||||
Me.YLabel.Name = "YLabel"
|
||||
Me.YLabel.Size = New System.Drawing.Size(200, 23)
|
||||
Me.YLabel.TabIndex = 31
|
||||
Me.YLabel.Text = "Number of Columns in the Y Direction:"
|
||||
'
|
||||
'DistanceLabel
|
||||
'
|
||||
Me.DistanceLabel.Location = New System.Drawing.Point(16, 15)
|
||||
Me.DistanceLabel.Name = "DistanceLabel"
|
||||
Me.DistanceLabel.Size = New System.Drawing.Size(152, 23)
|
||||
Me.DistanceLabel.TabIndex = 10
|
||||
Me.DistanceLabel.Text = "Distance between Columns:"
|
||||
'
|
||||
'floornumberTextBox
|
||||
'
|
||||
Me.floornumberTextBox.Location = New System.Drawing.Point(16, 207)
|
||||
Me.floornumberTextBox.Name = "floornumberTextBox"
|
||||
Me.floornumberTextBox.Size = New System.Drawing.Size(112, 20)
|
||||
Me.floornumberTextBox.TabIndex = 4
|
||||
Me.floornumberTextBox.Text = "1"
|
||||
'
|
||||
'DistanceTextBox
|
||||
'
|
||||
Me.DistanceTextBox.Location = New System.Drawing.Point(16, 39)
|
||||
Me.DistanceTextBox.Name = "DistanceTextBox"
|
||||
Me.DistanceTextBox.Size = New System.Drawing.Size(136, 20)
|
||||
Me.DistanceTextBox.TabIndex = 1
|
||||
Me.DistanceTextBox.Text = 20.0.ToString("0.0")
|
||||
'
|
||||
'YTextBox
|
||||
'
|
||||
Me.YTextBox.Location = New System.Drawing.Point(16, 151)
|
||||
Me.YTextBox.Name = "YTextBox"
|
||||
Me.YTextBox.Size = New System.Drawing.Size(136, 20)
|
||||
Me.YTextBox.TabIndex = 3
|
||||
Me.YTextBox.Text = "2"
|
||||
'
|
||||
'XTextBox
|
||||
'
|
||||
Me.XTextBox.Location = New System.Drawing.Point(16, 95)
|
||||
Me.XTextBox.Name = "XTextBox"
|
||||
Me.XTextBox.Size = New System.Drawing.Size(136, 20)
|
||||
Me.XTextBox.TabIndex = 2
|
||||
Me.XTextBox.Text = "2"
|
||||
'
|
||||
'braceLabel
|
||||
'
|
||||
Me.braceLabel.Location = New System.Drawing.Point(240, 127)
|
||||
Me.braceLabel.Name = "braceLabel"
|
||||
Me.braceLabel.Size = New System.Drawing.Size(120, 23)
|
||||
Me.braceLabel.TabIndex = 28
|
||||
Me.braceLabel.Text = "Type of Braces:"
|
||||
'
|
||||
'beamLabel
|
||||
'
|
||||
Me.beamLabel.Location = New System.Drawing.Point(240, 71)
|
||||
Me.beamLabel.Name = "beamLabel"
|
||||
Me.beamLabel.Size = New System.Drawing.Size(120, 23)
|
||||
Me.beamLabel.TabIndex = 27
|
||||
Me.beamLabel.Text = "Type of Beams:"
|
||||
'
|
||||
'columnLabel
|
||||
'
|
||||
Me.columnLabel.Location = New System.Drawing.Point(240, 15)
|
||||
Me.columnLabel.Name = "columnLabel"
|
||||
Me.columnLabel.Size = New System.Drawing.Size(120, 23)
|
||||
Me.columnLabel.TabIndex = 26
|
||||
Me.columnLabel.Text = "Type of Columns:"
|
||||
'
|
||||
'braceComboBox
|
||||
'
|
||||
Me.braceComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList
|
||||
Me.braceComboBox.Location = New System.Drawing.Point(240, 151)
|
||||
Me.braceComboBox.Name = "braceComboBox"
|
||||
Me.braceComboBox.Size = New System.Drawing.Size(288, 21)
|
||||
Me.braceComboBox.TabIndex = 7
|
||||
'
|
||||
'beamComboBox
|
||||
'
|
||||
Me.beamComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList
|
||||
Me.beamComboBox.Location = New System.Drawing.Point(240, 95)
|
||||
Me.beamComboBox.Name = "beamComboBox"
|
||||
Me.beamComboBox.Size = New System.Drawing.Size(288, 21)
|
||||
Me.beamComboBox.TabIndex = 6
|
||||
'
|
||||
'columnComboBox
|
||||
'
|
||||
Me.columnComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList
|
||||
Me.columnComboBox.Location = New System.Drawing.Point(240, 39)
|
||||
Me.columnComboBox.Name = "columnComboBox"
|
||||
Me.columnComboBox.Size = New System.Drawing.Size(288, 21)
|
||||
Me.columnComboBox.TabIndex = 5
|
||||
'
|
||||
'OKButton
|
||||
'
|
||||
Me.OKButton.DialogResult = System.Windows.Forms.DialogResult.OK
|
||||
Me.OKButton.Location = New System.Drawing.Point(280, 208)
|
||||
Me.OKButton.Name = "OKButton"
|
||||
Me.OKButton.Size = New System.Drawing.Size(75, 23)
|
||||
Me.OKButton.TabIndex = 8
|
||||
Me.OKButton.Text = "&OK"
|
||||
'
|
||||
'unitLabel
|
||||
'
|
||||
Me.unitLabel.Location = New System.Drawing.Point(158, 40)
|
||||
Me.unitLabel.Name = "unitLabel"
|
||||
Me.unitLabel.Size = New System.Drawing.Size(24, 16)
|
||||
Me.unitLabel.TabIndex = 34
|
||||
Me.unitLabel.Text = "feet"
|
||||
'
|
||||
'CreateBeamsColumnsBracesForm
|
||||
'
|
||||
Me.AcceptButton = Me.OKButton
|
||||
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
|
||||
Me.CancelButton = Me.cancelButton1
|
||||
Me.ClientSize = New System.Drawing.Size(544, 244)
|
||||
Me.Controls.Add(Me.unitLabel)
|
||||
Me.Controls.Add(Me.cancelButton1)
|
||||
Me.Controls.Add(Me.floornumberLabel)
|
||||
Me.Controls.Add(Me.XLabel)
|
||||
Me.Controls.Add(Me.YLabel)
|
||||
Me.Controls.Add(Me.DistanceLabel)
|
||||
Me.Controls.Add(Me.floornumberTextBox)
|
||||
Me.Controls.Add(Me.DistanceTextBox)
|
||||
Me.Controls.Add(Me.YTextBox)
|
||||
Me.Controls.Add(Me.XTextBox)
|
||||
Me.Controls.Add(Me.braceLabel)
|
||||
Me.Controls.Add(Me.beamLabel)
|
||||
Me.Controls.Add(Me.columnLabel)
|
||||
Me.Controls.Add(Me.braceComboBox)
|
||||
Me.Controls.Add(Me.beamComboBox)
|
||||
Me.Controls.Add(Me.columnComboBox)
|
||||
Me.Controls.Add(Me.OKButton)
|
||||
Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog
|
||||
Me.MaximizeBox = False
|
||||
Me.MinimizeBox = False
|
||||
Me.Name = "CreateBeamsColumnsBracesForm"
|
||||
Me.ShowInTaskbar = False
|
||||
Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
|
||||
Me.Text = "Create Beams Columns and Braces"
|
||||
Me.ResumeLayout(False)
|
||||
Me.PerformLayout()
|
||||
|
||||
End Sub
|
||||
|
||||
#End Region
|
||||
|
||||
Private Sub CreateBeamsColumnsBracesForm_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
|
||||
Dim notLoadSymbol As Boolean = False
|
||||
|
||||
If 0 = m_dataBuffer.ColumnMaps.Count Then
|
||||
Autodesk.Revit.UI.TaskDialog.Show("Revit", "No Structural Columns family is loaded in the project, please load one firstly.")
|
||||
notLoadSymbol = True
|
||||
End If
|
||||
|
||||
If 0 = m_dataBuffer.BeamMaps.Count Then
|
||||
Autodesk.Revit.UI.TaskDialog.Show("Revit", "No Structural Framing family is loaded in the project, please load one firstly.")
|
||||
notLoadSymbol = True
|
||||
End If
|
||||
|
||||
If notLoadSymbol Then
|
||||
Me.Close()
|
||||
Return
|
||||
End If
|
||||
|
||||
Me.columnComboBox.DataSource = m_dataBuffer.ColumnMaps
|
||||
Me.columnComboBox.DisplayMember = "SymbolName"
|
||||
Me.columnComboBox.ValueMember = "ElementType"
|
||||
|
||||
Me.beamComboBox.DataSource = m_dataBuffer.BeamMaps
|
||||
Me.beamComboBox.DisplayMember = "SymbolName"
|
||||
Me.beamComboBox.ValueMember = "ElementType"
|
||||
|
||||
Me.braceComboBox.DataSource = m_dataBuffer.BraceMaps
|
||||
Me.braceComboBox.DisplayMember = "SymbolName"
|
||||
Me.braceComboBox.ValueMember = "ElementType"
|
||||
End Sub
|
||||
|
||||
''' <summary>
|
||||
''' accept use's input and create columns, beams and braces
|
||||
''' </summary>
|
||||
''' <param name="sender"></param>
|
||||
''' <param name="e"></param>
|
||||
''' <remarks></remarks>
|
||||
Private Sub OKButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles OKButton.Click
|
||||
'check whether the input is correct and create elements
|
||||
Try
|
||||
Dim xNumber As Integer = Integer.Parse(Me.XTextBox.Text)
|
||||
Dim yNumber As Integer = Integer.Parse(Me.YTextBox.Text)
|
||||
Dim distance As Double = Double.Parse(Me.DistanceTextBox.Text)
|
||||
Dim columnType As Object = columnComboBox.SelectedValue
|
||||
Dim beamType As Object = beamComboBox.SelectedValue
|
||||
Dim braceType As Object = braceComboBox.SelectedValue
|
||||
Dim floorNumber As Integer = Integer.Parse(floornumberTextBox.Text)
|
||||
|
||||
m_dataBuffer.CreateMatrix(xNumber, yNumber, distance)
|
||||
m_dataBuffer.AddInstance(columnType, beamType, braceType, floorNumber)
|
||||
|
||||
Catch
|
||||
Autodesk.Revit.UI.TaskDialog.Show("Revit", "Please input datas correctly.")
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
''' <summary>
|
||||
''' cancel the command
|
||||
''' </summary>
|
||||
''' <param name="sender"></param>
|
||||
''' <param name="e"></param>
|
||||
''' <remarks></remarks>
|
||||
Private Sub cancelButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cancelButton1.Click
|
||||
End Sub
|
||||
|
||||
''' <summary>
|
||||
''' verify the distance
|
||||
''' </summary>
|
||||
''' <param name="sender"></param>
|
||||
''' <param name="e"></param>
|
||||
''' <remarks></remarks>
|
||||
Private Sub DistanceTextBox_Validating(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles DistanceTextBox.Validating
|
||||
Try
|
||||
Dim distance As Double = Double.Parse(DistanceTextBox.Text)
|
||||
|
||||
If distance <= 5 Then
|
||||
Autodesk.Revit.UI.TaskDialog.Show("Revit", "Please enter a value larger than 5.")
|
||||
DistanceTextBox.Text = ""
|
||||
DistanceTextBox.Focus()
|
||||
End If
|
||||
|
||||
If distance > 30000 Then
|
||||
Autodesk.Revit.UI.TaskDialog.Show("Revit", "Please enter a value less than 30000.")
|
||||
DistanceTextBox.Text = ""
|
||||
DistanceTextBox.Focus()
|
||||
End If
|
||||
|
||||
Catch ex As Exception
|
||||
Autodesk.Revit.UI.TaskDialog.Show("Revit", "Please enter a value larger than 5 and less than 30000.")
|
||||
DistanceTextBox.Text = ""
|
||||
DistanceTextBox.Focus()
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
''' <summary>
|
||||
''' verify the number of X direction
|
||||
''' </summary>
|
||||
''' <param name="sender"></param>
|
||||
''' <param name="e"></param>
|
||||
''' <remarks></remarks>
|
||||
Private Sub XTextBox_Validating(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles XTextBox.Validating
|
||||
Try
|
||||
Dim xNumber As Integer = Integer.Parse(XTextBox.Text)
|
||||
If xNumber < 1 Or xNumber > 20 Then
|
||||
Autodesk.Revit.UI.TaskDialog.Show("Revit", "Please input an integer for X direction between 1 to 20.")
|
||||
XTextBox.Text = ""
|
||||
End If
|
||||
Catch ex As Exception
|
||||
Autodesk.Revit.UI.TaskDialog.Show("Revit", "Please input an integer for X direction between 1 to 20.")
|
||||
XTextBox.Text = ""
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
''' <summary>
|
||||
''' verify the number of Y direction
|
||||
''' </summary>
|
||||
''' <param name="sender"></param>
|
||||
''' <param name="e"></param>
|
||||
''' <remarks></remarks>
|
||||
Private Sub YTextBox_Validating(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles YTextBox.Validating
|
||||
Try
|
||||
Dim yNumber As Integer = Integer.Parse(YTextBox.Text)
|
||||
If yNumber < 1 Or yNumber > 20 Then
|
||||
Autodesk.Revit.UI.TaskDialog.Show("Revit", "Please input an integer for Y direction between 1 to 20.")
|
||||
YTextBox.Text = ""
|
||||
End If
|
||||
Catch ex As Exception
|
||||
Autodesk.Revit.UI.TaskDialog.Show("Revit", "Please input an integer for Y direction between 1 to 20.")
|
||||
YTextBox.Text = ""
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
''' <summary>
|
||||
''' verify the number of floors
|
||||
''' </summary>
|
||||
''' <param name="sender"></param>
|
||||
''' <param name="e"></param>
|
||||
''' <remarks></remarks>
|
||||
Private Sub floornumberTextBox_Validating(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles floornumberTextBox.Validating
|
||||
Try
|
||||
Dim floorNumber As Integer = Integer.Parse(floornumberTextBox.Text)
|
||||
If floorNumber < 1 Or floorNumber > 10 Then
|
||||
Autodesk.Revit.UI.TaskDialog.Show("Revit", "Please input an integer for the number of floors between 1 to 10.")
|
||||
floornumberTextBox.Text = ""
|
||||
End If
|
||||
Catch ex As Exception
|
||||
Autodesk.Revit.UI.TaskDialog.Show("Revit", "Please input an integer for the number of floors between 1 to 10.")
|
||||
floornumberTextBox.Text = ""
|
||||
End Try
|
||||
End Sub
|
||||
End Class
|
||||
Binary file not shown.
Reference in New Issue
Block a user