mirror of
https://github.com/jeremytammik/RevitSdkSamples.git
synced 2026-09-17 18:12:08 +00:00
added Revit 2022 SDK minus except *rvt and *rfa
This commit is contained in:
+58
@@ -0,0 +1,58 @@
|
||||
//
|
||||
// (C) Copyright 2003-2013 by Autodesk, Inc.
|
||||
//
|
||||
// Permission to use, copy, modify, and distribute this software in
|
||||
// object code form for any purpose and without fee is hereby granted,
|
||||
// provided that the above copyright notice appears in all copies and
|
||||
// that both that copyright notice and the limited warranty and
|
||||
// restricted rights notice below appear in all supporting
|
||||
// documentation.
|
||||
//
|
||||
// AUTODESK PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS.
|
||||
// AUTODESK SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF
|
||||
// MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE. AUTODESK, INC.
|
||||
// DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE
|
||||
// UNINTERRUPTED OR ERROR FREE.
|
||||
//
|
||||
// Use, duplication, or disclosure by the U.S. Government is subject to
|
||||
// restrictions set forth in FAR 52.227-19 (Commercial Computer
|
||||
// Software - Restricted Rights) and DFAR 252.227-7013(c)(1)(ii)
|
||||
// (Rights in Technical Data and Computer Software), as applicable.
|
||||
//
|
||||
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using 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.
|
||||
[assembly: AssemblyTitle("QueryingResults")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("Autodesk")]
|
||||
[assembly: AssemblyProduct("QueryingResults")]
|
||||
[assembly: AssemblyCopyright("Copyright © Autodesk 2012")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
[assembly: Guid("dd3d57cb-15ad-422c-80c7-19f101665444")]
|
||||
|
||||
// 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.*")]
|
||||
[assembly: AssemblyVersion("2015.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("2015.0.0.2464")]
|
||||
@@ -0,0 +1,337 @@
|
||||
//
|
||||
// (C) Copyright 2003-2012 by Autodesk, Inc.
|
||||
//
|
||||
// Permission to use, copy, modify, and distribute this software in
|
||||
// object code form for any purpose and without fee is hereby granted,
|
||||
// provided that the above copyright notice appears in all copies and
|
||||
// that both that copyright notice and the limited warranty and
|
||||
// restricted rights notice below appear in all supporting
|
||||
// documentation.
|
||||
//
|
||||
// AUTODESK PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS.
|
||||
// AUTODESK SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF
|
||||
// MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE. AUTODESK, INC.
|
||||
// DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE
|
||||
// UNINTERRUPTED OR ERROR FREE.
|
||||
//
|
||||
// Use, duplication, or disclosure by the U.S. Government is subject to
|
||||
// restrictions set forth in FAR 52.227-19 (Commercial Computer
|
||||
// Software - Restricted Rights) and DFAR 252.227-7013(c)(1)(ii)
|
||||
// (Rights in Technical Data and Computer Software), as applicable.
|
||||
//
|
||||
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
using Autodesk.Revit;
|
||||
using Autodesk.Revit.DB;
|
||||
using Autodesk.Revit.UI;
|
||||
using Autodesk.Revit.DB.ResultsBuilder;
|
||||
using Autodesk.Revit.DB.ResultsBuilder.Storage;
|
||||
using Autodesk.Revit.DB.Structure;
|
||||
|
||||
namespace Revit.SDK.Samples.QueryingResults.CS
|
||||
{
|
||||
/// <summary>
|
||||
/// Implements the Revit add-in interface IExternalCommand
|
||||
/// </summary>
|
||||
[Autodesk.Revit.Attributes.Transaction(Autodesk.Revit.Attributes.TransactionMode.Manual)]
|
||||
[Autodesk.Revit.Attributes.Regeneration(Autodesk.Revit.Attributes.RegenerationOption.Manual)]
|
||||
[Autodesk.Revit.Attributes.Journaling(Autodesk.Revit.Attributes.JournalingMode.NoCommandData)]
|
||||
class QueryResults : IExternalCommand
|
||||
{
|
||||
#region Class Members
|
||||
// Ids of elements used in this example
|
||||
// ElementIds are hardcoded, so this example has to be used with the included "ResultsInRevit.rvt" file
|
||||
ElementId linearElementId = new ElementId(262075);
|
||||
ElementId surfaceElementId = new ElementId(263074);
|
||||
|
||||
// Reference to the Revit document
|
||||
Document document;
|
||||
#endregion
|
||||
|
||||
#region Class Interface Implementation
|
||||
|
||||
/// <summary>
|
||||
/// The top level command.
|
||||
/// </summary>
|
||||
/// <param name="commandData">An object that is passed to the external application
|
||||
/// which contains data related to the command,
|
||||
/// such as the application object and active view.</param>
|
||||
/// <param name="message">A message that can be set by the external application
|
||||
/// which will be displayed if a failure or cancellation is returned by
|
||||
/// the external command.</param>
|
||||
/// <param name="elements">A set of elements to which the external application
|
||||
/// can add elements that are to be highlighted in case of failure or cancellation.</param>
|
||||
/// <returns>Return the status of the external command.
|
||||
/// A result of Succeeded means that the API external method functioned as expected.
|
||||
/// Cancelled can be used to signify that the user cancelled the external operation
|
||||
/// at some point. Failure should be returned if the application is unable to proceed with
|
||||
/// the operation.</returns>
|
||||
public Autodesk.Revit.UI.Result Execute(ExternalCommandData commandData, ref string message, Autodesk.Revit.DB.ElementSet elements)
|
||||
{
|
||||
// Set reference to the document and then check if this command is run on the inclueded "ResultsInRevit.rvt" file
|
||||
document = commandData.Application.ActiveUIDocument.Document;
|
||||
String outputDocumentPathName = commandData.Application.ActiveUIDocument.Document.PathName + ".ECTesting.txt";
|
||||
|
||||
Autodesk.Revit.UI.Result res = Result.Failed;
|
||||
|
||||
if (document.Title != "ResultsInRevit.rvt")
|
||||
{
|
||||
// Report error if this is a wrong file
|
||||
Autodesk.Revit.UI.TaskDialog.Show("Wrong Revit file", "Cannot use :\n" + document.PathName + "\n\nPlease use attached " + "\"ResultsInRevit.rvt\" file.");
|
||||
}
|
||||
else
|
||||
{
|
||||
// Go ahead and read some results from elements otherwise
|
||||
try
|
||||
{
|
||||
// Set ElementIds for Revit elements and loads used in this example. ElementIds are hardcoded
|
||||
ElementId loadCaseId1 = new ElementId(37232);
|
||||
ElementId loadCaseId2 = new ElementId(37234);
|
||||
ElementId combinationId = new ElementId(261966);
|
||||
ElementId []loadCaseIds = new ElementId[] { loadCaseId1, loadCaseId2, combinationId };
|
||||
|
||||
ResultsPackage resultsPackage = null;
|
||||
try
|
||||
{
|
||||
// Get results package
|
||||
resultsPackage = GetResultsPackage(document);
|
||||
}
|
||||
catch
|
||||
{
|
||||
Autodesk.Revit.UI.TaskDialog.Show("Cannot get result package.", "\nTry to store results first.");
|
||||
}
|
||||
|
||||
// Read Results from the created result package and store them in the textfile
|
||||
using (System.IO.StreamWriter writer = new System.IO.StreamWriter(outputDocumentPathName, false))
|
||||
{
|
||||
writer.WriteLine(ReadLinearResults(resultsPackage, linearElementId, loadCaseIds));
|
||||
writer.WriteLine(ReadArbitraryLinearResults(resultsPackage, linearElementId));
|
||||
writer.WriteLine(ReadSurfaceResults(resultsPackage, surfaceElementId, loadCaseIds));
|
||||
writer.WriteLine(ReadArbitrarySurfaceResults(resultsPackage, surfaceElementId));
|
||||
}
|
||||
res = Result.Succeeded;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Autodesk.Revit.UI.TaskDialog.Show("Failed to read results from Revit", ex.Message.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Class Implementation
|
||||
|
||||
/// <summary>
|
||||
/// Gets result package by getting Result Access object from the document, then querying it for a specific name ( "ResultsInRevit" )
|
||||
/// </summary>
|
||||
/// <param name="doc">Revit document</param>
|
||||
/// <returns>ResultsPackage containig results created in the StoringResults example</returns>
|
||||
ResultsPackage GetResultsPackage(Document doc)
|
||||
{
|
||||
ResultsAccess results = ResultsAccess.CreateResultsAccess(doc);
|
||||
return results.ResultsPackages.First(s => s.Name == "ResultsInRevit");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reads linear analitical results for a specific element, for a set of load cases
|
||||
/// </summary>
|
||||
/// <param name="resultsPackage">Package from which to results are to be read</param>
|
||||
/// <param name="elementId">Revit Element id</param>
|
||||
/// <param name="loadCaseIds">Collection of load case Ids</param>
|
||||
/// <returns>Results formatted into a string</returns>
|
||||
private String ReadLinearResults( ResultsPackage resultsPackage, ElementId elementId, ElementId []loadCaseIds)
|
||||
{
|
||||
// Set a list of result type elements
|
||||
IList<LinearResultType> linearResultTypes = new List<LinearResultType>() { LinearResultType.Fx, LinearResultType.Fy, LinearResultType.Fz, LinearResultType.Mx, LinearResultType.My, LinearResultType.Mz };
|
||||
List<ElementId> elementIds = new List<ElementId>() { elementId };
|
||||
|
||||
// Read results from the package
|
||||
IList<LineGraph> graphs = resultsPackage.GetLineGraphs(elementIds, loadCaseIds, linearResultTypes, new LineGraphParameters( UnitsSystem.Metric ) );
|
||||
|
||||
// Format results
|
||||
return FormatLinearResultsOutput( "Linear results", graphs);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reads linear arbitrary results for a specific element in a similar way to analitical results
|
||||
/// No load cases are used as arbitrary results are load independent
|
||||
/// </summary>
|
||||
/// <param name="resultsPackage">Package from which to results are to be read</param>
|
||||
/// <param name="elementId">Revit Element id</param>
|
||||
/// <returns>Results formatted into a string</returns>
|
||||
private String ReadArbitraryLinearResults(ResultsPackage resultsPackage, ElementId elementId)
|
||||
{
|
||||
IList<String> rnfTypes = new List<String>() { "RnfBarsAngleBottom", "RnfBarsAngleTop", "RnfBarsAngleLeft", "RnfBarsAngleRight" };
|
||||
List<ElementId> elementIds = new List<ElementId>() { elementId };
|
||||
List<ElementId> loadCaseIds = new List<ElementId>() { null };
|
||||
|
||||
IList<LineGraph> graphs = resultsPackage.GetLineGraphs(elementIds, loadCaseIds, rnfTypes, new LineGraphParameters(UnitsSystem.Metric));
|
||||
|
||||
return FormatLinearResultsOutput( "Linear arbitrary results", graphs);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Formats linear results into a string
|
||||
/// </summary>
|
||||
/// <param name="title">Title of the results group</param>
|
||||
/// <param name="graphs">Results - collection of LineGraph elements</param>
|
||||
/// <returns>String containing formatted results</returns>
|
||||
private String FormatLinearResultsOutput( String title, IList<LineGraph> graphs)
|
||||
{
|
||||
// String object
|
||||
StringBuilder res = new StringBuilder();
|
||||
|
||||
res.AppendLine();
|
||||
// Add header(title)
|
||||
res.AppendLine("Result type: " + title);
|
||||
res.AppendLine();
|
||||
// Add domain
|
||||
res.AppendLine( "X coordinates: ");
|
||||
foreach( double xCoord in graphs[0].Points.Select(s=>s.U))
|
||||
{
|
||||
res.Append(xCoord);
|
||||
}
|
||||
|
||||
// Group results using loadId
|
||||
var loads = graphs.GroupBy(s => s.LoadId);
|
||||
// Iterate over groups
|
||||
foreach (IGrouping<ElementId,LineGraph> load in loads)
|
||||
{
|
||||
res.AppendLine();
|
||||
res.AppendLine();
|
||||
// Get and add to the string Load info for each group( Load name and load type(Combination/LoadCase))
|
||||
if (load.Key != null)
|
||||
{
|
||||
res.AppendLine(GetLoadInfoForGraph(load.Key));
|
||||
}
|
||||
// Iterate over all results in the current group
|
||||
foreach (LineGraph lineGraph in load)
|
||||
{
|
||||
res.AppendLine();
|
||||
// Get and add result type
|
||||
res.AppendLine("Results: " +lineGraph.ResultType.ToString());
|
||||
// Add all values for the current result
|
||||
foreach( double value in lineGraph.Points.Select(s=>s.V))
|
||||
{
|
||||
res.Append( String.Format("{0:0.000},", value));
|
||||
}
|
||||
}
|
||||
}
|
||||
return res.ToString();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reads surface analitical results for a specific element, for a set of load cases
|
||||
/// </summary>
|
||||
/// <param name="resultsPackage">Package from which to results are to be read</param>
|
||||
/// <param name="elementId">Revit Element id</param>
|
||||
/// <param name="loadCaseIds">Collection of load case Ids</param>
|
||||
/// <returns>Results formatted into a string</returns>
|
||||
private String ReadSurfaceResults( ResultsPackage resultsPackage, ElementId elementId, ElementId []loadCaseIds)
|
||||
{
|
||||
// Set a list of result type elements
|
||||
SurfaceResultType[] surfaceResultTypes = { SurfaceResultType.Fxx, SurfaceResultType.Fyy, SurfaceResultType.Fxy, SurfaceResultType.Mxx, SurfaceResultType.Myy, SurfaceResultType.Mxy };
|
||||
List<ElementId> elementIds = new List<ElementId>() { elementId };
|
||||
|
||||
// Read results from the package
|
||||
IList<SurfaceGraph> graphs = resultsPackage.GetSurfaceGraphs(elementIds, loadCaseIds, surfaceResultTypes, new SurfaceGraphParameters(UnitsSystem.Metric));
|
||||
|
||||
// Format results
|
||||
return FormatSurfaceResultsOutput( "Surface results", graphs);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reads surface arbitrary results for a specific element in a similar way to analitical results
|
||||
/// </summary>
|
||||
/// <param name="resultsPackage">Package from which to results are to be read</param>
|
||||
/// <param name="elementId">Revit Element id</param>
|
||||
/// <returns>Results formatted into a string</returns>
|
||||
private String ReadArbitrarySurfaceResults( ResultsPackage resultsPackage, ElementId elementId)
|
||||
{
|
||||
String[] surfaceResultTypes = { "AxxBottom", "AyyBottom", "AxxTop", "AyyTop" };
|
||||
|
||||
List<ElementId> elementIds = new List<ElementId>() { elementId };
|
||||
List<ElementId> loadCaseIds = new List<ElementId>() { null };
|
||||
|
||||
IList<SurfaceGraph> graphs = resultsPackage.GetSurfaceGraphs(elementIds, loadCaseIds, surfaceResultTypes, new SurfaceGraphParameters(UnitsSystem.Metric));
|
||||
|
||||
return FormatSurfaceResultsOutput("Linear arbitrary results", graphs);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Formats surface results into a string
|
||||
/// </summary>
|
||||
/// <param name="title">Title of the results group</param>
|
||||
/// <param name="graphs">Results - collection of SurfaceGraph elements</param>
|
||||
/// <returns>String containing formatted results</returns>
|
||||
private String FormatSurfaceResultsOutput( String title, IList<SurfaceGraph> graphs)
|
||||
{
|
||||
StringBuilder res = new StringBuilder();
|
||||
|
||||
res.AppendLine();
|
||||
// Add header(title)
|
||||
res.AppendLine("Result type: " + title);
|
||||
res.AppendLine();
|
||||
// Add domain
|
||||
res.AppendLine("Points coordinates (x,y,z): ");
|
||||
foreach (XYZ coord in graphs[0].Points )
|
||||
{
|
||||
res.Append("(" + String.Format("{0:0.00},", coord.X) + String.Format("{0:0.00},", coord.Y) + String.Format("{0:0.00},", coord.Z) + ") ");
|
||||
}
|
||||
|
||||
// Group results using loadId
|
||||
var loads = graphs.GroupBy(s => s.LoadId);
|
||||
// Iterate over groups
|
||||
foreach (IGrouping<ElementId, SurfaceGraph> load in loads)
|
||||
{
|
||||
res.AppendLine();
|
||||
res.AppendLine();
|
||||
// Get and add to the string Load info for each group( Load name and load type(Combination/LoadCase))
|
||||
if (load.Key != null)
|
||||
{
|
||||
res.AppendLine(GetLoadInfoForGraph(load.Key));
|
||||
}
|
||||
// Iterate over all results in the current group
|
||||
foreach (SurfaceGraph surfaceGraph in load)
|
||||
{
|
||||
res.AppendLine();
|
||||
// Get and add result type
|
||||
res.AppendLine("Results: " + surfaceGraph.ResultType.ToString());
|
||||
// Add all values for the current result
|
||||
foreach (double value in surfaceGraph.Values)
|
||||
{
|
||||
res.Append(String.Format("{0:0.00},", value));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return res.ToString();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets string containg formatted load case description for a given load case Id
|
||||
/// </summary>
|
||||
/// <param name="loadId">Id for the given load</param>
|
||||
/// <returns>Load case description formatted int a string</returns>
|
||||
private String GetLoadInfoForGraph(ElementId loadId)
|
||||
{
|
||||
// Get revit element
|
||||
Autodesk.Revit.DB.Element load = document.GetElement(loadId);
|
||||
// Get load case type
|
||||
String type = load is LoadCase ? "Load Case" : ( load is LoadCombination ? "Load Combination" : "Unknown");
|
||||
// Get load case name
|
||||
String name = load is LoadCase ? (load as LoadCase).Name : ( load is LoadCombination ? (load as LoadCombination).Name : "-");
|
||||
|
||||
// Format both into a string
|
||||
return "Load type: " + type + ", Load name: " + name;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RevitAddIns>
|
||||
<AddIn Type="Command">
|
||||
<Assembly>AssemblyPath</Assembly>
|
||||
<ClientId>7ead6750-de24-4ca4-b063-ba40226e8d53</ClientId>
|
||||
<FullClassName>Revit.SDK.Samples.QueryingResults.CS.QueryResults</FullClassName>
|
||||
<Text>Query analitycal results in Revit</Text>
|
||||
<Description>Read analitycal results from Revit and output them to text file</Description>
|
||||
<VisibilityMode>AlwaysVisible</VisibilityMode>
|
||||
<VendorId>ADSK</VendorId>
|
||||
<VendorDescription>Autodesk, www.autodesk.com</VendorDescription>
|
||||
</AddIn>
|
||||
</RevitAddIns>
|
||||
+76
@@ -0,0 +1,76 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProductVersion>8.0.30703</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{A532EE11-A893-4D72-8245-76D47710C206}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>QueryingResults</RootNamespace>
|
||||
<AssemblyName>QueryingResults</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<TargetFrameworkProfile />
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<Prefer32Bit>false</Prefer32Bit>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<Prefer32Bit>false</Prefer32Bit>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="ResultsBuilder">
|
||||
<HintPath>..\..\..\..\..\..\References\ResultsBuilder\ResultsBuilder.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="RevitAPI">
|
||||
<HintPath>..\..\..\..\..\..\References\Revit\RevitAPI.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="RevitAPIUI">
|
||||
<HintPath>..\..\..\..\..\..\References\Revit\RevitAPIUI.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="QueryResults.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="QueryingResults.addin" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<PropertyGroup>
|
||||
<PostBuildEvent>if exist ..\..\..\..\..\..\..\..\Tools\BuildEvents\BuildEvents.exe (
|
||||
..\..\..\..\..\..\..\..\Tools\BuildEvents\BuildEvents.exe prepare_example $(ProjectDir) $(TargetPath) ..\..\..\..\..\..\Bin\SDK\CodeChecking\VisualStudio\Examples\ResultsInRevit\$(ProjectName)
|
||||
)</PostBuildEvent>
|
||||
</PropertyGroup>
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
</Project>
|
||||
+58
@@ -0,0 +1,58 @@
|
||||
//
|
||||
// (C) Copyright 2003-2013 by Autodesk, Inc.
|
||||
//
|
||||
// Permission to use, copy, modify, and distribute this software in
|
||||
// object code form for any purpose and without fee is hereby granted,
|
||||
// provided that the above copyright notice appears in all copies and
|
||||
// that both that copyright notice and the limited warranty and
|
||||
// restricted rights notice below appear in all supporting
|
||||
// documentation.
|
||||
//
|
||||
// AUTODESK PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS.
|
||||
// AUTODESK SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF
|
||||
// MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE. AUTODESK, INC.
|
||||
// DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE
|
||||
// UNINTERRUPTED OR ERROR FREE.
|
||||
//
|
||||
// Use, duplication, or disclosure by the U.S. Government is subject to
|
||||
// restrictions set forth in FAR 52.227-19 (Commercial Computer
|
||||
// Software - Restricted Rights) and DFAR 252.227-7013(c)(1)(ii)
|
||||
// (Rights in Technical Data and Computer Software), as applicable.
|
||||
//
|
||||
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using 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.
|
||||
[assembly: AssemblyTitle("StoringResults")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("Autodesk")]
|
||||
[assembly: AssemblyProduct("StoringResults")]
|
||||
[assembly: AssemblyCopyright("Copyright © Autodesk 2012")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
[assembly: Guid("288da9d5-faa3-4a81-8d52-162656e0b39e")]
|
||||
|
||||
// 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.*")]
|
||||
[assembly: AssemblyVersion("2015.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("2015.0.0.2464")]
|
||||
@@ -0,0 +1,353 @@
|
||||
//
|
||||
// (C) Copyright 2003-2013 by Autodesk, Inc.
|
||||
//
|
||||
// Permission to use, copy, modify, and distribute this software in
|
||||
// object code form for any purpose and without fee is hereby granted,
|
||||
// provided that the above copyright notice appears in all copies and
|
||||
// that both that copyright notice and the limited warranty and
|
||||
// restricted rights notice below appear in all supporting
|
||||
// documentation.
|
||||
//
|
||||
// AUTODESK PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS.
|
||||
// AUTODESK SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF
|
||||
// MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE. AUTODESK, INC.
|
||||
// DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE
|
||||
// UNINTERRUPTED OR ERROR FREE.
|
||||
//
|
||||
// Use, duplication, or disclosure by the U.S. Government is subject to
|
||||
// restrictions set forth in FAR 52.227-19 (Commercial Computer
|
||||
// Software - Restricted Rights) and DFAR 252.227-7013(c)(1)(ii)
|
||||
// (Rights in Technical Data and Computer Software), as applicable.
|
||||
//
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
using Autodesk.Revit;
|
||||
using Autodesk.Revit.DB;
|
||||
using Autodesk.Revit.UI;
|
||||
using Autodesk.Revit.DB.ResultsBuilder;
|
||||
using Autodesk.Revit.DB.ResultsBuilder.Storage;
|
||||
using Autodesk.Revit.DB.Structure;
|
||||
|
||||
namespace Revit.SDK.Samples.StoringResults.CS
|
||||
{
|
||||
/// <summary>
|
||||
/// Implements the Revit add-in interface IExternalCommand
|
||||
/// </summary>
|
||||
[Autodesk.Revit.Attributes.Transaction(Autodesk.Revit.Attributes.TransactionMode.Manual)]
|
||||
[Autodesk.Revit.Attributes.Regeneration(Autodesk.Revit.Attributes.RegenerationOption.Manual)]
|
||||
[Autodesk.Revit.Attributes.Journaling(Autodesk.Revit.Attributes.JournalingMode.NoCommandData)]
|
||||
class StoreResults : IExternalCommand
|
||||
{
|
||||
#region Class Members
|
||||
|
||||
// Ids of elements used in this example
|
||||
// ElementIds are hardcoded, so this example has to be used with the included "ResultsInRevit.rvt" file
|
||||
ElementId linearElementId = new ElementId(262075);
|
||||
ElementId surfaceElementId = new ElementId(263074);
|
||||
|
||||
// Ids of loads used in the example
|
||||
ElementId loadCaseId1 = new ElementId(37232);
|
||||
ElementId loadCaseId2 = new ElementId(37234);
|
||||
|
||||
Guid packageGuid = Guid.NewGuid();
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region Class Interface Implementation
|
||||
/// <summary>
|
||||
/// The top level command.
|
||||
/// </summary>
|
||||
/// <param name="commandData">An object that is passed to the external application
|
||||
/// which contains data related to the command,
|
||||
/// such as the application object and active view.</param>
|
||||
/// <param name="message">A message that can be set by the external application
|
||||
/// which will be displayed if a failure or cancellation is returned by
|
||||
/// the external command.</param>
|
||||
/// <param name="elements">A set of elements to which the external application
|
||||
/// can add elements that are to be highlighted in case of failure or cancellation.</param>
|
||||
/// <returns>Return the status of the external command.
|
||||
/// A result of Succeeded means that the API external method functioned as expected.
|
||||
/// Cancelled can be used to signify that the user cancelled the external operation
|
||||
/// at some point. Failure should be returned if the application is unable to proceed with
|
||||
/// the operation.</returns>
|
||||
public Autodesk.Revit.UI.Result Execute(ExternalCommandData commandData, ref string message, Autodesk.Revit.DB.ElementSet elements)
|
||||
{
|
||||
Autodesk.Revit.UI.Result retVal = Autodesk.Revit.UI.Result.Succeeded;
|
||||
Document doc = commandData.Application.ActiveUIDocument.Document;
|
||||
|
||||
// Check if this is the Revit file that is included in this example and display warning if not
|
||||
if (doc.Title != "ResultsInRevit.rvt")
|
||||
{
|
||||
Autodesk.Revit.UI.TaskDialog.Show("Wrong Revit file", "Cannot use :\n" + doc.PathName + "\n\nPlease use attached " + "\"ResultsInRevit.rvt\" file.");
|
||||
retVal = Autodesk.Revit.UI.Result.Failed;
|
||||
}
|
||||
|
||||
Transaction trans = new Transaction(doc);
|
||||
try
|
||||
{
|
||||
trans.SetName("ResultsInRevit_Transaction");
|
||||
trans.Start();
|
||||
|
||||
// Create new instance of empty result builder
|
||||
ResultsPackageBuilder resultsPackageBuilder = createResultsPackageBuilder(doc);
|
||||
// Add analitical results to the linear element for two load cases
|
||||
AddLinearResults(resultsPackageBuilder, linearElementId, new ElementId[] { loadCaseId1, loadCaseId2 });
|
||||
// Add some arbitrary results to the same element
|
||||
AddArbitraryLinearResults(resultsPackageBuilder, linearElementId);
|
||||
// Add analitical results to the surface element for the same load cases
|
||||
AddSurfaceResults(doc, resultsPackageBuilder, surfaceElementId, new ElementId[] { loadCaseId1, loadCaseId2});
|
||||
// Add arbitrary results to the surface element
|
||||
AddArbitrarySurfaceResults(doc, resultsPackageBuilder, surfaceElementId);
|
||||
|
||||
// End adding and close transaction
|
||||
resultsPackageBuilder.Finish();
|
||||
trans.Commit();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
// Rollback transaction and display warning if there were any problems
|
||||
trans.RollBack();
|
||||
Autodesk.Revit.UI.TaskDialog.Show("Failed to write results to Revit", ex.Message.ToString());
|
||||
retVal = Autodesk.Revit.UI.Result.Failed;
|
||||
}
|
||||
|
||||
return retVal;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Class Implementation
|
||||
|
||||
/// <summary>
|
||||
/// Creates an empty results package and fills out its header fields
|
||||
/// </summary>
|
||||
/// <param name="doc">Revit document</param>
|
||||
/// <returns>Reference to the newly created package</returns>
|
||||
private ResultsPackageBuilder createResultsPackageBuilder( Document doc)
|
||||
{
|
||||
ResultsAccess resultsAccess = ResultsAccess.CreateResultsAccess(doc);
|
||||
ResultsPackageBuilder resultsPackageBuilder = resultsAccess.CreateResultsPackage(packageGuid, "ResultsInRevit", UnitsSystem.Metric, ResultsPackageTypes.All);
|
||||
|
||||
resultsPackageBuilder.SetAnalysisName("ResultsInRevit_Analysis");
|
||||
resultsPackageBuilder.SetModelName("ResultsInRevit_Model");
|
||||
resultsPackageBuilder.SetDescription("Sample results");
|
||||
resultsPackageBuilder.SetVendorDescription("Autodesk");
|
||||
resultsPackageBuilder.SetVendorId("ADSK");
|
||||
|
||||
return resultsPackageBuilder;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds some results to a linear element for specific load cases
|
||||
/// </summary>
|
||||
/// <param name="resultsPackageBuilder">Reference to the results package</param>
|
||||
/// <param name="elementId">Id of the linear element to which results are to be added</param>
|
||||
/// <param name="loadCaseIds">Array of Ids of loads</param>
|
||||
private void AddLinearResults(ResultsPackageBuilder resultsPackageBuilder, ElementId elementId, ElementId []loadCaseIds)
|
||||
{
|
||||
// Create a list of points ( represented here by relative coordinates on the element ) in which results will be stored
|
||||
List<double> xCoordinateValues = new List<double>() { 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0 };
|
||||
|
||||
// Create list of some results
|
||||
// Each list element contains result type and a list of result values
|
||||
List<Tuple<LinearResultType, List<double>>> valuesForForceType = new List<Tuple<LinearResultType, List<double>>>()
|
||||
{
|
||||
new Tuple<LinearResultType,List<double>> ( LinearResultType.Fx, new List<double>() { 4.01, 4.02, 4.03, 4.04, 4.05, 4.06, 4.07, 4.08, 4.09, 4.10 }),
|
||||
new Tuple<LinearResultType,List<double>> ( LinearResultType.Fy, new List<double>() { -0.40, -0.30, -0.20, -0.10, 0.00, 0.10, 0.20, 0.30, 0.40, 0.50 }),
|
||||
new Tuple<LinearResultType,List<double>> ( LinearResultType.Fz, new List<double>() { 1.00, 1.20, 1.30, 1.40, 1.50, 1.60, 1.70, 1.80, 1.90, 2.00 }),
|
||||
new Tuple<LinearResultType,List<double>> ( LinearResultType.Mx, new List<double>() { 1.60, 1.60, 1.60, 1.60, 1.60, 1.60, 1.60, 1.60, 1.60, 1.60 }),
|
||||
new Tuple<LinearResultType,List<double>> ( LinearResultType.My, new List<double>() { 1.21, 1.00, 0.90, 0.40, 0.10, 0.10, 0.40, 0.90, 1.00, 1.21 }),
|
||||
new Tuple<LinearResultType,List<double>> ( LinearResultType.Mz, new List<double>() { 6.21, 6.00, 5.90, 5.40, 5.10, 5.10, 5.40, 5.90, 6.00, 6.21 }),
|
||||
};
|
||||
|
||||
// Add results for the first load case
|
||||
ElementId loadCaseId1 = loadCaseIds[0];
|
||||
// First result domain
|
||||
resultsPackageBuilder.SetBarResult(elementId, loadCaseId1, DomainResultType.X, xCoordinateValues);
|
||||
// Then result values
|
||||
foreach ( var valueForForce in valuesForForceType)
|
||||
{
|
||||
resultsPackageBuilder.SetBarResult(elementId, loadCaseId1, valueForForce.Item1, valueForForce.Item2);
|
||||
}
|
||||
|
||||
// Modify results and add them for the second load case as well
|
||||
ElementId loadCaseId2 = loadCaseIds[1];
|
||||
resultsPackageBuilder.SetBarResult(elementId, loadCaseId2, DomainResultType.X, xCoordinateValues);
|
||||
foreach (var valueForForce in valuesForForceType)
|
||||
{
|
||||
resultsPackageBuilder.SetBarResult(elementId, loadCaseId2, valueForForce.Item1, valueForForce.Item2.Select(s => s * 2));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds some arbitrary(user defined) results to a linear element. The arbitrary results that we are using here are load case independent
|
||||
/// </summary>
|
||||
/// <param name="resultsPackageBuilder"></param>
|
||||
/// <param name="elementId"></param>
|
||||
private void AddArbitraryLinearResults(ResultsPackageBuilder resultsPackageBuilder, ElementId elementId)
|
||||
{
|
||||
// Create list of some results
|
||||
// Each list element contains arbitrary result type(represented by string) and a list of result values
|
||||
List<Tuple<String, List<double>>> valuesForRnf = new List<Tuple<String, List<double>>>()
|
||||
{
|
||||
new Tuple<String,List<double>> ( "RnfBarsAngleBottom", new List<double>() { 45.00, 30.00, 15.00, 60.00, 0.00, 0.00, 10.00, 0.00, 0.00, 90.00 }),
|
||||
new Tuple<String,List<double>> ( "RnfBarsAngleTop", new List<double>() { 45.00, 30.00, 15.00, 60.00, 0.00, 0.00, 10.00, 0.00, 0.00, 90.00 }),
|
||||
new Tuple<String,List<double>> ( "RnfBarsAngleLeft", new List<double>() { 45.00, 30.00, 15.00, 60.00, 0.00, 0.00, 10.00, 0.00, 0.00, 90.00 }),
|
||||
new Tuple<String,List<double>> ( "RnfBarsAngleRight", new List<double>() { 45.00, 30.00, 15.00, 60.00, 0.00, 0.00, 10.00, 0.00, 0.00, 90.00 }),
|
||||
};
|
||||
|
||||
// Add result domain for load independent results
|
||||
List<double> xCoordinateValues = new List<double>() { 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0 };
|
||||
resultsPackageBuilder.SetBarResult(elementId, null, DomainResultType.X, xCoordinateValues);
|
||||
// Add result values
|
||||
foreach (var valueForRnf in valuesForRnf)
|
||||
{
|
||||
resultsPackageBuilder.AddMeasurement(valueForRnf.Item1, MeasurementResultType.Bar, UnitType.UT_Angle, DisplayUnitType.DUT_DEGREES_AND_MINUTES, MeasurementDependencyType.LoadCaseIndependent);
|
||||
resultsPackageBuilder.SetArbitraryResult(elementId, null, valueForRnf.Item1, valueForRnf.Item2);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Auxiliary method. Gets sample points from surface element contour( three points for each contour curve: start, mid and end )
|
||||
/// </summary>
|
||||
/// <param name="doc">Revit document</param>
|
||||
/// <param name="elementId">Surface element Id</param>
|
||||
/// <returns>List of XYZ points on the contour</returns>
|
||||
private List<XYZ> GetSurfaceContourPoints( Document doc, ElementId elementId )
|
||||
{
|
||||
// Create point list, get list of curves from analitical model
|
||||
List<XYZ> contour = new List<XYZ>();
|
||||
AnalyticalModel analyticalModel = (doc.GetElement(elementId) as AnalyticalModel);
|
||||
IList<Curve> curves = analyticalModel.GetCurves(AnalyticalCurveType.RawCurves);
|
||||
|
||||
// Iterate over curves and add mid, and end point of every curve to the point list
|
||||
foreach (Curve curve in curves)
|
||||
{
|
||||
double startParam = curve.GetEndParameter(0),
|
||||
endParam = curve.GetEndParameter(1);
|
||||
|
||||
XYZ start = curve.Evaluate(startParam, false),
|
||||
mid = curve.Evaluate(0.5*(startParam+endParam), false),
|
||||
end = curve.Evaluate(endParam, false);
|
||||
contour.Add(mid);
|
||||
contour.Add(end);
|
||||
}
|
||||
return contour;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Auxiliary method. Generates a list of sample results for points on surface element contour
|
||||
/// </summary>
|
||||
/// <param name="points">List of points for which results are to be generated</param>
|
||||
/// <returns>A list containing a number of records with surface result type and corresponding result values</returns>
|
||||
private List<Tuple<SurfaceResultType, List<double>>> GenerateSampleSurfaceResultsForContour(List<XYZ> points)
|
||||
{
|
||||
// Create an array of result types
|
||||
SurfaceResultType[] surfaceResultTypes = { SurfaceResultType.Fxx, SurfaceResultType.Fyy, SurfaceResultType.Fxy, SurfaceResultType.Mxx, SurfaceResultType.Myy, SurfaceResultType.Mxy };
|
||||
|
||||
// Create list
|
||||
var sampleResults = new List<Tuple<SurfaceResultType, List<double>>>();
|
||||
double coeff = 1.0e-3;
|
||||
// Iterate over types, create a value for each point and add a record to the list
|
||||
foreach (SurfaceResultType surfaceResultType in surfaceResultTypes)
|
||||
{
|
||||
coeff *= 10;
|
||||
List<double> results = points.Select( s=>( s.X*coeff + s.Y*coeff + s.Z*coeff)).ToList();
|
||||
sampleResults.Add( new Tuple<SurfaceResultType,List<double>>(surfaceResultType,results));
|
||||
}
|
||||
return sampleResults;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Auxiliary method. Generates a list of sample arbitrary results for points on surface element contour
|
||||
/// </summary>
|
||||
/// <param name="points">List of points for which arbitrary results are to be generated</param>
|
||||
/// <returns>A list containing a number of records with arbitrary surface result type and corresponding result values</returns>
|
||||
private List<Tuple<String, List<double>>> GenerateSampleArbitrarySurfaceResultsForContour(List<XYZ> points)
|
||||
{
|
||||
// Create an array of arbitrary result types. Type is represented by a string
|
||||
String[] surfaceResultTypes = { "Axx__Bottom", "Ayy__Bottom", "Axx__Top", "Ayy__Top" };
|
||||
|
||||
// Create list
|
||||
var sampleResults = new List<Tuple<String, List<double>>>();
|
||||
double coeff = 1.0e-4;
|
||||
// Iterate over types, create a value for each point and add a record to the list
|
||||
foreach (String surfaceResultType in surfaceResultTypes)
|
||||
{
|
||||
coeff *= 1.5;
|
||||
List<double> results = points.Select(s => (s.X * coeff + s.Y * coeff + s.Z * coeff)).ToList();
|
||||
sampleResults.Add(new Tuple<String, List<double>>(surfaceResultType, results));
|
||||
}
|
||||
return sampleResults;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds some results to a surface element for specific load cases
|
||||
/// </summary>
|
||||
/// <param name="doc">Revit document</param>
|
||||
/// <param name="resultsPackageBuilder"></param>
|
||||
/// <param name="elementId"></param>
|
||||
/// <param name="loadCaseIds"></param>
|
||||
private void AddSurfaceResults(Document doc, ResultsPackageBuilder resultsPackageBuilder, ElementId elementId, ElementId []loadCaseIds)
|
||||
{
|
||||
// Get a list of points on the contour
|
||||
List<XYZ> contourPoints = GetSurfaceContourPoints(doc, elementId);
|
||||
// Get a list of sample results in contour points
|
||||
var contourResults = GenerateSampleSurfaceResultsForContour(contourPoints);
|
||||
|
||||
// Add results for the first load case
|
||||
ElementId loadCaseId1 = loadCaseIds[0];
|
||||
// Result domain for each axis first
|
||||
resultsPackageBuilder.SetSurfaceResult(elementId, loadCaseId1, DomainResultType.X, contourPoints.Select(s => s.X));
|
||||
resultsPackageBuilder.SetSurfaceResult(elementId, loadCaseId1, DomainResultType.Y, contourPoints.Select(s => s.Y));
|
||||
resultsPackageBuilder.SetSurfaceResult(elementId, loadCaseId1, DomainResultType.Z, contourPoints.Select(s => s.Z));
|
||||
// Then correspoding result values
|
||||
foreach (var contourResult in contourResults)
|
||||
{
|
||||
resultsPackageBuilder.SetSurfaceResult(elementId, loadCaseId1, contourResult.Item1, contourResult.Item2);
|
||||
}
|
||||
|
||||
// Add modified results for the second load case too
|
||||
ElementId loadCaseId2 = loadCaseIds[1];
|
||||
resultsPackageBuilder.SetSurfaceResult(elementId, loadCaseId2, DomainResultType.X, contourPoints.Select(s => s.X));
|
||||
resultsPackageBuilder.SetSurfaceResult(elementId, loadCaseId2, DomainResultType.Y, contourPoints.Select(s => s.Y));
|
||||
resultsPackageBuilder.SetSurfaceResult(elementId, loadCaseId2, DomainResultType.Z, contourPoints.Select(s => s.Z));
|
||||
foreach (var contourResult in contourResults)
|
||||
{
|
||||
resultsPackageBuilder.SetSurfaceResult(elementId, loadCaseId2, contourResult.Item1, contourResult.Item2.Select(s=>s*2));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds some arbitrary(user defined), load independent results to a surface element.
|
||||
/// </summary>
|
||||
/// <param name="doc"></param>
|
||||
/// <param name="resultsPackageBuilder"></param>
|
||||
/// <param name="elementId"></param>
|
||||
private void AddArbitrarySurfaceResults(Document doc, ResultsPackageBuilder resultsPackageBuilder, ElementId elementId)
|
||||
{
|
||||
// Get contour points and generate sample arbitrary results for the surface element
|
||||
List<XYZ> contourPoints = GetSurfaceContourPoints(doc, elementId);
|
||||
var contourResults = GenerateSampleArbitrarySurfaceResultsForContour(contourPoints);
|
||||
|
||||
// Add result domain for load independent results for x,y,z axes
|
||||
resultsPackageBuilder.SetSurfaceResult(elementId, null, DomainResultType.X, contourPoints.Select(s => s.X));
|
||||
resultsPackageBuilder.SetSurfaceResult(elementId, null, DomainResultType.Y, contourPoints.Select(s => s.Y));
|
||||
resultsPackageBuilder.SetSurfaceResult(elementId, null, DomainResultType.Z, contourPoints.Select(s => s.Z));
|
||||
// Add result values
|
||||
foreach (var result in contourResults)
|
||||
{
|
||||
resultsPackageBuilder.AddMeasurement(result.Item1, MeasurementResultType.Surface, UnitType.UT_Area, DisplayUnitType.DUT_SQUARE_METERS, MeasurementDependencyType.LoadCaseIndependent);
|
||||
resultsPackageBuilder.SetArbitraryResult(elementId, null, result.Item1, result.Item2);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RevitAddIns>
|
||||
<AddIn Type="Command">
|
||||
<Assembly>AssemblyPath</Assembly>
|
||||
<ClientId>7ead6750-de24-4ca4-b063-ba40116e8d53</ClientId>
|
||||
<FullClassName>Revit.SDK.Samples.StoringResults.CS.StoreResults</FullClassName>
|
||||
<Text>Store analitycal results in Revit</Text>
|
||||
<Description>Create and store analitycal results in Revit</Description>
|
||||
<VisibilityMode>AlwaysVisible</VisibilityMode>
|
||||
<VendorId>ADSK</VendorId>
|
||||
<VendorDescription>Autodesk, www.autodesk.com</VendorDescription>
|
||||
</AddIn>
|
||||
</RevitAddIns>
|
||||
+76
@@ -0,0 +1,76 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProductVersion>8.0.30703</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{A0C4B14C-1C68-4D3A-8B6B-802DB93397DD}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>StoringResults</RootNamespace>
|
||||
<AssemblyName>StoringResults</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<TargetFrameworkProfile />
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<Prefer32Bit>false</Prefer32Bit>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<Prefer32Bit>false</Prefer32Bit>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="ResultsBuilder">
|
||||
<HintPath>..\..\..\..\..\..\References\ResultsBuilder\ResultsBuilder.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="RevitAPI">
|
||||
<HintPath>..\..\..\..\..\..\References\Revit\RevitAPI.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="RevitAPIUI">
|
||||
<HintPath>..\..\..\..\..\..\References\Revit\RevitAPIUI.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="StoreResults.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="StoringResults.addin" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<PropertyGroup>
|
||||
<PostBuildEvent>if exist ..\..\..\..\..\..\..\..\Tools\BuildEvents\BuildEvents.exe (
|
||||
..\..\..\..\..\..\..\..\Tools\BuildEvents\BuildEvents.exe prepare_example $(ProjectDir) $(TargetPath) ..\..\..\..\..\..\Bin\SDK\CodeChecking\VisualStudio\Examples\ResultsInRevit\$(ProjectName)
|
||||
)</PostBuildEvent>
|
||||
</PropertyGroup>
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
</Project>
|
||||
Reference in New Issue
Block a user