mirror of
https://github.com/jeremytammik/RevitSdkSamples.git
synced 2026-09-26 12:41:32 +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>AutoJoin.dll</Assembly>
|
||||
<ClientId>ac7c9e70-077e-4693-8f2e-aea13dd2fad3</ClientId>
|
||||
<FullClassName>Revit.SDK.Samples.AutoJoin.CS.Command</FullClassName>
|
||||
<Text>Auto Join</Text>
|
||||
<Description>Automatically join geometry of combinable elements.</Description>
|
||||
<VisibilityMode>AlwaysVisible</VisibilityMode>
|
||||
<VendorId>ADSK</VendorId>
|
||||
<VendorDescription>Autodesk, www.autodesk.com</VendorDescription>
|
||||
</AddIn>
|
||||
</RevitAddIns>
|
||||
@@ -0,0 +1,198 @@
|
||||
//
|
||||
// (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.
|
||||
//
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
using Autodesk.Revit;
|
||||
using Autodesk.Revit.DB;
|
||||
|
||||
namespace Revit.SDK.Samples.AutoJoin.CS
|
||||
{
|
||||
/// <summary>
|
||||
/// Join all the overlapping generic forms in this document.
|
||||
/// </summary>
|
||||
public class AutoJoin
|
||||
{
|
||||
/// <summary>
|
||||
/// Constructor
|
||||
/// </summary>
|
||||
public AutoJoin()
|
||||
{
|
||||
m_elements = new List<CombinableElement>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Join geometry between overlapping solids.
|
||||
/// </summary>
|
||||
/// <param name="document">The active document</param>
|
||||
/// <returns>The number of geometry combination be joined in this document.</returns>
|
||||
public int Join(Document document)
|
||||
{
|
||||
int combinated = 0;
|
||||
|
||||
// CombinableElement is of an element type that exists in the API, but not in Revit's native object model.
|
||||
// We use a combination of GenericForm and GeomCombination elements instead to find all CombinableElement.
|
||||
LogicalOrFilter filter = new LogicalOrFilter(
|
||||
new ElementClassFilter(typeof(GenericForm)),
|
||||
new ElementClassFilter(typeof(GeomCombination)));
|
||||
|
||||
FilteredElementIterator itor = (new FilteredElementCollector(document)).WherePasses(filter).GetElementIterator();
|
||||
itor.Reset();
|
||||
while (itor.MoveNext())
|
||||
{
|
||||
GenericForm gf = itor.Current as GenericForm;
|
||||
if (null != gf && !gf.IsSolid)
|
||||
continue;
|
||||
|
||||
CombinableElement ce = itor.Current as CombinableElement;
|
||||
if (null == ce)
|
||||
continue;
|
||||
else
|
||||
m_elements.Add(ce);
|
||||
}
|
||||
// Added all solid forms in this document.
|
||||
|
||||
while (1 < m_elements.Count)
|
||||
{
|
||||
GeomCombination geomCombination = JoinOverlapping(m_elements, document);
|
||||
if (null == geomCombination)
|
||||
{
|
||||
return combinated;//No overlapping.
|
||||
}
|
||||
|
||||
combinated++;
|
||||
}
|
||||
|
||||
return combinated;
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Join the overlapped elements in the list.
|
||||
/// </summary>
|
||||
/// <param name="elements">the element list may includes overlapping.</param>
|
||||
/// <param name="document">the active document</param>
|
||||
/// <returns>the joined geometry combination, the joined elements is removed from the list.</returns>
|
||||
public GeomCombination JoinOverlapping(List<CombinableElement> elements, Document document)
|
||||
{
|
||||
CombinableElementArray joinedElements = new CombinableElementArray();
|
||||
|
||||
// try to find the first overlapping.
|
||||
foreach (CombinableElement aElement in elements)
|
||||
{
|
||||
foreach (CombinableElement xElement in elements)
|
||||
{
|
||||
if (IsOverlapped(aElement, xElement))
|
||||
{
|
||||
joinedElements.Append(aElement);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (1 == joinedElements.Size)
|
||||
break;
|
||||
}
|
||||
|
||||
if (0 == joinedElements.Size)
|
||||
{
|
||||
return null;//Can not find any overlapping.
|
||||
}
|
||||
|
||||
// try to find all elements overlapped the first element.
|
||||
foreach (CombinableElement aElement in elements)
|
||||
{
|
||||
if (IsOverlapped(aElement, joinedElements.get_Item(0)))
|
||||
{
|
||||
joinedElements.Append(aElement);
|
||||
}
|
||||
}
|
||||
|
||||
List<CombinableElement> allCanJoin = new List<CombinableElement>();
|
||||
bool isNew = false;
|
||||
do
|
||||
{
|
||||
allCanJoin.Clear();
|
||||
isNew = false;
|
||||
|
||||
// try to find all elements overlapped joinedElements
|
||||
foreach (CombinableElement aElement in joinedElements)
|
||||
{
|
||||
foreach (CombinableElement xElement in elements)
|
||||
{
|
||||
if (IsOverlapped(aElement, xElement))
|
||||
{
|
||||
allCanJoin.Add(xElement);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach (CombinableElement aElement in allCanJoin)
|
||||
{
|
||||
bool isContained = false;
|
||||
|
||||
for (int ii = 0; ii < joinedElements.Size; ii++)
|
||||
{
|
||||
if (aElement.Id.IntegerValue == joinedElements.get_Item(ii).Id.IntegerValue)
|
||||
{
|
||||
isContained = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!isContained)
|
||||
{
|
||||
isNew = true;
|
||||
joinedElements.Append(aElement);
|
||||
}
|
||||
}
|
||||
} while (isNew);// find all elements which overlapped with joined geometry combination.
|
||||
|
||||
|
||||
// removed the joined elements from the input list.
|
||||
foreach (CombinableElement aElement in joinedElements)
|
||||
{
|
||||
elements.Remove(aElement);
|
||||
}
|
||||
|
||||
return document.CombineElements(joinedElements);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tell if the element A and B are overlapped.
|
||||
/// </summary>
|
||||
/// <param name="elementA">element A</param>
|
||||
/// <param name="elementB">element B</param>
|
||||
/// <returns>return true if A and B are overlapped, or else return false.</returns>
|
||||
public bool IsOverlapped(CombinableElement elementA, CombinableElement elementB)
|
||||
{
|
||||
if (elementA.Id.IntegerValue == elementB.Id.IntegerValue)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
Options geOptions = Command.s_appCreation.NewGeometryOptions();
|
||||
return Intersection.IsOverlapped(elementA.get_Geometry(geOptions), elementB.get_Geometry(geOptions));
|
||||
}
|
||||
|
||||
private List<CombinableElement> m_elements;// this element list to combine geometry.
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProductVersion>9.0.30729</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{B0F48DFB-6DAF-4451-8E7C-2617485D7CE0}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>AutoJoin</RootNamespace>
|
||||
<AssemblyName>AutoJoin</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
|
||||
<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>
|
||||
</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>
|
||||
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<OutputPath>bin\x64\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<DebugType>full</DebugType>
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
|
||||
<OutputPath>bin\x64\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<Optimize>true</Optimize>
|
||||
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<RunPostBuildEvent>OnOutputUpdated</RunPostBuildEvent>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="System.Core">
|
||||
<RequiredTargetFramework>3.5</RequiredTargetFramework>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="AutoJoin.cs" />
|
||||
<Compile Include="Command.cs" />
|
||||
<Compile Include="Intersection.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(SolutionDir)VSProps\SDKSamples.targets" />
|
||||
<!-- 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>
|
||||
-->
|
||||
<PropertyGroup>
|
||||
<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,119 @@
|
||||
//
|
||||
// (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.
|
||||
//
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
using Autodesk.Revit;
|
||||
using Autodesk.Revit.DB;
|
||||
using Autodesk.Revit.UI;
|
||||
|
||||
using AppCreation = Autodesk.Revit.Creation.Application;
|
||||
|
||||
namespace Revit.SDK.Samples.AutoJoin.CS
|
||||
{
|
||||
/// <summary>
|
||||
/// This sample demonstrates how to automatically join geometry
|
||||
/// between multiple generic forms for use in family modeling and massing.
|
||||
/// </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)]
|
||||
public class Command : IExternalCommand
|
||||
{
|
||||
|
||||
public static AppCreation s_appCreation;
|
||||
|
||||
/// <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 virtual Autodesk.Revit.UI.Result Execute(ExternalCommandData commandData
|
||||
, ref string message, Autodesk.Revit.DB.ElementSet elements)
|
||||
{
|
||||
Transaction trans = new Transaction(commandData.Application.ActiveUIDocument.Document, "Revit.SDK.Samples.AutoJoin");
|
||||
trans.Start();
|
||||
if (null == s_appCreation)
|
||||
{
|
||||
// share for class Intersection.
|
||||
s_appCreation = commandData.Application.Application.Create;
|
||||
}
|
||||
|
||||
UIDocument doc = commandData.Application.ActiveUIDocument;
|
||||
CombinableElementArray solids
|
||||
= new CombinableElementArray();
|
||||
|
||||
ElementSet es = new ElementSet();
|
||||
foreach (ElementId elemId in es)
|
||||
{
|
||||
es.Insert(doc.Document.GetElement(elemId));
|
||||
}
|
||||
if (0 < es.Size)
|
||||
{
|
||||
foreach (Autodesk.Revit.DB.ElementId elementId in doc.Selection.GetElementIds())
|
||||
{
|
||||
Autodesk.Revit.DB.Element element = doc.Document.GetElement(elementId);
|
||||
System.Diagnostics.Trace.WriteLine(element.GetType().ToString());
|
||||
|
||||
GenericForm gf = element as GenericForm;
|
||||
if (null != gf && !gf.IsSolid)
|
||||
continue;
|
||||
|
||||
CombinableElement ce = element as CombinableElement;
|
||||
if (null != ce)
|
||||
solids.Append(ce);
|
||||
}
|
||||
|
||||
if (solids.Size < 2)
|
||||
{
|
||||
message = "At least 2 combinable elements should be selected.";
|
||||
trans.RollBack();
|
||||
return Autodesk.Revit.UI.Result.Failed;
|
||||
}
|
||||
|
||||
doc.Document.CombineElements(solids);
|
||||
|
||||
//The selected generic forms are joined, whether or not they overlap.
|
||||
trans.Commit();
|
||||
return Autodesk.Revit.UI.Result.Succeeded;
|
||||
}
|
||||
|
||||
AutoJoin autojoin = new AutoJoin();
|
||||
autojoin.Join(doc.Document);
|
||||
//All overlapping generic forms are joined.
|
||||
trans.Commit();
|
||||
return Autodesk.Revit.UI.Result.Succeeded;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,160 @@
|
||||
//
|
||||
// (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.
|
||||
//
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
using Autodesk.Revit.Creation;
|
||||
using Autodesk.Revit.DB;
|
||||
|
||||
using GeometryElement = Autodesk.Revit.DB.GeometryElement;
|
||||
using AppCreation = Autodesk.Revit.Creation.Application;
|
||||
|
||||
namespace Revit.SDK.Samples.AutoJoin.CS
|
||||
{
|
||||
/// <summary>
|
||||
/// Tell if two geometry objects are overlapping or not.
|
||||
/// </summary>
|
||||
class Intersection
|
||||
{
|
||||
/// <summary>
|
||||
/// Tell if the geometry object A and B are overlapped.
|
||||
/// </summary>
|
||||
/// <param name="geometryA">geometry object A</param>
|
||||
/// <param name="geometryB">geometry object B</param>
|
||||
/// <returns>return true if A and B are overlapped, or else return false.</returns>
|
||||
public static bool IsOverlapped(GeometryObject geometryA, GeometryObject geometryB)
|
||||
{
|
||||
List<Face> facesOfA = new List<Face>();
|
||||
List<Curve> curvesOfB = new List<Curve>();
|
||||
|
||||
GetAllFaces(geometryA, facesOfA);
|
||||
GetAllCurves(geometryB, curvesOfB);
|
||||
|
||||
foreach (Face face in facesOfA)
|
||||
{
|
||||
foreach (Curve curve in curvesOfB)
|
||||
{
|
||||
if (face.Intersect(curve) == Autodesk.Revit.DB.SetComparisonResult.Overlap)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get all faces of the geometry object and insert them to the list
|
||||
/// </summary>
|
||||
/// <param name="geometry">the geometry object</param>
|
||||
/// <param name="faces">the face list</param>
|
||||
private static void GetAllFaces(GeometryObject geometry, List<Face> faces)
|
||||
{
|
||||
if (geometry is GeometryElement)
|
||||
{
|
||||
GetAllFaces(geometry as GeometryElement, faces);
|
||||
return;
|
||||
}
|
||||
|
||||
if (geometry is Solid)
|
||||
{
|
||||
GetAllFaces(geometry as Solid, faces);
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static void GetAllFaces(GeometryElement geoElement, List<Face> faces)
|
||||
{
|
||||
//foreach (GeometryObject geObject in geoElement.Objects)
|
||||
IEnumerator<GeometryObject> Objects = geoElement.GetEnumerator();
|
||||
while (Objects.MoveNext())
|
||||
{
|
||||
GeometryObject geObject = Objects.Current;
|
||||
|
||||
GetAllFaces(geObject, faces);
|
||||
}
|
||||
}
|
||||
|
||||
private static void GetAllFaces(Solid solid, List<Face> faces)
|
||||
{
|
||||
foreach (Face face in solid.Faces)
|
||||
{
|
||||
faces.Add(face);
|
||||
}
|
||||
}
|
||||
|
||||
private static void GetAllCurves(GeometryObject geometry, List<Curve> curves)
|
||||
{
|
||||
if (geometry is GeometryElement)
|
||||
{
|
||||
GetAllCurves(geometry as GeometryElement, curves);
|
||||
return;
|
||||
}
|
||||
|
||||
if (geometry is Solid)
|
||||
{
|
||||
GetAllCurves(geometry as Solid, curves);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
private static void GetAllCurves(GeometryElement geoElement, List<Curve> curves)
|
||||
{
|
||||
//foreach (GeometryObject geObject in geoElement.Objects)
|
||||
IEnumerator<GeometryObject> Objects = geoElement.GetEnumerator();
|
||||
while (Objects.MoveNext())
|
||||
{
|
||||
GeometryObject geObject = Objects.Current;
|
||||
|
||||
GetAllCurves(geObject, curves);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static void GetAllCurves(Solid solid, List<Curve> curves)
|
||||
{
|
||||
foreach (Face face in solid.Faces)
|
||||
{
|
||||
GetAllCurves(face, curves);
|
||||
}
|
||||
}
|
||||
|
||||
private static void GetAllCurves(Face face, List<Curve> curves)
|
||||
{
|
||||
foreach (EdgeArray loop in face.EdgeLoops)
|
||||
{
|
||||
foreach (Edge edge in loop)
|
||||
{
|
||||
List<Autodesk.Revit.DB.XYZ> points = edge.Tessellate() as List<Autodesk.Revit.DB.XYZ>;
|
||||
for (int ii = 0; ii + 1 < points.Count; ii++)
|
||||
{
|
||||
Line line = Line.CreateBound(points[ii], points[ii + 1]);
|
||||
curves.Add(line);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
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("AutoJoin")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("Autodesk, Inc.")]
|
||||
[assembly: AssemblyProduct("AutoJoin")]
|
||||
[assembly: AssemblyCopyright("Copyright © Autodesk, Inc. 2009")]
|
||||
[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("26bf733b-b9f1-4375-80b2-adaa26b5541f")]
|
||||
|
||||
// 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 Revision and Build Numbers
|
||||
// by using the '*' as shown below:
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
Binary file not shown.
Reference in New Issue
Block a user