mirror of
https://github.com/jeremytammik/RevitSdkSamples.git
synced 2026-09-24 20:19:54 +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>AreaReinCurve.dll</Assembly>
|
||||
<ClientId>39f3f2fe-ce81-4e76-9c3e-ec84532eda25</ClientId>
|
||||
<FullClassName>Revit.SDK.Samples.AreaReinCurve.CS.Command</FullClassName>
|
||||
<Text>AreaReinCurve</Text>
|
||||
<Description>Turn off all layers but one. You get some parallel bars. Remove the hooks from one boundary curve so that the bars have hooks only at the other end.</Description>
|
||||
<VisibilityMode>AlwaysVisible</VisibilityMode>
|
||||
<VendorId>ADSK</VendorId>
|
||||
<VendorDescription>Autodesk, www.autodesk.com</VendorDescription>
|
||||
</AddIn>
|
||||
</RevitAddIns>
|
||||
@@ -0,0 +1,226 @@
|
||||
//
|
||||
// (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.
|
||||
//
|
||||
namespace Revit.SDK.Samples.AreaReinCurve.CS
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
|
||||
using Autodesk.Revit;
|
||||
using Autodesk.Revit.DB;
|
||||
using Autodesk.Revit.UI;
|
||||
using Autodesk.Revit.DB.Structure;
|
||||
|
||||
[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
|
||||
{
|
||||
AreaReinforcement m_areaRein;
|
||||
List<AreaReinforcementCurve> m_areaReinCurves;
|
||||
Document m_doc;
|
||||
|
||||
/// <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 Autodesk.Revit.UI.Result Execute(ExternalCommandData revit,
|
||||
ref string message, Autodesk.Revit.DB.ElementSet elements)
|
||||
{
|
||||
Transaction trans = new Transaction(revit.Application.ActiveUIDocument.Document, "Revit.SDK.Samples.AreaReinCurve");
|
||||
trans.Start();
|
||||
ElementSet selected = new ElementSet();
|
||||
foreach (ElementId elementId in revit.Application.ActiveUIDocument.Selection.GetElementIds())
|
||||
{
|
||||
selected.Insert(revit.Application.ActiveUIDocument.Document.GetElement(elementId));
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
m_doc = revit.Application.ActiveUIDocument.Document;
|
||||
|
||||
//selected is not one rectangular AreaReinforcement
|
||||
if (!PreData(selected))
|
||||
{
|
||||
message = "Please select only one rectangular AreaReinforcement.";
|
||||
trans.RollBack();
|
||||
return Autodesk.Revit.UI.Result.Failed;
|
||||
}
|
||||
|
||||
//fail to turn off layers
|
||||
if (!TurnOffLayers())
|
||||
{
|
||||
message = "Can't turn off layers as expected or can't find these layers.";
|
||||
trans.RollBack();
|
||||
return Autodesk.Revit.UI.Result.Failed;
|
||||
}
|
||||
|
||||
//fail to remove hooks
|
||||
if (!ChangeHookType())
|
||||
{
|
||||
message = "Can't remove HookTypes as expected.";
|
||||
trans.RollBack();
|
||||
return Autodesk.Revit.UI.Result.Failed;
|
||||
}
|
||||
}
|
||||
catch (ApplicationException appEx)
|
||||
{
|
||||
message = appEx.ToString();
|
||||
trans.RollBack();
|
||||
return Autodesk.Revit.UI.Result.Failed;
|
||||
}
|
||||
catch
|
||||
{
|
||||
message = "Unexpected error happens.";
|
||||
trans.RollBack();
|
||||
return Autodesk.Revit.UI.Result.Failed;
|
||||
}
|
||||
|
||||
//command is successful
|
||||
string msg = "All layers but Major Direction Layer or Exterior Direction Layer ";
|
||||
msg += "have been turn off; ";
|
||||
msg += "Removed the Hooks from one boundary curve of the Major Direction Layer ";
|
||||
msg += "or Exterior Direction Layer.";
|
||||
TaskDialog.Show("Revit", msg);
|
||||
trans.Commit();
|
||||
return Autodesk.Revit.UI.Result.Succeeded;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// check whether the selected is expected, prepare necessary data
|
||||
/// </summary>
|
||||
/// <param name="selected">selected elements</param>
|
||||
/// <returns>whether the selected AreaReinforcement is expected</returns>
|
||||
private bool PreData(ElementSet selected)
|
||||
{
|
||||
//selected is not only one AreaReinforcement
|
||||
if (selected.Size != 1)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
foreach (Object o in selected)
|
||||
{
|
||||
m_areaRein = o as AreaReinforcement;
|
||||
if (null == m_areaRein)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
//whether the selected AreaReinforcement is rectangular
|
||||
CurveArray curves = new CurveArray();
|
||||
m_areaReinCurves = new List<AreaReinforcementCurve>();
|
||||
IList<ElementId> curveIds = m_areaRein.GetBoundaryCurveIds();
|
||||
foreach (ElementId o in curveIds)
|
||||
{
|
||||
AreaReinforcementCurve areaCurve = m_doc.GetElement(o) as AreaReinforcementCurve;
|
||||
if (null == areaCurve)
|
||||
{
|
||||
ApplicationException appEx = new ApplicationException
|
||||
("There is unexpected error with selected AreaReinforcement.");
|
||||
throw appEx;
|
||||
}
|
||||
m_areaReinCurves.Add(areaCurve);
|
||||
curves.Append(areaCurve.Curve);
|
||||
}
|
||||
bool flag = GeomUtil.IsRectangular(curves);
|
||||
|
||||
return flag;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// turn off all layers but the Major Direction Layer or Exterior Direction Layer
|
||||
/// </summary>
|
||||
/// <returns>whether the command is successful</returns>
|
||||
private bool TurnOffLayers()
|
||||
{
|
||||
//AreaReinforcement is on the floor or slab
|
||||
bool flag = true;
|
||||
flag = ParameterUtil.SetParaInt(m_areaRein,
|
||||
BuiltInParameter.REBAR_SYSTEM_ACTIVE_BOTTOM_DIR_1, 0);
|
||||
flag &= ParameterUtil.SetParaInt(m_areaRein,
|
||||
BuiltInParameter.REBAR_SYSTEM_ACTIVE_BOTTOM_DIR_2, 0);
|
||||
flag &= ParameterUtil.SetParaInt(m_areaRein,
|
||||
BuiltInParameter.REBAR_SYSTEM_ACTIVE_TOP_DIR_2, 0);
|
||||
|
||||
//AreaReinforcement is on the wall
|
||||
if (!flag)
|
||||
{
|
||||
flag = true;
|
||||
flag &= ParameterUtil.SetParaInt(m_areaRein, "Interior Major Direction", 0);
|
||||
flag &= ParameterUtil.SetParaInt(m_areaRein, "Exterior Minor Direction", 0);
|
||||
flag &= ParameterUtil.SetParaInt(m_areaRein, "Interior Minor Direction", 0);
|
||||
}
|
||||
|
||||
return flag;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// remove the hooks from one boundary curve of the Major Direction Layer
|
||||
/// or Exterior Direction Layer
|
||||
/// </summary>
|
||||
/// <returns>whether the command is successful</returns>
|
||||
private bool ChangeHookType()
|
||||
{
|
||||
//find two vertical AreaReinforcementCurve
|
||||
Line line0 = m_areaReinCurves[0].Curve as Line;
|
||||
Line line1 = m_areaReinCurves[1].Curve as Line;
|
||||
Line line2 = m_areaReinCurves[2].Curve as Line;
|
||||
AreaReinforcementCurve temp = null;
|
||||
if (GeomUtil.IsVertical(line0, line1))
|
||||
{
|
||||
temp = m_areaReinCurves[1];
|
||||
}
|
||||
else
|
||||
{
|
||||
temp = m_areaReinCurves[2];
|
||||
}
|
||||
|
||||
//remove hooks
|
||||
ParameterUtil.SetParaInt(m_areaReinCurves[0],
|
||||
BuiltInParameter.REBAR_SYSTEM_OVERRIDE, -1);
|
||||
Parameter para = m_areaReinCurves[0].get_Parameter(
|
||||
BuiltInParameter.REBAR_SYSTEM_HOOK_TYPE_TOP_DIR_1);
|
||||
bool flag = ParameterUtil.SetParaNullId(para);
|
||||
|
||||
ParameterUtil.SetParaInt(temp, BuiltInParameter.REBAR_SYSTEM_OVERRIDE, -1);
|
||||
para = temp.get_Parameter(
|
||||
BuiltInParameter.REBAR_SYSTEM_HOOK_TYPE_TOP_DIR_1);
|
||||
flag &= ParameterUtil.SetParaNullId(para);
|
||||
|
||||
return flag;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,94 @@
|
||||
<?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>{01E38E1B-982E-48FC-89F9-75BA333A8A52}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>Revit.SDK.Samples.AreaReinCurve.CS</RootNamespace>
|
||||
<AssemblyName>AreaReinCurve</AssemblyName>
|
||||
<SccProjectName>
|
||||
</SccProjectName>
|
||||
<SccLocalPath>
|
||||
</SccLocalPath>
|
||||
<SccAuxPath>
|
||||
</SccAuxPath>
|
||||
<SccProvider>
|
||||
</SccProvider>
|
||||
<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.Windows.Forms" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="System.Core">
|
||||
<RequiredTargetFramework>3.5</RequiredTargetFramework>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="AreaReinCurve.cs" />
|
||||
<Compile Include="GeomUtil.cs" />
|
||||
<Compile Include="ParameterUtil.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,167 @@
|
||||
//
|
||||
// (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.
|
||||
//
|
||||
namespace Revit.SDK.Samples.AreaReinCurve.CS
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
|
||||
using Autodesk.Revit;
|
||||
using Autodesk.Revit.DB;
|
||||
using Autodesk.Revit.DB.Structure;
|
||||
|
||||
using GeoElement = Autodesk.Revit.DB.GeometryElement;
|
||||
using Element = Autodesk.Revit.DB.Element;
|
||||
|
||||
/// <summary>
|
||||
/// provide some common geometry judgement and calculate method
|
||||
/// </summary>
|
||||
class GeomUtil
|
||||
{
|
||||
const double PRECISION = 0.00001; //precision when judge whether two doubles are equal
|
||||
|
||||
/// <summary>
|
||||
/// judge whether given 4 lines can form a rectangular
|
||||
/// </summary>
|
||||
/// <param name="lines"></param>
|
||||
/// <returns>is rectangular</returns>
|
||||
/// <summary>
|
||||
/// judge whether given 4 lines can form a rectangular
|
||||
/// </summary>
|
||||
/// <param name="lines"></param>
|
||||
/// <returns>is rectangular</returns>
|
||||
public static bool IsRectangular(CurveArray curves)
|
||||
{
|
||||
if (curves.Size != 4)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
Line[] lines = new Line[4];
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
lines[i] = curves.get_Item(i) as Line;
|
||||
if (null == lines[i])
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
Line iniLine = lines[0];
|
||||
Line[] verticalLines = new Line[2];
|
||||
Line paraLine = null;
|
||||
int index = 0;
|
||||
for (int i = 1; i < 4; i++)
|
||||
{
|
||||
if (IsVertical(lines[0], lines[i]))
|
||||
{
|
||||
verticalLines[index] = lines[i];
|
||||
index++;
|
||||
}
|
||||
else
|
||||
{
|
||||
paraLine = lines[i];
|
||||
}
|
||||
}
|
||||
if (index != 2)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
bool flag = IsVertical(paraLine, verticalLines[0]);
|
||||
return flag;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// judge whether two lines are vertical
|
||||
/// </summary>
|
||||
/// <param name="line1"></param>
|
||||
/// <param name="line2"></param>
|
||||
/// <returns></returns>
|
||||
public static bool IsVertical(Line line1, Line line2)
|
||||
{
|
||||
Autodesk.Revit.DB.XYZ vector1 = SubXYZ(line1.GetEndPoint(0), line1.GetEndPoint(1));
|
||||
Autodesk.Revit.DB.XYZ vector2 = SubXYZ(line2.GetEndPoint(0), line2.GetEndPoint(1));
|
||||
|
||||
double result = DotMatrix(vector1, vector2);
|
||||
|
||||
if (Math.Abs(result) < PRECISION)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// subtraction of two Autodesk.Revit.DB.XYZ as Matrix
|
||||
/// </summary>
|
||||
/// <param name="p1"></param>
|
||||
/// <param name="p2"></param>
|
||||
/// <returns></returns>
|
||||
private static Autodesk.Revit.DB.XYZ SubXYZ (Autodesk.Revit.DB.XYZ p1, Autodesk.Revit.DB.XYZ p2)
|
||||
{
|
||||
double x = p1.X - p2.X;
|
||||
double y = p1.Y - p2.Y;
|
||||
double z = p1.Z - p2.Z;
|
||||
|
||||
Autodesk.Revit.DB.XYZ result = new Autodesk.Revit.DB.XYZ (x, y, z);
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// dot product of two Autodesk.Revit.DB.XYZ as Matrix
|
||||
/// </summary>
|
||||
/// <param name="p1"></param>
|
||||
/// <param name="p2"></param>
|
||||
/// <returns></returns>
|
||||
private static double DotMatrix(Autodesk.Revit.DB.XYZ p1, Autodesk.Revit.DB.XYZ p2)
|
||||
{
|
||||
double v1 = p1.X;
|
||||
double v2 = p1.Y;
|
||||
double v3 = p1.Z;
|
||||
|
||||
double u1 = p2.X;
|
||||
double u2 = p2.Y;
|
||||
double u3 = p2.Z;
|
||||
|
||||
double result = v1 * u1 + v2 * u2 + v3 * u3;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// judge whether the subtraction of two doubles is less than the internal decided precision
|
||||
/// </summary>
|
||||
/// <param name="d1"></param>
|
||||
/// <param name="d2"></param>
|
||||
/// <returns></returns>
|
||||
private static bool IsEqual(double d1, double d2)
|
||||
{
|
||||
double diff = Math.Abs(d1 - d2);
|
||||
if (diff < PRECISION)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,126 @@
|
||||
//
|
||||
// (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.
|
||||
//
|
||||
namespace Revit.SDK.Samples.AreaReinCurve.CS
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
|
||||
using Autodesk.Revit;
|
||||
using Autodesk.Revit.DB;
|
||||
|
||||
/// <summary>
|
||||
/// contain utility methods find or set certain parameter
|
||||
/// </summary>
|
||||
public class ParameterUtil
|
||||
{
|
||||
/// <summary>
|
||||
/// find certain parameter in a set
|
||||
/// </summary>
|
||||
/// <param name="paras"></param>
|
||||
/// <param name="name">find by name</param>
|
||||
/// <returns>found parameter</returns>
|
||||
public static bool SetParaInt(Element elem, string paraName, int value)
|
||||
{
|
||||
ParameterSet paras = elem.Parameters;
|
||||
Parameter findPara = FindParaByName(paras, paraName);
|
||||
|
||||
if (null == findPara)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!findPara.IsReadOnly)
|
||||
{
|
||||
findPara.Set(value);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// find certain parameter in a set
|
||||
/// </summary>
|
||||
/// <param name="paras"></param>
|
||||
/// <param name="name">find by name</param>
|
||||
/// <returns>found parameter</returns>
|
||||
public static Parameter FindParaByName(ParameterSet paras, string name)
|
||||
{
|
||||
Parameter findPara = null;
|
||||
|
||||
foreach (Parameter para in paras)
|
||||
{
|
||||
if (para.Definition.Name == name)
|
||||
{
|
||||
findPara = para;
|
||||
}
|
||||
}
|
||||
|
||||
return findPara;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// set certain parameter of given element to int value
|
||||
/// </summary>
|
||||
/// <param name="elem">given element</param>
|
||||
/// <param name="paraIndex">BuiltInParameter</param>
|
||||
/// <param name="value"></param>
|
||||
/// <returns></returns>
|
||||
public static bool SetParaInt(Element elem, BuiltInParameter paraIndex, int value)
|
||||
{
|
||||
Parameter para = elem.get_Parameter(paraIndex);
|
||||
if (null == para)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!para.IsReadOnly)
|
||||
{
|
||||
para.Set(value);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// set certain parameter of given element to int value
|
||||
/// </summary>
|
||||
/// <param name="elem">given element</param>
|
||||
/// <param name="paraIndex">BuiltInParameter</param>
|
||||
/// <param name="value"></param>
|
||||
/// <returns></returns>
|
||||
public static bool SetParaNullId(Parameter para)
|
||||
{
|
||||
Autodesk.Revit.DB.ElementId id = new ElementId(-1);
|
||||
|
||||
if (!para.IsReadOnly)
|
||||
{
|
||||
para.Set(id);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
//
|
||||
// (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.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("AreaReinCurve")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("AreaReinCurve")]
|
||||
[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("9ee39375-f989-4221-9ac7-905b2437b3f1")]
|
||||
|
||||
// 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