mirror of
https://github.com/jeremytammik/RevitSdkSamples.git
synced 2026-08-15 18:14:02 +00:00
added Revit 2022 SDK minus except *rvt and *rfa
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RevitAddIns>
|
||||
<AddIn Type="Command">
|
||||
<Assembly>AnalyticalViewer.dll</Assembly>
|
||||
<ClientId>2bb42c44-3fa5-4d9c-89b6-f72510bae9f5</ClientId>
|
||||
<FullClassName>Revit.SDK.Samples.AnalyticalViewer.VB.NET.AnalyticalViewer</FullClassName>
|
||||
<Text>Analytical Viewer</Text>
|
||||
<Description>Display analytical model of one or more selected elements.</Description>
|
||||
<VisibilityMode>AlwaysVisible</VisibilityMode>
|
||||
<VendorId>ADSK</VendorId>
|
||||
<VendorDescription>Autodesk, www.autodesk.com</VendorDescription>
|
||||
</AddIn>
|
||||
</RevitAddIns>
|
||||
@@ -0,0 +1,150 @@
|
||||
<?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>{1ADAB5BD-80A9-46E4-8B57-AB6865A0AE07}</ProjectGuid>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ApplicationIcon>
|
||||
</ApplicationIcon>
|
||||
<AssemblyKeyContainerName>
|
||||
</AssemblyKeyContainerName>
|
||||
<AssemblyName>AnalyticalViewer</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.AnalyticalViewer.VB.NET</RootNamespace>
|
||||
<StartupObject>
|
||||
</StartupObject>
|
||||
<FileUpgradeFlags>
|
||||
</FileUpgradeFlags>
|
||||
<MyType>Windows</MyType>
|
||||
<UpgradeBackupLocation>
|
||||
</UpgradeBackupLocation>
|
||||
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
|
||||
<TargetFrameworkProfile />
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<OutputPath>bin\</OutputPath>
|
||||
<DocumentationFile>AnalyticalViewer.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>AnalyticalViewer.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>AnalyticalViewer.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>AnalyticalViewer.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.Windows.Forms" />
|
||||
<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="Main.vb">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Folder Include="My Project\" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\RevitViewer\VB.NET\RevitViewer.vbproj">
|
||||
<Project>{f2a04d84-b791-4738-a226-d38cdd8ebf87}</Project>
|
||||
<Name>RevitViewer</Name>
|
||||
</ProjectReference>
|
||||
</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,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("4FB10252-6C3B-4553-B0E3-2CC98A791FAD")>
|
||||
|
||||
' 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,243 @@
|
||||
'
|
||||
' (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.Collections.Generic
|
||||
|
||||
Imports Autodesk.Revit
|
||||
Imports Autodesk.Revit.DB
|
||||
Imports Autodesk.Revit.UI
|
||||
|
||||
''' <summary>
|
||||
''' Implements the Revit add-in interface IExternalCommand
|
||||
''' </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 AnalyticalViewer
|
||||
Implements Autodesk.Revit.UI.IExternalCommand
|
||||
|
||||
Private mViewer As RevitViewer.VB.NET.Wireframe
|
||||
Private mApplication As Autodesk.Revit.ApplicationServices.Application
|
||||
|
||||
''' <summary>
|
||||
''' Implement this method as an external command for Revit.
|
||||
''' </summary>
|
||||
''' <param name="commandData">An object that is passed to the external application
|
||||
''' which contains data related to the command,
|
||||
''' such as the application object and active view.</param>
|
||||
''' <param name="message">A message that can be set by the external application
|
||||
''' which will be displayed if a failure or cancellation is returned by
|
||||
''' the external command.</param>
|
||||
''' <param name="elements">A set of elements to which the external application
|
||||
''' can add elements that are to be highlighted in case of failure or cancellation.</param>
|
||||
''' <returns>Return the status of the external command.
|
||||
''' A result of Succeeded means that the API external method functioned as expected.
|
||||
''' Cancelled can be used to signify that the user cancelled the external operation
|
||||
''' at some point. Failure should be returned if the application is unable to proceed with
|
||||
''' the operation.</returns>
|
||||
Public Function Execute(ByVal commandData As ExternalCommandData, ByRef message As String, ByVal elements As Autodesk.Revit.DB.ElementSet) As Autodesk.Revit.UI.Result Implements IExternalCommand.Execute
|
||||
|
||||
Dim element As Autodesk.Revit.DB.Element
|
||||
Dim elementId As Autodesk.Revit.DB.ElementId
|
||||
|
||||
mApplication = commandData.Application.Application
|
||||
|
||||
If (commandData.Application.ActiveUIDocument.Selection.GetElementIds().Count > 0) Then
|
||||
For Each elementId In commandData.Application.ActiveUIDocument.Selection.GetElementIds()
|
||||
element = commandData.Application.ActiveUIDocument.Document.GetElement(elementId)
|
||||
DrawAnalyticalModel(element)
|
||||
Next
|
||||
Else
|
||||
'ElementIsElementTypeFilter filter the elementType which has not AnalyticalModel
|
||||
Dim filter As Autodesk.Revit.DB.ElementIsElementTypeFilter
|
||||
filter = New Autodesk.Revit.DB.ElementIsElementTypeFilter(True)
|
||||
Dim collector As Autodesk.Revit.DB.FilteredElementCollector
|
||||
collector = New Autodesk.Revit.DB.FilteredElementCollector(commandData.Application.ActiveUIDocument.Document)
|
||||
collector.WherePasses(filter)
|
||||
Dim iter As IEnumerator
|
||||
iter = collector.GetElementIterator
|
||||
|
||||
Do While (iter.MoveNext())
|
||||
element = iter.Current
|
||||
DrawAnalyticalModel(element)
|
||||
Loop
|
||||
End If
|
||||
|
||||
If Not (mViewer Is Nothing) Then
|
||||
|
||||
mViewer.Fit()
|
||||
mViewer.Draw()
|
||||
mViewer.ShowModal()
|
||||
Else
|
||||
TaskDialog.Show("Revit", "No analytical model to represent.")
|
||||
End If
|
||||
|
||||
mViewer = Nothing
|
||||
mApplication = Nothing
|
||||
|
||||
Return Autodesk.Revit.UI.Result.Succeeded
|
||||
End Function
|
||||
|
||||
''' <summary>
|
||||
''' distribute analytical model to its corresponding method to be draw.
|
||||
''' </summary>
|
||||
''' <param name="element"></param>
|
||||
''' <remarks></remarks>
|
||||
Private Sub DrawAnalyticalModel(ByVal element As Autodesk.Revit.DB.Element)
|
||||
|
||||
Dim analyticalModel As Autodesk.Revit.DB.Structure.AnalyticalModel = Nothing
|
||||
|
||||
analyticalModel = element.GetAnalyticalModel()
|
||||
|
||||
If (analyticalModel Is Nothing) Then
|
||||
Exit Sub
|
||||
End If
|
||||
|
||||
If (mViewer Is Nothing) Then
|
||||
mViewer = New RevitViewer.VB.NET.Wireframe
|
||||
End If
|
||||
|
||||
If TypeOf element Is Autodesk.Revit.DB.FamilyInstance Then
|
||||
Dim familyInstance As Autodesk.Revit.DB.FamilyInstance = element
|
||||
|
||||
If familyInstance.StructuralType.Equals(Autodesk.Revit.DB.Structure.StructuralType.Footing) Then
|
||||
DrawAnalyticalModelLocation(analyticalModel)
|
||||
Return
|
||||
End If
|
||||
|
||||
End If
|
||||
|
||||
DrawAnalyticalModelCurves(analyticalModel.GetCurves([Structure].AnalyticalCurveType.ActiveCurves))
|
||||
|
||||
|
||||
End Sub
|
||||
|
||||
''' <summary>
|
||||
''' Draw the primitive curve.
|
||||
''' </summary>
|
||||
''' <param name="curve"></param>
|
||||
''' <remarks></remarks>
|
||||
Private Sub DrawAnalyticalModelCurve(ByVal curve As Autodesk.Revit.DB.Curve)
|
||||
|
||||
If (curve Is Nothing) Then
|
||||
Exit Sub
|
||||
End If
|
||||
|
||||
Dim points As New List(Of Autodesk.Revit.DB.XYZ)
|
||||
points = curve.Tessellate
|
||||
|
||||
If (points Is Nothing) Then
|
||||
Exit Sub
|
||||
End If
|
||||
|
||||
If points.Count = 0 Then
|
||||
Exit Sub
|
||||
End If
|
||||
|
||||
Dim previousPoint As Autodesk.Revit.DB.XYZ
|
||||
previousPoint = New Autodesk.Revit.DB.XYZ
|
||||
Dim i As Integer
|
||||
For i = 0 To points.Count - 1
|
||||
|
||||
Dim point As Autodesk.Revit.DB.XYZ
|
||||
point = points.Item(i)
|
||||
If i > 0 Then
|
||||
mViewer.Add(previousPoint.X, previousPoint.Y, previousPoint.Z, point.X, point.Y, point.Z)
|
||||
End If
|
||||
|
||||
previousPoint = point
|
||||
Next
|
||||
|
||||
End Sub
|
||||
|
||||
''' <summary>
|
||||
''' Draw the primitive curve array.
|
||||
''' </summary>
|
||||
''' <param name="curves"></param>
|
||||
''' <remarks></remarks>
|
||||
Private Sub DrawAnalyticalModelCurves(ByVal curves As IList(Of Curve))
|
||||
|
||||
Dim curve As Autodesk.Revit.DB.Curve
|
||||
|
||||
For Each curve In curves
|
||||
|
||||
DrawAnalyticalModelCurve(curve)
|
||||
|
||||
Next
|
||||
|
||||
End Sub
|
||||
|
||||
|
||||
''' <summary>
|
||||
''' draw analytical location model
|
||||
''' </summary>
|
||||
''' <param name="analyticalModel"></param>
|
||||
''' <remarks></remarks>
|
||||
Private Sub DrawAnalyticalModelLocation(ByVal analyticalModel As Autodesk.Revit.DB.Structure.AnalyticalModel)
|
||||
|
||||
'draw a square
|
||||
|
||||
Dim location As Autodesk.Revit.DB.XYZ
|
||||
location = analyticalModel.GetPoint()
|
||||
|
||||
Dim curves As IList(Of Curve) = New List(Of Curve)()
|
||||
|
||||
Dim point1 As Autodesk.Revit.DB.XYZ
|
||||
point1 = New Autodesk.Revit.DB.XYZ
|
||||
Dim point2 As Autodesk.Revit.DB.XYZ
|
||||
point2 = New Autodesk.Revit.DB.XYZ
|
||||
Dim point3 As Autodesk.Revit.DB.XYZ
|
||||
point3 = New Autodesk.Revit.DB.XYZ
|
||||
Dim point4 As Autodesk.Revit.DB.XYZ
|
||||
point4 = New Autodesk.Revit.DB.XYZ
|
||||
|
||||
point1 = New Autodesk.Revit.DB.XYZ(location.X - 2, location.Y - 2, location.Z)
|
||||
|
||||
point2 = New Autodesk.Revit.DB.XYZ(location.X - 2, location.Y + 2, location.Z)
|
||||
|
||||
point3 = New Autodesk.Revit.DB.XYZ(location.X + 2, location.Y + 2, location.Z)
|
||||
|
||||
point4 = New Autodesk.Revit.DB.XYZ(location.X + 2, location.Y - 2, location.Z)
|
||||
|
||||
Dim line1 As Autodesk.Revit.DB.Line
|
||||
Dim line2 As Autodesk.Revit.DB.Line
|
||||
Dim line3 As Autodesk.Revit.DB.Line
|
||||
Dim line4 As Autodesk.Revit.DB.Line
|
||||
|
||||
line1 = Autodesk.Revit.DB.Line.CreateBound(point1, point2)
|
||||
line2 = Autodesk.Revit.DB.Line.CreateBound(point2, point3)
|
||||
line3 = Autodesk.Revit.DB.Line.CreateBound(point3, point4)
|
||||
line4 = Autodesk.Revit.DB.Line.CreateBound(point4, point1)
|
||||
|
||||
curves.Add(line1)
|
||||
curves.Add(line2)
|
||||
curves.Add(line3)
|
||||
curves.Add(line4)
|
||||
|
||||
DrawAnalyticalModelCurves(curves)
|
||||
|
||||
End Sub
|
||||
|
||||
End Class
|
||||
|
||||
Binary file not shown.
Reference in New Issue
Block a user