mirror of
https://github.com/jeremytammik/RevitSdkSamples.git
synced 2026-09-28 21:36:57 +00:00
removed Revit 2021 SDK contents
This commit is contained in:
@@ -1,57 +0,0 @@
|
||||
//
|
||||
// (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 System.Linq;
|
||||
using System.Text;
|
||||
using Autodesk.Revit.DB;
|
||||
using Autodesk.Revit.DB.Architecture;
|
||||
|
||||
namespace Revit.SDK.Samples.StairsAutomation.CS
|
||||
{
|
||||
/// <summary>
|
||||
/// An interface that represents a landing.
|
||||
/// </summary>
|
||||
public interface IStairsLandingComponent
|
||||
{
|
||||
/// <summary>
|
||||
/// Obtains the curves that bound the landing.
|
||||
/// </summary>
|
||||
/// <returns>The boundary curves.</returns>
|
||||
CurveLoop GetLandingBoundary();
|
||||
|
||||
/// <summary>
|
||||
/// Obtains the elevation of the landing.
|
||||
/// </summary>
|
||||
/// <returns>The elevation.</returns>
|
||||
double GetLandingBaseElevation();
|
||||
|
||||
/// <summary>
|
||||
/// Creates the landing component represented by this configuration.
|
||||
/// </summary>
|
||||
/// <param name="document">The document.</param>
|
||||
/// <param name="stairsElementId">The stairs element id.</param>
|
||||
/// <returns>The new landing.</returns>
|
||||
StairsLanding CreateLanding(Document document, ElementId stairsElementId);
|
||||
}
|
||||
}
|
||||
@@ -1,107 +0,0 @@
|
||||
//
|
||||
// (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.DB;
|
||||
|
||||
namespace Revit.SDK.Samples.StairsAutomation.CS
|
||||
{
|
||||
/// <summary>
|
||||
/// Utilities used in processing of landings.
|
||||
/// </summary>
|
||||
public class LandingComponentUtils
|
||||
{
|
||||
/// <summary>
|
||||
/// Returns a new set of curves created as a projection of the input curves to the provided elevation.
|
||||
/// </summary>
|
||||
/// <remarks>Assumes, but does not validate, that the curves are in the XY plane.</remarks>
|
||||
/// <param name="curves">The curves.</param>
|
||||
/// <param name="elevation">The target elevation.</param>
|
||||
/// <returns>The projected curves.</returns>
|
||||
public static IList<Curve> ProjectCurvesToElevation(IList<Curve> curves, double elevation)
|
||||
{
|
||||
List<Curve> ret = new List<Curve>();
|
||||
foreach (Curve curve in curves)
|
||||
{
|
||||
ret.Add(ProjectCurveToElevation(curve, elevation));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a new curve created as a projection of the input curve to the provided elevation.
|
||||
/// </summary>
|
||||
/// <remarks>Assumes, but does not validate, that the curve is in the XY plane.</remarks>
|
||||
/// <param name="curve">The curve.</param>
|
||||
/// <param name="elevation">The target elevation.</param>
|
||||
/// <returns>The projected curve.</returns>
|
||||
public static Curve ProjectCurveToElevation(Curve curve, double elevation)
|
||||
{
|
||||
double offset1 = elevation - curve.GetEndPoint(0).Z;
|
||||
Curve projectedCurve = curve.CreateTransformed(Transform.CreateTranslation(new XYZ(0, 0, offset1)));
|
||||
return projectedCurve;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Given two linear inputs, finds the combination of endpoints from each line which are farthest from each other, and returns a line
|
||||
/// connecting those points.
|
||||
/// </summary>
|
||||
/// <param name="line1">The first line.</param>
|
||||
/// <param name="line2">The second line.</param>
|
||||
/// <returns>The longest line connecting one endpoint from each line. </returns>
|
||||
public static Line FindLongestEndpointConnection(Line line1, Line line2)
|
||||
{
|
||||
double maxDistance = 0.0;
|
||||
XYZ endPoint1 = null;
|
||||
XYZ endPoint2 = null;
|
||||
|
||||
for (int i = 0; i < 2; i++)
|
||||
{
|
||||
for (int j = 0; j < 2; j++)
|
||||
{
|
||||
double distance = line1.GetEndPoint(j).DistanceTo(line2.GetEndPoint(i));
|
||||
if (distance > maxDistance)
|
||||
{
|
||||
maxDistance = distance;
|
||||
endPoint1 = line1.GetEndPoint(j);
|
||||
endPoint2 = line2.GetEndPoint(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return Line.CreateBound(endPoint1, endPoint2);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Computes the parameter of the point projected onto the curve.
|
||||
/// </summary>
|
||||
/// <param name="curve">The curve.</param>
|
||||
/// <param name="point">The point.</param>
|
||||
/// <returns>The parameter of the projected point.</returns>
|
||||
public static double ComputeParameter(Curve curve, XYZ point)
|
||||
{
|
||||
IntersectionResult result = curve.Project(point);
|
||||
return result.Parameter;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,99 +0,0 @@
|
||||
//
|
||||
// (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 System.Linq;
|
||||
using System.Text;
|
||||
using Autodesk.Revit.DB;
|
||||
using Autodesk.Revit.DB.Architecture;
|
||||
|
||||
namespace Revit.SDK.Samples.StairsAutomation.CS
|
||||
{
|
||||
/// <summary>
|
||||
/// A configuration for creation of a landing with a fixed cross section.
|
||||
/// </summary>
|
||||
public class StairsRectangleLandingComponent : IStairsLandingComponent
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a new StairsRectangleLandingConfiguration.
|
||||
/// </summary>
|
||||
/// <param name="stairsRunBoundary1">The end curve of the lower stair run.</param>
|
||||
/// <param name="stairsRunBoundary2">The start curve of the higher stair run.</param>
|
||||
/// <param name="runDirection">A vector representing the direction of the lower stair run.</param>
|
||||
/// <param name="elevation">The elevation of the landing.</param>
|
||||
/// <param name="width">The width of the landing.</param>
|
||||
public StairsRectangleLandingComponent(Line stairsRunBoundary1, Line stairsRunBoundary2, XYZ runDirection, double elevation, double width)
|
||||
{
|
||||
// offset to base elevation
|
||||
m_stairsRunBoundary1 = LandingComponentUtils.ProjectCurveToElevation(stairsRunBoundary1, elevation) as Line;
|
||||
m_stairsRunBoundary2 = LandingComponentUtils.ProjectCurveToElevation(stairsRunBoundary2, elevation) as Line;
|
||||
|
||||
m_runDirection = runDirection;
|
||||
m_width = width;
|
||||
m_elevation = elevation;
|
||||
}
|
||||
|
||||
private Line m_stairsRunBoundary1;
|
||||
private Line m_stairsRunBoundary2;
|
||||
private XYZ m_runDirection;
|
||||
private double m_width;
|
||||
private double m_elevation;
|
||||
|
||||
#region IStairsLandingConfiguration Members
|
||||
|
||||
/// <summary>
|
||||
/// Implements the interface method.
|
||||
/// </summary>
|
||||
public Autodesk.Revit.DB.CurveLoop GetLandingBoundary()
|
||||
{
|
||||
// TODO : What if not collinear
|
||||
Line boundaryLine = LandingComponentUtils.FindLongestEndpointConnection(m_stairsRunBoundary1, m_stairsRunBoundary2);
|
||||
|
||||
// offset by 1/2 of width
|
||||
Curve centerCurve = boundaryLine.CreateTransformed(Transform.CreateTranslation(m_runDirection * (m_width / 2.0)));
|
||||
|
||||
// Create by Thicken
|
||||
CurveLoop curveLoop = CurveLoop.CreateViaThicken(centerCurve, m_width, XYZ.BasisZ);
|
||||
|
||||
return curveLoop;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Implements the interface method.
|
||||
/// </summary>
|
||||
public double GetLandingBaseElevation()
|
||||
{
|
||||
return m_elevation;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Implements the interface method.
|
||||
/// </summary>
|
||||
public StairsLanding CreateLanding(Document document, ElementId stairsElementId)
|
||||
{
|
||||
return StairsLanding.CreateSketchedLanding(document, stairsElementId, GetLandingBoundary(), GetLandingBaseElevation());
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user