mirror of
https://github.com/jeremytammik/RevitSdkSamples.git
synced 2026-09-25 20:27:01 +00:00
added Revit 2022 SDK minus except *rvt and *rfa
This commit is contained in:
@@ -0,0 +1,77 @@
|
||||
//
|
||||
// (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.Text;
|
||||
|
||||
using Autodesk.Revit;
|
||||
using Autodesk.Revit.DB;
|
||||
using Autodesk.Revit.UI;
|
||||
|
||||
namespace Revit.SDK.Samples.CurtainWallGrid.CS
|
||||
{
|
||||
/// <summary>
|
||||
/// the entry point of the sample (to launch the sample dialog and allows further operations)
|
||||
/// </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 Command : IExternalCommand
|
||||
{
|
||||
/// <summary>
|
||||
/// The entrance of this example, implements the Execute method of IExternalCommand
|
||||
/// </summary>
|
||||
#region IExternalCommand Members Implementation
|
||||
/// <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 commandData, ref string message, Autodesk.Revit.DB.ElementSet elements)
|
||||
{
|
||||
MyDocument myDoc = new MyDocument(commandData);
|
||||
|
||||
using (GridForm gridForm = new GridForm(myDoc))
|
||||
{
|
||||
// The form is created successfully
|
||||
if (null != gridForm && false == gridForm.IsDisposed)
|
||||
{
|
||||
gridForm.ShowDialog();
|
||||
}
|
||||
}
|
||||
return Autodesk.Revit.UI.Result.Succeeded;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RevitAddIns>
|
||||
<AddIn Type="Command">
|
||||
<Assembly>CurtainWallGrid.dll</Assembly>
|
||||
<ClientId>8948a640-b0fe-4fa0-ad40-2581376bd519</ClientId>
|
||||
<FullClassName>Revit.SDK.Samples.CurtainWallGrid.CS.Command</FullClassName>
|
||||
<Text>Curtain Wall and Grid</Text>
|
||||
<Description>Create a curtain wall and edit its grid</Description>
|
||||
<VisibilityMode>AlwaysVisible</VisibilityMode>
|
||||
<VendorId>ADSK</VendorId>
|
||||
<VendorDescription>Autodesk, www.autodesk.com</VendorDescription>
|
||||
</AddIn>
|
||||
</RevitAddIns>
|
||||
@@ -0,0 +1,118 @@
|
||||
<?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>{C6D32355-2C27-4A24-9BE4-11F3E78C301E}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>CurtainWallGrid</RootNamespace>
|
||||
<AssemblyName>CurtainWallGrid</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.Drawing" />
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="System.Core">
|
||||
<RequiredTargetFramework>3.5</RequiredTargetFramework>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Command.cs" />
|
||||
<Compile Include="GridCoordinates.cs" />
|
||||
<Compile Include="MyDocument.cs" />
|
||||
<Compile Include="GridDrawing.cs" />
|
||||
<Compile Include="GridForm.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="GridForm.Designer.cs">
|
||||
<DependentUpon>GridForm.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="GridGeometry.cs" />
|
||||
<Compile Include="GridLine2D.cs" />
|
||||
<Compile Include="GridProperties.cs" />
|
||||
<Compile Include="MathTools.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Properties\Resources.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DesignTime>True</DesignTime>
|
||||
<DependentUpon>Resources.resx</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Unit.cs" />
|
||||
<Compile Include="Utility.cs" />
|
||||
<Compile Include="WallGeometry.cs" />
|
||||
<Compile Include="WallDrawing.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="GridForm.resx">
|
||||
<SubType>Designer</SubType>
|
||||
<DependentUpon>GridForm.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Properties\Resources.resx">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>ResXFileCodeGenerator</Generator>
|
||||
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
||||
</EmbeddedResource>
|
||||
</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,303 @@
|
||||
//
|
||||
// (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.Text;
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
|
||||
using Autodesk.Revit.DB;
|
||||
using Autodesk.Revit.UI;
|
||||
|
||||
namespace Revit.SDK.Samples.CurtainWallGrid.CS
|
||||
{
|
||||
/// <summary>
|
||||
/// Maintain the matrixes needed by 3D & 2D operations: pan, zoom, 2D->3D, 3D->2D
|
||||
/// </summary>
|
||||
public class GridCoordinates
|
||||
{
|
||||
#region Fields
|
||||
// scale the size of the image to let it shown in the canvas
|
||||
private float m_scaleFactor = 0.85f;
|
||||
|
||||
// the document of this sample
|
||||
private MyDocument m_myDocument;
|
||||
|
||||
// stores the current GridDrawing data
|
||||
private GridDrawing m_drawing;
|
||||
|
||||
// stores the client rectangle of the canvas of the curtain grid
|
||||
// will be used in the scale matrix and move-to-center matrix
|
||||
private System.Drawing.Rectangle m_boundary;
|
||||
|
||||
// stores the midpoint of the client rectangle
|
||||
// will be used in the scale matrix and move-to-center matrix
|
||||
private System.Drawing.Point m_center;
|
||||
|
||||
// store the Matrix used to transform 3D points to 2D
|
||||
Matrix4 m_to2DMatrix = null;
|
||||
|
||||
// store the Matrix used to move points to center
|
||||
Matrix4 m_moveToCenterMatrix = null;
|
||||
|
||||
// store the Matrix used to scale profile fit to pictureBox
|
||||
Matrix4 m_scaleMatrix = null;
|
||||
|
||||
// store the Matrix used to transform Revit coordinate to window UI
|
||||
Matrix4 m_transformMatrix = null;
|
||||
|
||||
// store the Matrix used to transform window UI coordinate to Revit
|
||||
Matrix4 m_restoreMatrix = null;
|
||||
|
||||
// stores the boundary of the curtain grid
|
||||
List<PointF> m_boundPoints;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
/// <summary>
|
||||
/// stores the GridDrawing data used in the current dialog
|
||||
/// </summary>
|
||||
public GridDrawing Drawing
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_drawing;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_drawing = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// store the Matrix used to transform 3D points to 2D
|
||||
/// </summary>
|
||||
public Matrix4 To2DMatrix
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_to2DMatrix;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// store the Matrix used to transform Revit coordinate to window UI
|
||||
/// </summary>
|
||||
public Matrix4 TransformMatrix
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_transformMatrix;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// store the Matrix used to transform window UI coordinate to Revit
|
||||
/// </summary>
|
||||
public Matrix4 RestoreMatrix
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_restoreMatrix;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
/// <summary>
|
||||
/// constructor
|
||||
/// </summary>
|
||||
/// <param name="myDoc">
|
||||
/// the document of this sample
|
||||
/// </param>
|
||||
/// <param name="drawing">
|
||||
/// the GridDrawing data used in the dialog
|
||||
/// </param>
|
||||
public GridCoordinates(MyDocument myDoc, GridDrawing drawing)
|
||||
{
|
||||
m_myDocument = myDoc;
|
||||
|
||||
if (null == drawing)
|
||||
{
|
||||
TaskDialog.Show("Revit", "Error! There's no grid information in the curtain wall.");
|
||||
}
|
||||
m_drawing = drawing;
|
||||
drawing.Coordinates = this;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Public Methods
|
||||
/// <summary>
|
||||
/// obtain the matrixes used in this dialog
|
||||
/// </summary>
|
||||
public void GetMatrix()
|
||||
{
|
||||
// initialize the class members, obtain the location information of the canvas
|
||||
m_boundary = m_drawing.Boundary;
|
||||
m_center = m_drawing.Center;
|
||||
|
||||
// Get a matrix which can transform points to 2D
|
||||
m_to2DMatrix = GetTo2DMatrix();
|
||||
|
||||
// get the vertexes of the canvas (in Point/PointF format)
|
||||
m_boundPoints = GetBoundsPoints();
|
||||
|
||||
// get a matrix which can keep all the points in the center of the canvas
|
||||
m_moveToCenterMatrix = GetMoveToCenterMatrix();
|
||||
|
||||
// get a matrix for scaling all the points and lines within the canvas
|
||||
m_scaleMatrix = GetScaleMatrix();
|
||||
|
||||
// transform 3D points to 2D
|
||||
m_transformMatrix = Get3DTo2DMatrix();
|
||||
|
||||
// transform from 2D to 3D
|
||||
m_restoreMatrix = Get2DTo3DMatrix();
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Private Methods
|
||||
/// <summary>
|
||||
/// calculate the matrix used to transform 2D to 3D
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// matrix used to transform 2d points to 3d
|
||||
/// </returns>
|
||||
private Matrix4 Get2DTo3DMatrix()
|
||||
{
|
||||
Matrix4 matrix = Matrix4.Multiply(
|
||||
new Matrix4(new Vector4(-m_center.X, -m_center.Y, 0)), m_scaleMatrix.Inverse());
|
||||
matrix = Matrix4.Multiply(
|
||||
matrix, m_moveToCenterMatrix);
|
||||
return Matrix4.Multiply(matrix, m_to2DMatrix);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// calculate the matrix used to transform 3D to 2D
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// matrix used to transform 3d points to 2d
|
||||
/// </returns>
|
||||
private Matrix4 Get3DTo2DMatrix()
|
||||
{
|
||||
Matrix4 result = Matrix4.Multiply(
|
||||
m_to2DMatrix.Inverse(), m_moveToCenterMatrix.Inverse());
|
||||
result = Matrix4.Multiply(result, m_scaleMatrix);
|
||||
return Matrix4.Multiply(result, new Matrix4(new Vector4(m_center.X, m_center.Y, 0)));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// calculate the matrix used to scale
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// matrix used to scale the to-be-painted image
|
||||
/// </returns>
|
||||
private Matrix4 GetScaleMatrix()
|
||||
{
|
||||
float xScale = m_boundary.Width / (m_boundPoints[1].X - m_boundPoints[0].X);
|
||||
float yScale = m_boundary.Height / (m_boundPoints[1].Y - m_boundPoints[0].Y);
|
||||
float factor = xScale <= yScale ? xScale : yScale;
|
||||
return new Matrix4((float)(factor * m_scaleFactor));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get a matrix which can move points to center
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// matrix used to move point to center of canvas
|
||||
/// </returns>
|
||||
private Matrix4 GetMoveToCenterMatrix()
|
||||
{
|
||||
//translate the origin to bound center
|
||||
PointF min = m_boundPoints[0];
|
||||
PointF max = m_boundPoints[1];
|
||||
PointF center = new PointF((min.X + max.X) / 2, (min.Y + max.Y) / 2);
|
||||
return new Matrix4(new Vector4(center.X, center.Y, 0));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get max and min coordinates of all points
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// points array stores the bounding box of all points
|
||||
/// </returns>
|
||||
private List<PointF> GetBoundsPoints()
|
||||
{
|
||||
Matrix4 matrix = m_to2DMatrix;
|
||||
Matrix4 inverseMatrix = matrix.Inverse();
|
||||
float minX = 0, maxX = 0, minY = 0, maxY = 0;
|
||||
bool bFirstPoint = true;
|
||||
List<PointF> resultPoints = new List<PointF>();
|
||||
|
||||
//get the max and min point on the face
|
||||
foreach (Autodesk.Revit.DB.XYZ point in m_drawing.Geometry.GridVertexesXYZ)
|
||||
{
|
||||
Vector4 v = new Vector4(point);
|
||||
Vector4 v1 = inverseMatrix.Transform(v);
|
||||
|
||||
if (bFirstPoint)
|
||||
{
|
||||
minX = maxX = v1.X;
|
||||
minY = maxY = v1.Y;
|
||||
bFirstPoint = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (v1.X < minX) { minX = v1.X; }
|
||||
else if (v1.X > maxX) { maxX = v1.X; }
|
||||
|
||||
if (v1.Y < minY) { minY = v1.Y; }
|
||||
else if (v1.Y > maxY) { maxY = v1.Y; }
|
||||
}
|
||||
}
|
||||
resultPoints.Add(new PointF(minX, minY));
|
||||
resultPoints.Add(new PointF(maxX, maxY));
|
||||
return resultPoints;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get a matrix which can transform points to 2D
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// matrix which can transform points to 2D
|
||||
/// </returns>
|
||||
private Matrix4 GetTo2DMatrix()
|
||||
{
|
||||
Autodesk.Revit.DB.XYZ startXYZ = m_myDocument.WallGeometry.StartXYZ;
|
||||
Autodesk.Revit.DB.XYZ endXYZ = m_myDocument.WallGeometry.EndXYZ;
|
||||
XYZ sub = endXYZ - startXYZ;
|
||||
Vector4 xAxis = new Vector4(new Autodesk.Revit.DB.XYZ(sub.X, sub.Y, sub.Z));
|
||||
xAxis.Normalize();
|
||||
//because in the windows UI, Y axis is downward
|
||||
Vector4 yAxis = new Vector4(new Autodesk.Revit.DB.XYZ(0, 0, -1));
|
||||
yAxis.Normalize();
|
||||
Vector4 zAxis = Vector4.CrossProduct(xAxis, yAxis);
|
||||
zAxis.Normalize();
|
||||
Vector4 origin = new Vector4(m_drawing.Geometry.GridVertexesXYZ[0]);
|
||||
|
||||
return new Matrix4(xAxis, yAxis, zAxis, origin);
|
||||
}
|
||||
#endregion
|
||||
} // end of class
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
+412
@@ -0,0 +1,412 @@
|
||||
//
|
||||
// (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.CurtainWallGrid.CS
|
||||
{
|
||||
partial class GridForm
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.mainTabControl = new System.Windows.Forms.TabControl();
|
||||
this.curtainWallTabPage = new System.Windows.Forms.TabPage();
|
||||
this.exitButton = new System.Windows.Forms.Button();
|
||||
this.wallTypeMsgLabel = new System.Windows.Forms.Label();
|
||||
this.viewMsgLabel = new System.Windows.Forms.Label();
|
||||
this.createButton = new System.Windows.Forms.Button();
|
||||
this.clearButton = new System.Windows.Forms.Button();
|
||||
this.wallTypelabel = new System.Windows.Forms.Label();
|
||||
this.wallTypeComboBox = new System.Windows.Forms.ComboBox();
|
||||
this.viewLabel = new System.Windows.Forms.Label();
|
||||
this.viewComboBox = new System.Windows.Forms.ComboBox();
|
||||
this.curtainWallPictureBox = new System.Windows.Forms.PictureBox();
|
||||
this.curtainGridTabPage = new System.Windows.Forms.TabPage();
|
||||
this.gridPropertyPanel = new System.Windows.Forms.Panel();
|
||||
this.gridExitButton = new System.Windows.Forms.Button();
|
||||
this.curtainGridPropertyGrid = new System.Windows.Forms.PropertyGrid();
|
||||
this.curtainGridPicturePanel = new System.Windows.Forms.Panel();
|
||||
this.gridOperationLabel = new System.Windows.Forms.Label();
|
||||
this.lineOperationsComboBox = new System.Windows.Forms.ComboBox();
|
||||
this.curtainGridPictureBox = new System.Windows.Forms.PictureBox();
|
||||
this.statusStrip = new System.Windows.Forms.StatusStrip();
|
||||
this.operationStatusLabel = new System.Windows.Forms.ToolStripStatusLabel();
|
||||
this.mainPanel = new System.Windows.Forms.Panel();
|
||||
this.mainTabControl.SuspendLayout();
|
||||
this.curtainWallTabPage.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.curtainWallPictureBox)).BeginInit();
|
||||
this.curtainGridTabPage.SuspendLayout();
|
||||
this.gridPropertyPanel.SuspendLayout();
|
||||
this.curtainGridPicturePanel.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.curtainGridPictureBox)).BeginInit();
|
||||
this.statusStrip.SuspendLayout();
|
||||
this.mainPanel.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// mainTabControl
|
||||
//
|
||||
this.mainTabControl.Controls.Add(this.curtainWallTabPage);
|
||||
this.mainTabControl.Controls.Add(this.curtainGridTabPage);
|
||||
this.mainTabControl.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.mainTabControl.Location = new System.Drawing.Point(0, 0);
|
||||
this.mainTabControl.Name = "mainTabControl";
|
||||
this.mainTabControl.SelectedIndex = 0;
|
||||
this.mainTabControl.Size = new System.Drawing.Size(467, 321);
|
||||
this.mainTabControl.TabIndex = 0;
|
||||
this.mainTabControl.SelectedIndexChanged += new System.EventHandler(this.mainTabControl_SelectedIndexChanged);
|
||||
this.mainTabControl.Selecting += new System.Windows.Forms.TabControlCancelEventHandler(this.mainTabControl_Selecting);
|
||||
this.mainTabControl.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.mainTabControl_KeyPress);
|
||||
//
|
||||
// curtainWallTabPage
|
||||
//
|
||||
this.curtainWallTabPage.Controls.Add(this.exitButton);
|
||||
this.curtainWallTabPage.Controls.Add(this.wallTypeMsgLabel);
|
||||
this.curtainWallTabPage.Controls.Add(this.viewMsgLabel);
|
||||
this.curtainWallTabPage.Controls.Add(this.createButton);
|
||||
this.curtainWallTabPage.Controls.Add(this.clearButton);
|
||||
this.curtainWallTabPage.Controls.Add(this.wallTypelabel);
|
||||
this.curtainWallTabPage.Controls.Add(this.wallTypeComboBox);
|
||||
this.curtainWallTabPage.Controls.Add(this.viewLabel);
|
||||
this.curtainWallTabPage.Controls.Add(this.viewComboBox);
|
||||
this.curtainWallTabPage.Controls.Add(this.curtainWallPictureBox);
|
||||
this.curtainWallTabPage.Location = new System.Drawing.Point(4, 22);
|
||||
this.curtainWallTabPage.Name = "curtainWallTabPage";
|
||||
this.curtainWallTabPage.Padding = new System.Windows.Forms.Padding(3);
|
||||
this.curtainWallTabPage.Size = new System.Drawing.Size(459, 295);
|
||||
this.curtainWallTabPage.TabIndex = 0;
|
||||
this.curtainWallTabPage.Text = "Create Curtain Wall";
|
||||
this.curtainWallTabPage.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// exitButton
|
||||
//
|
||||
this.exitButton.Anchor = System.Windows.Forms.AnchorStyles.Right;
|
||||
this.exitButton.DialogResult = System.Windows.Forms.DialogResult.Cancel;
|
||||
this.exitButton.Location = new System.Drawing.Point(276, 262);
|
||||
this.exitButton.Name = "exitButton";
|
||||
this.exitButton.Size = new System.Drawing.Size(165, 23);
|
||||
this.exitButton.TabIndex = 7;
|
||||
this.exitButton.Text = "E&xit";
|
||||
this.exitButton.UseVisualStyleBackColor = true;
|
||||
this.exitButton.Click += new System.EventHandler(this.exitButton_Click);
|
||||
//
|
||||
// wallTypeMsgLabel
|
||||
//
|
||||
this.wallTypeMsgLabel.Anchor = System.Windows.Forms.AnchorStyles.Right;
|
||||
this.wallTypeMsgLabel.AutoSize = true;
|
||||
this.wallTypeMsgLabel.Location = new System.Drawing.Point(273, 88);
|
||||
this.wallTypeMsgLabel.Name = "wallTypeMsgLabel";
|
||||
this.wallTypeMsgLabel.Size = new System.Drawing.Size(107, 13);
|
||||
this.wallTypeMsgLabel.TabIndex = 6;
|
||||
this.wallTypeMsgLabel.Text = "Specify the wall type:";
|
||||
//
|
||||
// viewMsgLabel
|
||||
//
|
||||
this.viewMsgLabel.Anchor = System.Windows.Forms.AnchorStyles.Right;
|
||||
this.viewMsgLabel.AutoSize = true;
|
||||
this.viewMsgLabel.Location = new System.Drawing.Point(273, 36);
|
||||
this.viewMsgLabel.Name = "viewMsgLabel";
|
||||
this.viewMsgLabel.Size = new System.Drawing.Size(168, 13);
|
||||
this.viewMsgLabel.TabIndex = 5;
|
||||
this.viewMsgLabel.Text = "Specify a view for the curtain wall:";
|
||||
//
|
||||
// createButton
|
||||
//
|
||||
this.createButton.Anchor = System.Windows.Forms.AnchorStyles.Right;
|
||||
this.createButton.Enabled = false;
|
||||
this.createButton.Location = new System.Drawing.Point(276, 186);
|
||||
this.createButton.Name = "createButton";
|
||||
this.createButton.Size = new System.Drawing.Size(165, 23);
|
||||
this.createButton.TabIndex = 4;
|
||||
this.createButton.Text = "Create Curtain &Wall";
|
||||
this.createButton.UseVisualStyleBackColor = true;
|
||||
this.createButton.Click += new System.EventHandler(this.createButton_Click);
|
||||
//
|
||||
// clearButton
|
||||
//
|
||||
this.clearButton.Anchor = System.Windows.Forms.AnchorStyles.Right;
|
||||
this.clearButton.Enabled = false;
|
||||
this.clearButton.Location = new System.Drawing.Point(276, 147);
|
||||
this.clearButton.Name = "clearButton";
|
||||
this.clearButton.Size = new System.Drawing.Size(165, 23);
|
||||
this.clearButton.TabIndex = 3;
|
||||
this.clearButton.Text = "&Clear Baseline";
|
||||
this.clearButton.UseVisualStyleBackColor = true;
|
||||
this.clearButton.Click += new System.EventHandler(this.clearButton_Click);
|
||||
//
|
||||
// wallTypelabel
|
||||
//
|
||||
this.wallTypelabel.Anchor = System.Windows.Forms.AnchorStyles.Right;
|
||||
this.wallTypelabel.AutoSize = true;
|
||||
this.wallTypelabel.Location = new System.Drawing.Point(273, 112);
|
||||
this.wallTypelabel.Name = "wallTypelabel";
|
||||
this.wallTypelabel.Size = new System.Drawing.Size(37, 13);
|
||||
this.wallTypelabel.TabIndex = 4;
|
||||
this.wallTypelabel.Text = " Type:";
|
||||
//
|
||||
// wallTypeComboBox
|
||||
//
|
||||
this.wallTypeComboBox.Anchor = System.Windows.Forms.AnchorStyles.Right;
|
||||
this.wallTypeComboBox.AutoCompleteMode = System.Windows.Forms.AutoCompleteMode.SuggestAppend;
|
||||
this.wallTypeComboBox.AutoCompleteSource = System.Windows.Forms.AutoCompleteSource.ListItems;
|
||||
this.wallTypeComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.wallTypeComboBox.FormattingEnabled = true;
|
||||
this.wallTypeComboBox.Location = new System.Drawing.Point(312, 109);
|
||||
this.wallTypeComboBox.Name = "wallTypeComboBox";
|
||||
this.wallTypeComboBox.Size = new System.Drawing.Size(129, 21);
|
||||
this.wallTypeComboBox.TabIndex = 2;
|
||||
this.wallTypeComboBox.SelectedIndexChanged += new System.EventHandler(this.wallTypeComboBox_SelectedIndexChanged);
|
||||
//
|
||||
// viewLabel
|
||||
//
|
||||
this.viewLabel.Anchor = System.Windows.Forms.AnchorStyles.Right;
|
||||
this.viewLabel.AutoSize = true;
|
||||
this.viewLabel.Location = new System.Drawing.Point(273, 62);
|
||||
this.viewLabel.Name = "viewLabel";
|
||||
this.viewLabel.Size = new System.Drawing.Size(33, 13);
|
||||
this.viewLabel.TabIndex = 2;
|
||||
this.viewLabel.Text = "View:";
|
||||
//
|
||||
// viewComboBox
|
||||
//
|
||||
this.viewComboBox.Anchor = System.Windows.Forms.AnchorStyles.Right;
|
||||
this.viewComboBox.AutoCompleteMode = System.Windows.Forms.AutoCompleteMode.SuggestAppend;
|
||||
this.viewComboBox.AutoCompleteSource = System.Windows.Forms.AutoCompleteSource.ListItems;
|
||||
this.viewComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.viewComboBox.FormattingEnabled = true;
|
||||
this.viewComboBox.Location = new System.Drawing.Point(312, 59);
|
||||
this.viewComboBox.Name = "viewComboBox";
|
||||
this.viewComboBox.Size = new System.Drawing.Size(129, 21);
|
||||
this.viewComboBox.TabIndex = 1;
|
||||
this.viewComboBox.SelectedIndexChanged += new System.EventHandler(this.viewComboBox_SelectedIndexChanged);
|
||||
//
|
||||
// curtainWallPictureBox
|
||||
//
|
||||
this.curtainWallPictureBox.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
|
||||
this.curtainWallPictureBox.Dock = System.Windows.Forms.DockStyle.Left;
|
||||
this.curtainWallPictureBox.Location = new System.Drawing.Point(3, 3);
|
||||
this.curtainWallPictureBox.Name = "curtainWallPictureBox";
|
||||
this.curtainWallPictureBox.Size = new System.Drawing.Size(266, 289);
|
||||
this.curtainWallPictureBox.TabIndex = 0;
|
||||
this.curtainWallPictureBox.TabStop = false;
|
||||
this.curtainWallPictureBox.Paint += new System.Windows.Forms.PaintEventHandler(this.curtainWallPictureBox_Paint);
|
||||
this.curtainWallPictureBox.MouseClick += new System.Windows.Forms.MouseEventHandler(this.curtainWallPictureBox_MouseClick);
|
||||
this.curtainWallPictureBox.MouseMove += new System.Windows.Forms.MouseEventHandler(this.curtainWallPictureBox_MouseMove);
|
||||
//
|
||||
// curtainGridTabPage
|
||||
//
|
||||
this.curtainGridTabPage.Controls.Add(this.gridPropertyPanel);
|
||||
this.curtainGridTabPage.Controls.Add(this.curtainGridPicturePanel);
|
||||
this.curtainGridTabPage.Location = new System.Drawing.Point(4, 22);
|
||||
this.curtainGridTabPage.Name = "curtainGridTabPage";
|
||||
this.curtainGridTabPage.Padding = new System.Windows.Forms.Padding(3);
|
||||
this.curtainGridTabPage.Size = new System.Drawing.Size(459, 295);
|
||||
this.curtainGridTabPage.TabIndex = 1;
|
||||
this.curtainGridTabPage.Text = "Curtain Grid";
|
||||
this.curtainGridTabPage.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// gridPropertyPanel
|
||||
//
|
||||
this.gridPropertyPanel.Controls.Add(this.gridExitButton);
|
||||
this.gridPropertyPanel.Controls.Add(this.curtainGridPropertyGrid);
|
||||
this.gridPropertyPanel.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.gridPropertyPanel.Location = new System.Drawing.Point(295, 3);
|
||||
this.gridPropertyPanel.Name = "gridPropertyPanel";
|
||||
this.gridPropertyPanel.Size = new System.Drawing.Size(161, 289);
|
||||
this.gridPropertyPanel.TabIndex = 2;
|
||||
//
|
||||
// gridExitButton
|
||||
//
|
||||
this.gridExitButton.Location = new System.Drawing.Point(15, 264);
|
||||
this.gridExitButton.Name = "gridExitButton";
|
||||
this.gridExitButton.Size = new System.Drawing.Size(132, 24);
|
||||
this.gridExitButton.TabIndex = 1;
|
||||
this.gridExitButton.Text = "E&xit";
|
||||
this.gridExitButton.UseVisualStyleBackColor = true;
|
||||
this.gridExitButton.Click += new System.EventHandler(this.gridExitButton_Click);
|
||||
//
|
||||
// curtainGridPropertyGrid
|
||||
//
|
||||
this.curtainGridPropertyGrid.CategoryForeColor = System.Drawing.SystemColors.InactiveCaptionText;
|
||||
this.curtainGridPropertyGrid.Dock = System.Windows.Forms.DockStyle.Top;
|
||||
this.curtainGridPropertyGrid.HelpVisible = false;
|
||||
this.curtainGridPropertyGrid.Location = new System.Drawing.Point(0, 0);
|
||||
this.curtainGridPropertyGrid.Name = "curtainGridPropertyGrid";
|
||||
this.curtainGridPropertyGrid.PropertySort = System.Windows.Forms.PropertySort.Categorized;
|
||||
this.curtainGridPropertyGrid.Size = new System.Drawing.Size(161, 262);
|
||||
this.curtainGridPropertyGrid.TabIndex = 0;
|
||||
this.curtainGridPropertyGrid.ToolbarVisible = false;
|
||||
//
|
||||
// curtainGridPicturePanel
|
||||
//
|
||||
this.curtainGridPicturePanel.Controls.Add(this.gridOperationLabel);
|
||||
this.curtainGridPicturePanel.Controls.Add(this.lineOperationsComboBox);
|
||||
this.curtainGridPicturePanel.Controls.Add(this.curtainGridPictureBox);
|
||||
this.curtainGridPicturePanel.Dock = System.Windows.Forms.DockStyle.Left;
|
||||
this.curtainGridPicturePanel.Location = new System.Drawing.Point(3, 3);
|
||||
this.curtainGridPicturePanel.Name = "curtainGridPicturePanel";
|
||||
this.curtainGridPicturePanel.Size = new System.Drawing.Size(292, 289);
|
||||
this.curtainGridPicturePanel.TabIndex = 1;
|
||||
//
|
||||
// gridOperationLabel
|
||||
//
|
||||
this.gridOperationLabel.AutoSize = true;
|
||||
this.gridOperationLabel.Location = new System.Drawing.Point(4, 270);
|
||||
this.gridOperationLabel.Name = "gridOperationLabel";
|
||||
this.gridOperationLabel.Size = new System.Drawing.Size(78, 13);
|
||||
this.gridOperationLabel.TabIndex = 3;
|
||||
this.gridOperationLabel.Text = "Grid Operation:";
|
||||
//
|
||||
// lineOperationsComboBox
|
||||
//
|
||||
this.lineOperationsComboBox.AutoCompleteMode = System.Windows.Forms.AutoCompleteMode.SuggestAppend;
|
||||
this.lineOperationsComboBox.AutoCompleteSource = System.Windows.Forms.AutoCompleteSource.ListItems;
|
||||
this.lineOperationsComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.lineOperationsComboBox.FormattingEnabled = true;
|
||||
this.lineOperationsComboBox.Location = new System.Drawing.Point(86, 267);
|
||||
this.lineOperationsComboBox.Name = "lineOperationsComboBox";
|
||||
this.lineOperationsComboBox.Size = new System.Drawing.Size(191, 21);
|
||||
this.lineOperationsComboBox.TabIndex = 2;
|
||||
this.lineOperationsComboBox.SelectedIndexChanged += new System.EventHandler(this.lineOperationsComboBox_SelectedIndexChanged);
|
||||
//
|
||||
// curtainGridPictureBox
|
||||
//
|
||||
this.curtainGridPictureBox.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
|
||||
this.curtainGridPictureBox.Dock = System.Windows.Forms.DockStyle.Top;
|
||||
this.curtainGridPictureBox.Location = new System.Drawing.Point(0, 0);
|
||||
this.curtainGridPictureBox.Name = "curtainGridPictureBox";
|
||||
this.curtainGridPictureBox.Size = new System.Drawing.Size(292, 262);
|
||||
this.curtainGridPictureBox.TabIndex = 0;
|
||||
this.curtainGridPictureBox.TabStop = false;
|
||||
this.curtainGridPictureBox.Paint += new System.Windows.Forms.PaintEventHandler(this.curtainGridPictureBox_Paint);
|
||||
this.curtainGridPictureBox.MouseClick += new System.Windows.Forms.MouseEventHandler(this.curtainGridPictureBox_MouseClick);
|
||||
this.curtainGridPictureBox.MouseMove += new System.Windows.Forms.MouseEventHandler(this.curtainGridPictureBox_MouseMove);
|
||||
//
|
||||
// statusStrip
|
||||
//
|
||||
this.statusStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.operationStatusLabel});
|
||||
this.statusStrip.Location = new System.Drawing.Point(0, 321);
|
||||
this.statusStrip.Name = "statusStrip";
|
||||
this.statusStrip.Size = new System.Drawing.Size(467, 22);
|
||||
this.statusStrip.SizingGrip = false;
|
||||
this.statusStrip.Stretch = false;
|
||||
this.statusStrip.TabIndex = 1;
|
||||
//
|
||||
// operationStatusLabel
|
||||
//
|
||||
this.operationStatusLabel.Name = "operationStatusLabel";
|
||||
this.operationStatusLabel.Size = new System.Drawing.Size(0, 17);
|
||||
//
|
||||
// mainPanel
|
||||
//
|
||||
this.mainPanel.Controls.Add(this.mainTabControl);
|
||||
this.mainPanel.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.mainPanel.Location = new System.Drawing.Point(0, 0);
|
||||
this.mainPanel.Name = "mainPanel";
|
||||
this.mainPanel.Size = new System.Drawing.Size(467, 321);
|
||||
this.mainPanel.TabIndex = 2;
|
||||
//
|
||||
// GridForm
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(467, 343);
|
||||
this.Controls.Add(this.mainPanel);
|
||||
this.Controls.Add(this.statusStrip);
|
||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
|
||||
this.KeyPreview = true;
|
||||
this.MaximizeBox = false;
|
||||
this.MinimizeBox = false;
|
||||
this.Name = "GridForm";
|
||||
this.ShowIcon = false;
|
||||
this.ShowInTaskbar = false;
|
||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
|
||||
this.Text = "Curtain Wall";
|
||||
this.Load += new System.EventHandler(this.GridForm_Load);
|
||||
this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.GridForm_KeyDown);
|
||||
this.KeyUp += new System.Windows.Forms.KeyEventHandler(this.GridForm_KeyUp);
|
||||
this.mainTabControl.ResumeLayout(false);
|
||||
this.curtainWallTabPage.ResumeLayout(false);
|
||||
this.curtainWallTabPage.PerformLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.curtainWallPictureBox)).EndInit();
|
||||
this.curtainGridTabPage.ResumeLayout(false);
|
||||
this.gridPropertyPanel.ResumeLayout(false);
|
||||
this.curtainGridPicturePanel.ResumeLayout(false);
|
||||
this.curtainGridPicturePanel.PerformLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.curtainGridPictureBox)).EndInit();
|
||||
this.statusStrip.ResumeLayout(false);
|
||||
this.statusStrip.PerformLayout();
|
||||
this.mainPanel.ResumeLayout(false);
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.TabControl mainTabControl;
|
||||
private System.Windows.Forms.TabPage curtainWallTabPage;
|
||||
private System.Windows.Forms.TabPage curtainGridTabPage;
|
||||
private System.Windows.Forms.PictureBox curtainWallPictureBox;
|
||||
private System.Windows.Forms.Label viewLabel;
|
||||
private System.Windows.Forms.ComboBox viewComboBox;
|
||||
private System.Windows.Forms.Label wallTypelabel;
|
||||
private System.Windows.Forms.ComboBox wallTypeComboBox;
|
||||
private System.Windows.Forms.Button createButton;
|
||||
private System.Windows.Forms.Button clearButton;
|
||||
private System.Windows.Forms.PropertyGrid curtainGridPropertyGrid;
|
||||
private System.Windows.Forms.StatusStrip statusStrip;
|
||||
private System.Windows.Forms.Panel mainPanel;
|
||||
private System.Windows.Forms.ToolStripStatusLabel operationStatusLabel;
|
||||
private System.Windows.Forms.Panel curtainGridPicturePanel;
|
||||
private System.Windows.Forms.PictureBox curtainGridPictureBox;
|
||||
private System.Windows.Forms.ComboBox lineOperationsComboBox;
|
||||
private System.Windows.Forms.Label gridOperationLabel;
|
||||
private System.Windows.Forms.Button exitButton;
|
||||
private System.Windows.Forms.Label wallTypeMsgLabel;
|
||||
private System.Windows.Forms.Label viewMsgLabel;
|
||||
private System.Windows.Forms.Panel gridPropertyPanel;
|
||||
private System.Windows.Forms.Button gridExitButton;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,923 @@
|
||||
//
|
||||
// (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.Data;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Drawing2D;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
|
||||
using Autodesk.Revit;
|
||||
using Autodesk.Revit.DB;
|
||||
|
||||
namespace Revit.SDK.Samples.CurtainWallGrid.CS
|
||||
{
|
||||
/// <summary>
|
||||
/// the main windows form for users to operate on
|
||||
/// users can create curtain walls in the 1st tab page
|
||||
/// and manipulate the grid details in the 2nd tab page
|
||||
/// </summary>
|
||||
public partial class GridForm : System.Windows.Forms.Form
|
||||
{
|
||||
#region Fields
|
||||
// store the document of this sample
|
||||
MyDocument m_myDocument;
|
||||
|
||||
// store whether the line to be moved has been selected
|
||||
// if the line to be moved has been selected, it's true; otherwise false
|
||||
private bool m_lineToMoveSelected = false;
|
||||
|
||||
// store the mouse location of last execution operation (happened when the mouse clicks down)
|
||||
private System.Drawing.Point m_lastPoint = System.Drawing.Point.Empty;
|
||||
|
||||
// stores the Ctrl key status: if Ctrl is down, the value of the variable true; otherwise false
|
||||
private bool m_ctrlKeyDown = false;
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
/// <summary>
|
||||
/// constructor
|
||||
/// </summary>
|
||||
/// <param name="myDoc">
|
||||
/// store the document of this sample
|
||||
/// </param>
|
||||
public GridForm(MyDocument myDoc)
|
||||
{
|
||||
m_myDocument = myDoc;
|
||||
if (null == m_myDocument.UIDocument)
|
||||
{
|
||||
this.Close();
|
||||
}
|
||||
|
||||
InitializeComponent();
|
||||
InitializeCustomComponent();
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Private methods
|
||||
/// <summary>
|
||||
/// initialize the special UI controls which needed to be initialized manually
|
||||
/// </summary>
|
||||
private void InitializeCustomComponent()
|
||||
{
|
||||
// moniter the sample message change status
|
||||
m_myDocument.MessageChanged += new MyDocument.MessageChangedHandler(m_myDocument_MessageChanged);
|
||||
|
||||
foreach (WallType type in m_myDocument.WallTypes)
|
||||
{
|
||||
wallTypeComboBox.Items.Add(type.Name);
|
||||
}
|
||||
|
||||
// add items to the views combo box
|
||||
foreach (Autodesk.Revit.DB.View view in m_myDocument.Views)
|
||||
{
|
||||
string name = view.ViewType + " : " + view.Name;
|
||||
viewComboBox.Items.Add(name);
|
||||
}
|
||||
|
||||
// add items to the lineOperationsComboBox
|
||||
lineOperationsComboBox.Items.Add(new LineOperation(LineOperationType.AddULine));
|
||||
lineOperationsComboBox.Items.Add(new LineOperation(LineOperationType.AddVLine));
|
||||
lineOperationsComboBox.Items.Add(new LineOperation(LineOperationType.LockOrUnlockLine));
|
||||
lineOperationsComboBox.Items.Add(new LineOperation(LineOperationType.MoveLine));
|
||||
lineOperationsComboBox.Items.Add(new LineOperation(LineOperationType.AddSegment));
|
||||
lineOperationsComboBox.Items.Add(new LineOperation(LineOperationType.RemoveSegment));
|
||||
lineOperationsComboBox.Items.Add(new LineOperation(LineOperationType.AddAllSegments));
|
||||
lineOperationsComboBox.Items.Add(new LineOperation(LineOperationType.AddAllMullions));
|
||||
lineOperationsComboBox.Items.Add(new LineOperation(LineOperationType.DeleteAllMullions));
|
||||
|
||||
// initialize the wall drawing's canvas information
|
||||
{
|
||||
m_myDocument.WallGeometry.Drawing.Boundary = curtainWallPictureBox.ClientRectangle;
|
||||
System.Drawing.Point rectLocation = curtainWallPictureBox.ClientRectangle.Location;
|
||||
int rectWidth = curtainWallPictureBox.ClientRectangle.Width;
|
||||
int rectHeight = curtainWallPictureBox.ClientRectangle.Height;
|
||||
int midX = rectLocation.X + rectWidth / 2;
|
||||
int midY = rectLocation.X + rectHeight / 2;
|
||||
System.Drawing.Point originPoint = new System.Drawing.Point(midX, midY);
|
||||
m_myDocument.WallGeometry.Drawing.Origin = originPoint;
|
||||
}
|
||||
|
||||
// initialize the grid drawing's information
|
||||
{
|
||||
GridDrawing gridDrawing = m_myDocument.GridGeometry.Drawing;
|
||||
gridDrawing.MouseInGridEvent += new GridDrawing.MouseInGridHandler(Drawing_MouseInGridEvent);
|
||||
gridDrawing.MouseOutGridEvent += new GridDrawing.MouseOutGridHandler(Drawing_MouseOutGridEvent);
|
||||
gridDrawing.Boundary = curtainGridPictureBox.ClientRectangle;
|
||||
// get the midpoint of the canvas region
|
||||
System.Drawing.Point rectLocation = gridDrawing.Boundary.Location;
|
||||
int rectWidth = gridDrawing.Boundary.Width;
|
||||
int rectHeight = gridDrawing.Boundary.Height;
|
||||
int midX = rectLocation.X + rectWidth / 2;
|
||||
int midY = rectLocation.Y + rectHeight / 2;
|
||||
System.Drawing.Point curtainGridMidpoint = new System.Drawing.Point(midX, midY);
|
||||
gridDrawing.Center = curtainGridMidpoint;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// update the status hints in the status strip
|
||||
/// </summary>
|
||||
void m_myDocument_MessageChanged()
|
||||
{
|
||||
//if it's an error / warning message, set the color of the text to red
|
||||
KeyValuePair<string, bool> message = m_myDocument.Message;
|
||||
if (true == message.Value)
|
||||
{
|
||||
this.operationStatusLabel.ForeColor = System.Drawing.Color.Red;
|
||||
}
|
||||
// it's a common hint message, set the color to black
|
||||
else
|
||||
{
|
||||
this.operationStatusLabel.ForeColor = System.Drawing.Color.Black;
|
||||
}
|
||||
this.operationStatusLabel.Text = message.Key;
|
||||
this.statusStrip.Refresh();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// initialize the Windows Form's appearance
|
||||
/// </summary>
|
||||
/// <param name="sender">
|
||||
/// object who sent this event
|
||||
/// </param>
|
||||
/// <param name="e">
|
||||
/// event args
|
||||
/// </param>
|
||||
private void GridForm_Load(object sender, EventArgs e)
|
||||
{
|
||||
this.viewComboBox.SelectedIndex = 0;
|
||||
this.wallTypeComboBox.SelectedIndex = 0;
|
||||
this.operationStatusLabel.Text = "Specify the baseline of the curtain wall by clicking in the canvas area";
|
||||
this.operationStatusLabel.ForeColor = System.Drawing.Color.Black;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// the user specifies a view plan to create the curtain wall
|
||||
/// </summary>
|
||||
/// <param name="sender">
|
||||
/// object who sent this event
|
||||
/// </param>
|
||||
/// <param name="e">
|
||||
/// event args
|
||||
/// </param>
|
||||
private void viewComboBox_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
// find which view is selected in the comboBox by obtaining its SelectedIndex value
|
||||
int indexSelected = viewComboBox.SelectedIndex;
|
||||
// the item selected in the ComboBox and the corresponding ViewPlan in the list have the same index
|
||||
// as we added them in the same order
|
||||
m_myDocument.WallGeometry.SelectedView = (ViewPlan)m_myDocument.Views[indexSelected];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// the user specifies a wall type to create the curtain wall
|
||||
/// </summary>
|
||||
/// <param name="sender">
|
||||
/// object who sent this event
|
||||
/// </param>
|
||||
/// <param name="e">
|
||||
/// event args
|
||||
/// </param>
|
||||
private void wallTypeComboBox_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
// find which wall type is selected in the comboBox by obtaining its SelectedIndex value
|
||||
int indexSelected = wallTypeComboBox.SelectedIndex;
|
||||
// the item selected in the ComboBox and the corresponding WallType in the list have the same index
|
||||
// as we added them in the same order
|
||||
m_myDocument.WallGeometry.SelectedWallType = m_myDocument.WallTypes[indexSelected];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// the user clicks on the canvas to draw the baseline of the curtain wall
|
||||
/// </summary>
|
||||
/// <param name="sender">
|
||||
/// object who sent this event
|
||||
/// </param>
|
||||
/// <param name="e">
|
||||
/// the mouse click event args
|
||||
/// </param>
|
||||
private void curtainWallPictureBox_MouseClick(object sender, MouseEventArgs e)
|
||||
{
|
||||
// if the curtain wall has been created, disable the mouse operation
|
||||
if (true == m_myDocument.WallCreated)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// if there's no end point or just start point specified, allowes to add new points
|
||||
// if both start point and end point specified, just return
|
||||
m_myDocument.WallGeometry.Drawing.AddPoint(e.Location);
|
||||
|
||||
// both start point and end point for the curtain wall creation have been specified.
|
||||
// allows to create the curtain wall now
|
||||
if (System.Drawing.Point.Empty != m_myDocument.WallGeometry.Drawing.WallLine2D.StartPoint &&
|
||||
System.Drawing.Point.Empty != m_myDocument.WallGeometry.Drawing.WallLine2D.EndPoint)
|
||||
{
|
||||
this.operationStatusLabel.ForeColor = System.Drawing.Color.Black;
|
||||
this.operationStatusLabel.Text = "Click \"Create Curtain Wall\" button to create the curtain wall.";
|
||||
this.createButton.Enabled = true;
|
||||
this.clearButton.Enabled = true;
|
||||
this.curtainWallPictureBox.Refresh();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// the user moves the mouse in the canvas to find a point for the baseline of the curtain wall
|
||||
/// </summary>
|
||||
/// <param name="sender">
|
||||
/// object who sent this event
|
||||
/// </param>
|
||||
/// <param name="e">
|
||||
/// the mouse move event args
|
||||
/// </param>
|
||||
private void curtainWallPictureBox_MouseMove(object sender, MouseEventArgs e)
|
||||
{
|
||||
// if the curtain wall has been created, disable the mouse operation
|
||||
if (true == m_myDocument.WallCreated)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// record the mouse location and draw an assistant line and draw hint text to show the current corrdinate
|
||||
m_myDocument.WallGeometry.Drawing.AddMousePosition(e.Location);
|
||||
this.curtainWallPictureBox.Refresh();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// redraw the baseline of the curtain wall
|
||||
/// </summary>
|
||||
/// <param name="sender">
|
||||
/// object who sent this event
|
||||
/// </param>
|
||||
/// <param name="e">
|
||||
/// event args
|
||||
/// </param>
|
||||
private void curtainWallPictureBox_Paint(object sender, PaintEventArgs e)
|
||||
{
|
||||
e.Graphics.SmoothingMode = SmoothingMode.HighQuality;
|
||||
m_myDocument.WallGeometry.Drawing.Draw(e.Graphics, Pens.Blue);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// clear the baseline in the canvas area
|
||||
/// </summary>
|
||||
/// <param name="sender">
|
||||
/// object who sent this event
|
||||
/// </param>
|
||||
/// <param name="e">
|
||||
/// event args
|
||||
/// </param>
|
||||
private void clearButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
// clear the baseline of the curtain wall
|
||||
m_myDocument.WallGeometry.Drawing.RemovePoints();
|
||||
this.curtainWallPictureBox.Refresh();
|
||||
|
||||
// disable the "create curtain wall" button and update the status hint
|
||||
this.clearButton.Enabled = false;
|
||||
this.createButton.Enabled = false;
|
||||
this.operationStatusLabel.Text = "Specify the baseline of the curtain wall by clicking in the canvas area";
|
||||
this.operationStatusLabel.ForeColor = System.Drawing.Color.Black;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// click "Create Curtain Wall" button will create the curtain wall
|
||||
/// </summary>
|
||||
/// <param name="sender">
|
||||
/// object who sent this event
|
||||
/// </param>
|
||||
/// <param name="e">
|
||||
/// event args
|
||||
/// </param>
|
||||
private void createButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
// if the wall has been created, return directly
|
||||
if (true == m_myDocument.WallCreated)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// create the wall
|
||||
Wall wall = m_myDocument.WallGeometry.CreateCurtainWall();
|
||||
if (null == wall)
|
||||
{
|
||||
return;
|
||||
}
|
||||
m_myDocument.CurtainWall = wall;
|
||||
m_myDocument.WallCreated = true;
|
||||
|
||||
// obtain the geometry data of the curtain grid
|
||||
m_myDocument.GridGeometry.ReloadGeometryData();
|
||||
|
||||
// refresh the UI components' status
|
||||
this.wallTypeComboBox.Enabled = false;
|
||||
this.viewComboBox.Enabled = false;
|
||||
this.clearButton.Enabled = false;
|
||||
this.createButton.Enabled = false;
|
||||
this.operationStatusLabel.ForeColor = System.Drawing.Color.Black;
|
||||
this.operationStatusLabel.Text = "Switch to \"Curtain Grid\" tab page to manipulate the curtain grid.";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// the mouse is out of the curtain grid area, change the cursor to default
|
||||
/// </summary>
|
||||
void Drawing_MouseOutGridEvent()
|
||||
{
|
||||
if (false == m_myDocument.WallCreated)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
m_myDocument.GridGeometry.Drawing.DrawObject.Clear();
|
||||
this.Cursor = Cursors.Default;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// the mouse moves into the curtain grid area, change the cursor to cross
|
||||
/// </summary>
|
||||
void Drawing_MouseInGridEvent()
|
||||
{
|
||||
if (false == m_myDocument.WallCreated)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
this.Cursor = Cursors.Cross;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// the user wants to change to another tab page (for example, change from "Create Curtain Wall" to "Curtain Grid")
|
||||
/// if the curtain wall hasn't been created, don't allow to change to "Curtain Grid" tab page
|
||||
/// </summary>
|
||||
/// <param name="sender">
|
||||
/// object who sent this event
|
||||
/// </param>
|
||||
/// <param name="e">
|
||||
/// event args
|
||||
/// </param>
|
||||
private void mainTabControl_Selecting(object sender, TabControlCancelEventArgs e)
|
||||
{
|
||||
// if no curtain wall is created, limits the tab pages to the 1st tab page
|
||||
if (false == m_myDocument.WallCreated)
|
||||
{
|
||||
this.mainTabControl.SelectedIndex = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// the user changes the tab page, update the data in the active tab page
|
||||
/// </summary>
|
||||
/// <param name="sender">
|
||||
/// object who sent this event
|
||||
/// </param>
|
||||
/// <param name="e">
|
||||
/// event args
|
||||
/// </param>
|
||||
private void mainTabControl_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
// if the curtain wall hasn't been created, doesn't allow to change the tab page
|
||||
if (false == m_myDocument.WallCreated)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// change to the curtain grid tab page, reload the properties of the curtain grid
|
||||
if (mainTabControl.SelectedTab == curtainGridTabPage)
|
||||
{
|
||||
UpdatePropertyGrid();
|
||||
this.operationStatusLabel.Text = "Operate the curtain grid by selecting an item from the bottom-left drop down list";
|
||||
this.operationStatusLabel.ForeColor = System.Drawing.Color.Black;
|
||||
}
|
||||
// change back to the curtain wall tab page, update the hint
|
||||
else
|
||||
{
|
||||
// stop the line operation and set it to "Waiting"
|
||||
m_myDocument.GridGeometry.Drawing.DrawObject.Clear();
|
||||
ResetLineOpApprearances();
|
||||
|
||||
// update the status hint
|
||||
this.operationStatusLabel.ForeColor = System.Drawing.Color.Black;
|
||||
this.operationStatusLabel.Text = "Switch to \"Curtain Grid\" tab page to manipulate the curtain grid.";
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// redraw the curtain grid canvas
|
||||
/// </summary>
|
||||
/// <param name="sender">
|
||||
/// object who sent this event
|
||||
/// </param>
|
||||
/// <param name="e">
|
||||
/// event args
|
||||
/// </param>
|
||||
private void curtainGridPictureBox_Paint(object sender, PaintEventArgs e)
|
||||
{
|
||||
m_myDocument.GridGeometry.Drawing.DrawCurtainGrid(e.Graphics);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// the user specifies a grid operation / grid line operation
|
||||
/// </summary>
|
||||
/// <param name="sender">
|
||||
/// object who sent this event
|
||||
/// </param>
|
||||
/// <param name="e">
|
||||
/// event args
|
||||
/// </param>
|
||||
private void lineOperationsComboBox_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
m_myDocument.ActiveOperation = (LineOperation)lineOperationsComboBox.SelectedItem;
|
||||
// update the status hints for the different grid/grid line operations
|
||||
if (LineOperationType.AddULine == m_myDocument.ActiveOperation.OpType)
|
||||
{
|
||||
this.operationStatusLabel.ForeColor = System.Drawing.Color.Black;
|
||||
this.operationStatusLabel.Text = "Specify a point within the curtain grid to locate new grid line";
|
||||
}
|
||||
else if (LineOperationType.AddVLine == m_myDocument.ActiveOperation.OpType)
|
||||
{
|
||||
this.operationStatusLabel.ForeColor = System.Drawing.Color.Black;
|
||||
this.operationStatusLabel.Text = "Specify a point within the curtain grid to locate new grid line";
|
||||
}
|
||||
else if (LineOperationType.LockOrUnlockLine == m_myDocument.ActiveOperation.OpType)
|
||||
{
|
||||
this.operationStatusLabel.ForeColor = System.Drawing.Color.Black;
|
||||
this.operationStatusLabel.Text = "Click on an existing grid line to switch its \"Lock\" status";
|
||||
}
|
||||
else if (LineOperationType.MoveLine == m_myDocument.ActiveOperation.OpType)
|
||||
{
|
||||
this.operationStatusLabel.ForeColor = System.Drawing.Color.Black;
|
||||
this.operationStatusLabel.Text = "Select a grid line & move the mouse, left-click to finish the movement";
|
||||
}
|
||||
else if (LineOperationType.AddSegment == m_myDocument.ActiveOperation.OpType)
|
||||
{
|
||||
this.operationStatusLabel.ForeColor = System.Drawing.Color.Black;
|
||||
this.operationStatusLabel.Text = "Add a segment to the place where a segment has been deleted previously";
|
||||
}
|
||||
else if (LineOperationType.RemoveSegment == m_myDocument.ActiveOperation.OpType)
|
||||
{
|
||||
this.operationStatusLabel.ForeColor = System.Drawing.Color.Black;
|
||||
this.operationStatusLabel.Text = "Remove the segment of the grid line";
|
||||
|
||||
}
|
||||
else if (LineOperationType.AddAllSegments == m_myDocument.ActiveOperation.OpType)
|
||||
{
|
||||
this.operationStatusLabel.ForeColor = System.Drawing.Color.Black;
|
||||
this.operationStatusLabel.Text = "Add all the segments of the selected grid line";
|
||||
}
|
||||
else if (LineOperationType.AddAllMullions == m_myDocument.ActiveOperation.OpType)
|
||||
{
|
||||
this.operationStatusLabel.ForeColor = System.Drawing.Color.Black;
|
||||
this.operationStatusLabel.Text = "Add mullions to all segments";
|
||||
m_myDocument.GridGeometry.AddAllMullions();
|
||||
ResetLineOpApprearances();
|
||||
UpdatePropertyGrid();
|
||||
}
|
||||
else if (LineOperationType.DeleteAllMullions == m_myDocument.ActiveOperation.OpType)
|
||||
{
|
||||
this.operationStatusLabel.ForeColor = System.Drawing.Color.Black;
|
||||
this.operationStatusLabel.Text = "Delete all the mullions of the curtain grid";
|
||||
m_myDocument.GridGeometry.DeleteAllMullions();
|
||||
ResetLineOpApprearances();
|
||||
UpdatePropertyGrid();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// reset the curtain grid operation to "Waiting"
|
||||
/// </summary>
|
||||
private void ResetLineOpApprearances()
|
||||
{
|
||||
// the user doesn't hold Ctrl key down
|
||||
if (false == m_ctrlKeyDown)
|
||||
{
|
||||
m_myDocument.ActiveOperation = new LineOperation(LineOperationType.Waiting);
|
||||
this.Cursor = Cursors.Default;
|
||||
}
|
||||
// cancel the hanged operation : for example: the line to-be-moved has been selected
|
||||
// and press "Esc", cancel the selection
|
||||
m_lineToMoveSelected = false;
|
||||
|
||||
// refresh the canvas area
|
||||
curtainGridPictureBox.Refresh();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// reload the properties of the curtain grid
|
||||
/// </summary>
|
||||
private void UpdatePropertyGrid()
|
||||
{
|
||||
m_myDocument.GridGeometry.ReloadGridProperties();
|
||||
curtainGridPropertyGrid.SelectedObject = m_myDocument.GridGeometry.GridProperties;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// the user clicks on the curtain grid canvas, executes the grid operation / grid line operation
|
||||
/// </summary>
|
||||
/// <param name="sender">object who sent this event</param>
|
||||
/// <param name="e">event args</param>
|
||||
private void curtainGridPictureBox_MouseClick(object sender, MouseEventArgs e)
|
||||
{
|
||||
// add a new U line to the canvas and to Revit
|
||||
if (LineOperationType.AddULine == m_myDocument.ActiveOperation.OpType)
|
||||
{
|
||||
m_myDocument.GridGeometry.AddUGridLine();
|
||||
ResetLineOpApprearances();
|
||||
UpdatePropertyGrid();
|
||||
m_lastPoint = e.Location;
|
||||
}
|
||||
// add a new V line to the canvas and to Revit
|
||||
else if (LineOperationType.AddVLine == m_myDocument.ActiveOperation.OpType)
|
||||
{
|
||||
m_myDocument.GridGeometry.AddVGridLine();
|
||||
ResetLineOpApprearances();
|
||||
UpdatePropertyGrid();
|
||||
m_lastPoint = e.Location;
|
||||
}
|
||||
// toggle the Lock status of the selected grid line
|
||||
else if (LineOperationType.LockOrUnlockLine == m_myDocument.ActiveOperation.OpType)
|
||||
{
|
||||
m_myDocument.GridGeometry.LockOrUnlockSelectedGridLine();
|
||||
ResetLineOpApprearances();
|
||||
UpdatePropertyGrid();
|
||||
//m_lastPoint = e.Location;
|
||||
}
|
||||
// move the selected grid line to a new place
|
||||
else if (LineOperationType.MoveLine == m_myDocument.ActiveOperation.OpType)
|
||||
{
|
||||
// during moving a grid line, the mouse will click twice
|
||||
// the 1st time is to select a grid line to move
|
||||
// the 2nd time is to determine the destination place for the selected grid line
|
||||
|
||||
// the 1st time, select a grid line to move
|
||||
if (false == m_lineToMoveSelected)
|
||||
{
|
||||
// get the line which will be moved
|
||||
bool lineObtained = m_myDocument.GridGeometry.GetLineToBeMoved();
|
||||
if (true == lineObtained)
|
||||
{
|
||||
m_lineToMoveSelected = true;
|
||||
this.operationStatusLabel.ForeColor = System.Drawing.Color.Black;
|
||||
this.operationStatusLabel.Text = "Move the mouse to the expected location, left click to finish the operation";
|
||||
}
|
||||
}
|
||||
// the 2nd time, the to-be-moved grid line specified, specify the destination location
|
||||
else
|
||||
{
|
||||
// the destination point has been set, move to that place
|
||||
bool succeeded = m_myDocument.GridGeometry.MoveGridLine(e.Location);
|
||||
if (true == succeeded)
|
||||
{
|
||||
m_lineToMoveSelected = false;
|
||||
ResetLineOpApprearances();
|
||||
//UpdatePropertyGrid();
|
||||
}
|
||||
}
|
||||
m_lastPoint = e.Location;
|
||||
}
|
||||
// add a segment to the selected place
|
||||
else if (LineOperationType.AddSegment == m_myDocument.ActiveOperation.OpType)
|
||||
{
|
||||
m_myDocument.GridGeometry.AddSegment();
|
||||
ResetLineOpApprearances();
|
||||
UpdatePropertyGrid();
|
||||
m_lastPoint = e.Location;
|
||||
}
|
||||
// remove the selected segment
|
||||
else if (LineOperationType.RemoveSegment == m_myDocument.ActiveOperation.OpType)
|
||||
{
|
||||
m_myDocument.GridGeometry.RemoveSegment();
|
||||
ResetLineOpApprearances();
|
||||
UpdatePropertyGrid();
|
||||
m_lastPoint = e.Location;
|
||||
}
|
||||
// add all the segments of the selected grid line
|
||||
else if (LineOperationType.AddAllSegments == m_myDocument.ActiveOperation.OpType)
|
||||
{
|
||||
m_myDocument.GridGeometry.AddAllSegments();
|
||||
ResetLineOpApprearances();
|
||||
UpdatePropertyGrid();
|
||||
m_lastPoint = e.Location;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// move the mouse in the curtain grid canvas, select the grid line / segment
|
||||
/// </summary>
|
||||
/// <param name="sender">
|
||||
/// object who sent this event
|
||||
/// </param>
|
||||
/// <param name="e">
|
||||
/// event args
|
||||
/// </param>
|
||||
private void curtainGridPictureBox_MouseMove(object sender, MouseEventArgs e)
|
||||
{
|
||||
if (LineOperationType.Waiting == m_myDocument.ActiveOperation.OpType)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// minimize the occurence of this method, if the move offset of the mouse is less than 1
|
||||
// don't regard the mouse has moved
|
||||
if (System.Drawing.Point.Empty != m_lastPoint)
|
||||
{
|
||||
System.Drawing.Point currentPoint = e.Location;
|
||||
if (Math.Abs(currentPoint.X - m_lastPoint.X) < 1 &&
|
||||
Math.Abs(currentPoint.Y - m_lastPoint.Y) < 1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_lastPoint = System.Drawing.Point.Empty;
|
||||
}
|
||||
}
|
||||
|
||||
if (LineOperationType.AddULine == m_myDocument.ActiveOperation.OpType)
|
||||
{
|
||||
m_myDocument.GridGeometry.Drawing.DrawObject.Clear();
|
||||
m_myDocument.GridGeometry.Drawing.AddDashULine(e.Location);
|
||||
this.curtainGridPictureBox.Refresh();
|
||||
}
|
||||
else if (LineOperationType.AddVLine == m_myDocument.ActiveOperation.OpType)
|
||||
{
|
||||
m_myDocument.GridGeometry.Drawing.DrawObject.Clear();
|
||||
m_myDocument.GridGeometry.Drawing.AddDashVLine(e.Location);
|
||||
this.curtainGridPictureBox.Refresh();
|
||||
}
|
||||
else if (LineOperationType.LockOrUnlockLine == m_myDocument.ActiveOperation.OpType)
|
||||
{
|
||||
m_myDocument.GridGeometry.Drawing.DrawObject.Clear();
|
||||
m_myDocument.GridGeometry.Drawing.SelectLine(e.Location, false, false);
|
||||
this.curtainGridPictureBox.Refresh();
|
||||
}
|
||||
else if (LineOperationType.MoveLine == m_myDocument.ActiveOperation.OpType)
|
||||
{
|
||||
// during moving a grid line, the mouse will click twice
|
||||
// the 1st time is to select a grid line to move
|
||||
// the 2nd time is to determine the destination place for the selected grid line
|
||||
if (false == m_lineToMoveSelected)
|
||||
{
|
||||
// get the line which will be moved
|
||||
m_myDocument.GridGeometry.Drawing.DrawObject.Clear();
|
||||
m_myDocument.GridGeometry.Drawing.SelectLine(e.Location, true, false);
|
||||
this.curtainGridPictureBox.Refresh();
|
||||
}
|
||||
else
|
||||
{
|
||||
// determine the destination place for the selected grid line
|
||||
m_myDocument.GridGeometry.Drawing.DrawObject.Clear();
|
||||
m_myDocument.GridGeometry.Drawing.AddDashLine(e.Location);
|
||||
this.curtainGridPictureBox.Refresh();
|
||||
}
|
||||
|
||||
}
|
||||
else if (LineOperationType.AddSegment == m_myDocument.ActiveOperation.OpType)
|
||||
{
|
||||
m_myDocument.GridGeometry.Drawing.DrawObject.Clear();
|
||||
m_myDocument.GridGeometry.Drawing.SelectSegment(e.Location);
|
||||
this.curtainGridPictureBox.Refresh();
|
||||
}
|
||||
else if (LineOperationType.RemoveSegment == m_myDocument.ActiveOperation.OpType)
|
||||
{
|
||||
m_myDocument.GridGeometry.Drawing.DrawObject.Clear();
|
||||
m_myDocument.GridGeometry.Drawing.SelectSegment(e.Location);
|
||||
this.curtainGridPictureBox.Refresh();
|
||||
}
|
||||
else if (LineOperationType.AddAllSegments == m_myDocument.ActiveOperation.OpType)
|
||||
{
|
||||
m_myDocument.GridGeometry.Drawing.DrawObject.Clear();
|
||||
m_myDocument.GridGeometry.Drawing.SelectLine(e.Location, false, true);
|
||||
this.curtainGridPictureBox.Refresh();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// when Ctrl key keeps down, don't set the operation to "default" after an operation finished
|
||||
/// for example, if the selected operation is "Add U grid line" and the Ctrl key keeps down
|
||||
/// after the user draws a U line, he can continue to draw another line, as long as the Ctrl is down
|
||||
/// </summary>
|
||||
/// <param name="sender">
|
||||
/// object who sent this event
|
||||
/// </param>
|
||||
/// <param name="e">
|
||||
/// event args
|
||||
/// </param>
|
||||
private void GridForm_KeyDown(object sender, KeyEventArgs e)
|
||||
{
|
||||
// "e.KeyValue == 17" return true only when "Ctrl" presses down
|
||||
if (e.KeyValue == 17)
|
||||
{
|
||||
m_ctrlKeyDown = true;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// reset the CtrlKeyDown flag to false, indicating that the Ctrl key is no longer down
|
||||
/// so the "continuous" operations will be stopped
|
||||
/// </summary>
|
||||
/// <param name="sender">
|
||||
/// object who sent this event
|
||||
/// </param>
|
||||
/// <param name="e">
|
||||
/// event args
|
||||
/// </param>
|
||||
private void GridForm_KeyUp(object sender, KeyEventArgs e)
|
||||
{
|
||||
// "e.KeyValue == 17" return true only when "Ctrl" presses down
|
||||
if (e.KeyValue == 17)
|
||||
{
|
||||
m_ctrlKeyDown = false;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// the user presses the "ESC" key, quit the current operation
|
||||
/// </summary>
|
||||
/// <param name="sender">
|
||||
/// object who sent this event
|
||||
/// </param>
|
||||
/// <param name="e">
|
||||
/// event args
|
||||
/// </param>
|
||||
private void mainTabControl_KeyPress(object sender, KeyPressEventArgs e)
|
||||
{
|
||||
// check whether the key is"ESC" key (for "ESC" key: e.KeyChar == 27)
|
||||
if (e.KeyChar != (char)27)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (mainTabControl.SelectedTab == curtainWallTabPage)
|
||||
{
|
||||
// context: press "ESC" during drawing the baseline for the curtain wall and not finished the drawing
|
||||
// (not both start point and end point for the curtain wall creation have been specified)
|
||||
// result: clear the baseline points(if have) and disable the "Create" button
|
||||
if (System.Drawing.Point.Empty == m_myDocument.WallGeometry.Drawing.WallLine2D.StartPoint ||
|
||||
System.Drawing.Point.Empty == m_myDocument.WallGeometry.Drawing.WallLine2D.EndPoint)
|
||||
{
|
||||
clearButton_Click(null, null);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// context: press "ESC" during operating the curtain grid
|
||||
// result: stop the current operation and set the operation to "Waiting"
|
||||
m_myDocument.GridGeometry.Drawing.DrawObject.Clear();
|
||||
ResetLineOpApprearances();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// the user clicks the "Exit" button, quit the dialog
|
||||
/// </summary>
|
||||
/// <param name="sender">
|
||||
/// object who sent this event
|
||||
/// </param>
|
||||
/// <param name="e">
|
||||
/// event args
|
||||
/// </param>
|
||||
private void exitButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
this.Close();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// the user clicks the "Exit" button, quit the dialog
|
||||
/// </summary>
|
||||
/// <param name="sender">
|
||||
/// object who sent this event
|
||||
/// </param>
|
||||
/// <param name="e">
|
||||
/// event args
|
||||
/// </param>
|
||||
private void gridExitButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
this.Close();
|
||||
}
|
||||
#endregion
|
||||
}// end of class
|
||||
|
||||
/// <summary>
|
||||
/// lists all the supported line operations in this sample
|
||||
/// </summary>
|
||||
public enum LineOperationType
|
||||
{
|
||||
Waiting,
|
||||
AddULine,
|
||||
AddVLine,
|
||||
LockOrUnlockLine,
|
||||
MoveLine,
|
||||
AddSegment,
|
||||
RemoveSegment,
|
||||
AddAllSegments,
|
||||
AddAllMullions,
|
||||
DeleteAllMullions
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// stores the specified line operation
|
||||
/// </summary>
|
||||
public struct LineOperation
|
||||
{
|
||||
#region Fields
|
||||
// the current line operation type
|
||||
private LineOperationType m_opType;
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
/// <summary>
|
||||
/// the current line operation type
|
||||
/// </summary>
|
||||
public LineOperationType OpType
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_opType;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
/// <summary>
|
||||
/// constructor
|
||||
/// </summary>
|
||||
/// <param name="type">
|
||||
/// the current line operation type
|
||||
/// </param>
|
||||
public LineOperation(LineOperationType type)
|
||||
{
|
||||
this.m_opType = type;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Public methods
|
||||
/// <summary>
|
||||
/// convert to string
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// the result string
|
||||
/// </returns>
|
||||
public override string ToString()
|
||||
{
|
||||
string resultString = string.Empty;
|
||||
switch (m_opType)
|
||||
{
|
||||
case LineOperationType.AddULine:
|
||||
resultString = "Add horizontal grid line";
|
||||
break;
|
||||
case LineOperationType.AddVLine:
|
||||
resultString = "Add vertical grid line";
|
||||
break;
|
||||
case LineOperationType.LockOrUnlockLine:
|
||||
resultString = "Lock or unlock grid line";
|
||||
break;
|
||||
case LineOperationType.MoveLine:
|
||||
resultString = "Move grid line";
|
||||
break;
|
||||
case LineOperationType.AddSegment:
|
||||
resultString = "Add segment";
|
||||
break;
|
||||
case LineOperationType.RemoveSegment:
|
||||
resultString = "Delete segment";
|
||||
break;
|
||||
case LineOperationType.AddAllSegments:
|
||||
resultString = "Add segments of entire grid line";
|
||||
break;
|
||||
case LineOperationType.AddAllMullions:
|
||||
resultString = "Add mullions to all segments";
|
||||
break;
|
||||
case LineOperationType.DeleteAllMullions:
|
||||
resultString = "Delete all mullions";
|
||||
break;
|
||||
default:
|
||||
resultString = base.ToString();
|
||||
break;
|
||||
}
|
||||
|
||||
return resultString;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,126 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<metadata name="statusStrip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>17, 17</value>
|
||||
</metadata>
|
||||
<metadata name="$this.TrayHeight" type="System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>47</value>
|
||||
</metadata>
|
||||
</root>
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,470 @@
|
||||
//
|
||||
// (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.Text;
|
||||
using System.Drawing;
|
||||
|
||||
namespace Revit.SDK.Samples.CurtainWallGrid.CS
|
||||
{
|
||||
/// <summary>
|
||||
/// a linear line in 2D point format
|
||||
/// </summary>
|
||||
public class Line2D
|
||||
{
|
||||
#region Fields
|
||||
// the start point of the line
|
||||
|
||||
Point m_startPoint;
|
||||
// the end point of the line
|
||||
Point m_endPoint;
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
/// <summary>
|
||||
/// the start point of the line
|
||||
/// </summary>
|
||||
public Point StartPoint
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_startPoint;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_startPoint = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// the end point of the line
|
||||
/// </summary>
|
||||
public Point EndPoint
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_endPoint;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_endPoint = value;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
/// <summary>
|
||||
/// default constructor
|
||||
/// </summary>
|
||||
public Line2D()
|
||||
{
|
||||
m_startPoint = Point.Empty;
|
||||
m_endPoint = Point.Empty;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// constructor
|
||||
/// </summary>
|
||||
/// <param name="startPoint">
|
||||
/// the start point for the line
|
||||
/// </param>
|
||||
/// <param name="endPoint">
|
||||
/// the end point for the line
|
||||
/// </param>
|
||||
public Line2D(Point startPoint, Point endPoint)
|
||||
{
|
||||
m_startPoint = startPoint;
|
||||
m_endPoint = endPoint;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// copy constructor
|
||||
/// </summary>
|
||||
/// <param name="line2D">
|
||||
/// the line to be copied
|
||||
/// </param>
|
||||
public Line2D(Line2D line2D)
|
||||
{
|
||||
m_startPoint = line2D.StartPoint;
|
||||
m_endPoint = line2D.EndPoint;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// the class stores the baseline data for curtain wall
|
||||
/// </summary>
|
||||
public class WallBaseline2D : Line2D
|
||||
{
|
||||
#region Fields
|
||||
// an assistant point for temp usage
|
||||
Point m_assistantPoint;
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
/// <summary>
|
||||
/// an assistant point for temp usage
|
||||
/// </summary>
|
||||
public Point AssistantPoint
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_assistantPoint;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_assistantPoint = value;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
/// <summary>
|
||||
/// default constructor
|
||||
/// </summary>
|
||||
public WallBaseline2D()
|
||||
: base()
|
||||
{
|
||||
m_assistantPoint = Point.Empty;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// constructor
|
||||
/// </summary>
|
||||
/// <param name="startPoint">
|
||||
/// the start point for the line
|
||||
/// </param>
|
||||
/// <param name="endPoint">
|
||||
/// the end point for the line
|
||||
/// </param>
|
||||
public WallBaseline2D(Point startPoint, Point endPoint)
|
||||
: base(startPoint, endPoint)
|
||||
{
|
||||
m_assistantPoint = Point.Empty;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// copy constructor
|
||||
/// </summary>
|
||||
/// <param name="wallLine2D">
|
||||
/// the line to be copied
|
||||
/// </param>
|
||||
public WallBaseline2D(WallBaseline2D wallLine2D)
|
||||
: base((Line2D)wallLine2D)
|
||||
{
|
||||
m_assistantPoint = wallLine2D.AssistantPoint;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Public methods
|
||||
/// <summary>
|
||||
/// clear the stored data
|
||||
/// </summary>
|
||||
public void Clear()
|
||||
{
|
||||
this.StartPoint = Point.Empty;
|
||||
this.EndPoint = Point.Empty;
|
||||
m_assistantPoint = Point.Empty;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// the 2D format for the curtain grid line, it inherits from the Line2D class
|
||||
/// </summary>
|
||||
public class GridLine2D : Line2D
|
||||
{
|
||||
#region Fields
|
||||
// indicate whether the grid line is locked
|
||||
bool m_locked;
|
||||
|
||||
// all the segments for the grid line
|
||||
List<SegmentLine2D> m_segments;
|
||||
|
||||
// indicate how many segments have been removed from the grid line
|
||||
private int m_removedNumber;
|
||||
|
||||
// indicate whether it's a U grid line
|
||||
private bool m_isUGridLine;
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
/// <summary>
|
||||
/// indicate whether the grid line is locked
|
||||
/// </summary>
|
||||
public bool Locked
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_locked;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_locked = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// all the segments for the grid line
|
||||
/// </summary>
|
||||
public List<SegmentLine2D> Segments
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_segments;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// indicate how many segments have been removed from the grid line
|
||||
/// </summary>
|
||||
public int RemovedNumber
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_removedNumber;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_removedNumber = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// indicate whether it's a U grid line
|
||||
/// </summary>
|
||||
public bool IsUGridLine
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_isUGridLine;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_isUGridLine = value;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
/// <summary>
|
||||
/// default constructor, initialize all the members with default value
|
||||
/// </summary>
|
||||
public GridLine2D()
|
||||
: base()
|
||||
{
|
||||
m_segments = new List<SegmentLine2D>();
|
||||
m_locked = false;
|
||||
m_removedNumber = 0;
|
||||
m_isUGridLine = false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// constructor, initialize the grid line with end points
|
||||
/// </summary>
|
||||
/// <param name="startPoint">
|
||||
/// the start point of the curtain grid line 2D
|
||||
/// </param>
|
||||
/// <param name="endPoint">
|
||||
/// the end point of the curtain grid line 2D
|
||||
/// </param>
|
||||
public GridLine2D(Point startPoint, Point endPoint)
|
||||
: base(startPoint, endPoint)
|
||||
{
|
||||
m_segments = new List<SegmentLine2D>();
|
||||
m_locked = false;
|
||||
m_removedNumber = 0;
|
||||
m_isUGridLine = false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// copy constructor, initialize the curtain grid line with another grid line 2D
|
||||
/// </summary>
|
||||
/// <param name="gridLine2D">
|
||||
/// the source line
|
||||
/// </param>
|
||||
public GridLine2D(GridLine2D gridLine2D)
|
||||
: base((Line2D)gridLine2D)
|
||||
{
|
||||
m_segments = new List<SegmentLine2D>();
|
||||
m_locked = gridLine2D.Locked;
|
||||
m_removedNumber = gridLine2D.RemovedNumber;
|
||||
m_isUGridLine = gridLine2D.IsUGridLine;
|
||||
foreach (SegmentLine2D segLine in gridLine2D.Segments)
|
||||
{
|
||||
m_segments.Add(new SegmentLine2D(segLine));
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// the line class for the segment of grid line, it inherits from Line2D class
|
||||
/// </summary>
|
||||
public class SegmentLine2D : Line2D
|
||||
{
|
||||
#region Fields
|
||||
// indicates whether the segment is "isolated"
|
||||
bool m_isolated;
|
||||
|
||||
// indicate whether the segment has been removed from the grid line
|
||||
bool m_removed;
|
||||
|
||||
// the index of the segment in the grid line
|
||||
private int m_segmentIndex;
|
||||
|
||||
// the index of its parent grid line in all the curtain grid's U/V grid lines
|
||||
private int m_gridLineIndex;
|
||||
|
||||
// indicates whether the segment is in a U grid line
|
||||
private bool m_isUSegment;
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
/// <summary>
|
||||
/// indicates whether the segment is "isolated"
|
||||
/// </summary>
|
||||
public bool Isolated
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_isolated;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_isolated = value;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region
|
||||
/// <summary>
|
||||
/// indicate whether the segment has been removed from the grid line
|
||||
/// </summary>
|
||||
public bool Removed
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_removed;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_removed = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// the index of the segment in the grid line
|
||||
/// </summary>
|
||||
public int SegmentIndex
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_segmentIndex;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_segmentIndex = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// the index of its parent grid line in all the curtain grid's U/V grid lines
|
||||
/// </summary>
|
||||
public int GridLineIndex
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_gridLineIndex;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_gridLineIndex = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// indicates whether the segment is in a U grid line
|
||||
/// </summary>
|
||||
public bool IsUSegment
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_isUSegment;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_isUSegment = value;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
/// <summary>
|
||||
/// default constructor
|
||||
/// </summary>
|
||||
public SegmentLine2D()
|
||||
: base()
|
||||
{
|
||||
m_removed = false;
|
||||
m_isolated = false;
|
||||
m_segmentIndex = -1;
|
||||
m_gridLineIndex = -1;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// constructor, initialize the segment with end points
|
||||
/// </summary>
|
||||
/// <param name="startPoint">
|
||||
/// the start point of the segment
|
||||
/// </param>
|
||||
/// <param name="endPoint">
|
||||
/// the end point of the segment
|
||||
/// </param>
|
||||
public SegmentLine2D(Point startPoint, Point endPoint)
|
||||
: base(startPoint, endPoint)
|
||||
{
|
||||
m_removed = false;
|
||||
m_isolated = false;
|
||||
m_segmentIndex = -1;
|
||||
m_gridLineIndex = -1;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// copy constructor
|
||||
/// </summary>
|
||||
/// <param name="segLine2D">
|
||||
/// the source segment line 2D
|
||||
/// </param>
|
||||
public SegmentLine2D(SegmentLine2D segLine2D)
|
||||
: base((Line2D)segLine2D)
|
||||
{
|
||||
m_removed = segLine2D.Removed;
|
||||
m_isolated = segLine2D.Isolated;
|
||||
m_segmentIndex = segLine2D.SegmentIndex;
|
||||
m_gridLineIndex = segLine2D.GridLineIndex;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,299 @@
|
||||
//
|
||||
// (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.Text;
|
||||
using System.ComponentModel;
|
||||
|
||||
using Autodesk.Revit;
|
||||
using Autodesk.Revit.DB;
|
||||
|
||||
namespace Revit.SDK.Samples.CurtainWallGrid.CS
|
||||
{
|
||||
/// <summary>
|
||||
/// all the supported Align type for the curtain grid
|
||||
/// </summary>
|
||||
public enum CurtainGridAlign
|
||||
{
|
||||
Beginning,
|
||||
Center,
|
||||
End
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// stores all the properties of the curtain grid and manages the behaviors and operations of the curtain grid
|
||||
/// </summary>
|
||||
public class GridProperties
|
||||
{
|
||||
#region Fields
|
||||
// stores the data of vertical justification
|
||||
private CurtainGridAlign m_verticalJustification;
|
||||
|
||||
// stores the data of vertical angle
|
||||
private double m_verticalAngle;
|
||||
|
||||
// stores the data of vertical offset
|
||||
private double m_verticalOffset;
|
||||
|
||||
// stores how many vertical lines there are in the grid
|
||||
private int m_verticalLinesNumber;
|
||||
|
||||
// stores the data of horizontal justification
|
||||
private CurtainGridAlign m_horizontalJustification;
|
||||
|
||||
// stores the data of horizontal angle
|
||||
private double m_horizontalAngle;
|
||||
|
||||
// stores the data of horizontal offset
|
||||
private double m_horizontalOffset;
|
||||
|
||||
// stores how many horizontal lines there are in the grid
|
||||
private int m_horizontalLinesNumber;
|
||||
|
||||
// stores how many panels there are in the grid
|
||||
private int m_panelNumber;
|
||||
|
||||
// stores how many curtain cells there are in the grid
|
||||
private int m_cellNumber;
|
||||
|
||||
// stores how many unlocked panels there are in the grid
|
||||
private int m_unlockedPanelsNumber;
|
||||
|
||||
// stores how many mullions there are in the grid
|
||||
private int m_mullionsNumber;
|
||||
|
||||
// stores how many unlocked mullions there are in the grid
|
||||
private int m_unlockedmullionsNumber;
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
/// <summary>
|
||||
/// stores the data of vertical justification
|
||||
/// </summary>
|
||||
[CategoryAttribute("Vertical Grid Pattern"), DefaultValueAttribute(CurtainGridAlign.Beginning), ReadOnlyAttribute(true)]
|
||||
public CurtainGridAlign VerticalJustification
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_verticalJustification;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_verticalJustification = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// stores the data of vertical angle
|
||||
/// </summary>
|
||||
[CategoryAttribute("Vertical Grid Pattern"), DefaultValueAttribute(0.0), ReadOnlyAttribute(true)]
|
||||
public double VerticalAngle
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_verticalAngle;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_verticalAngle = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// stores the data of vertical offset
|
||||
/// </summary>
|
||||
[CategoryAttribute("Vertical Grid Pattern"), DefaultValueAttribute(0.0), ReadOnlyAttribute(true)]
|
||||
public double VerticalOffset
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_verticalOffset;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_verticalOffset = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// stores how many U lines there are in the grid
|
||||
/// </summary>
|
||||
[CategoryAttribute("Vertical Grid Pattern"), DefaultValueAttribute(0), ReadOnlyAttribute(true)]
|
||||
public int VerticalLinesNumber
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_verticalLinesNumber;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_verticalLinesNumber = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// stores the data of horizontal justification
|
||||
/// </summary>
|
||||
[CategoryAttribute("Horizontal Grid Pattern"), DefaultValueAttribute(CurtainGridAlign.Beginning), ReadOnlyAttribute(true)]
|
||||
public CurtainGridAlign HorizontalJustification
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_horizontalJustification;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_horizontalJustification = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// stores the data of horizontal angle
|
||||
/// </summary>
|
||||
[CategoryAttribute("Horizontal Grid Pattern"), DefaultValueAttribute(0.0), ReadOnlyAttribute(true)]
|
||||
public double HorizontalAngle
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_horizontalAngle;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_horizontalAngle = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// stores the data of horizontal offset
|
||||
/// </summary>
|
||||
[CategoryAttribute("Horizontal Grid Pattern"), DefaultValueAttribute(0.0), ReadOnlyAttribute(true)]
|
||||
public double HorizontalOffset
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_horizontalOffset;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_horizontalOffset = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// stores how many V lines there are in the grid
|
||||
/// </summary>
|
||||
[CategoryAttribute("Horizontal Grid Pattern"), DefaultValueAttribute(0), ReadOnlyAttribute(true)]
|
||||
public int HorizontalLinesNumber
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_horizontalLinesNumber;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_horizontalLinesNumber = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// stores how many panels there are in the grid
|
||||
/// </summary>
|
||||
[CategoryAttribute("Other Data"), DefaultValueAttribute(0), ReadOnlyAttribute(true)]
|
||||
public int PanelNumber
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_panelNumber;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_panelNumber = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// stores how many curtain cells there are in the grid
|
||||
/// </summary>
|
||||
[CategoryAttribute("Other Data"), DefaultValueAttribute(0), ReadOnlyAttribute(true)]
|
||||
public int CellNumber
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_cellNumber;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_cellNumber = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// stores how many unlocked panels there are in the grid
|
||||
/// </summary>
|
||||
[CategoryAttribute("Other Data"), DefaultValueAttribute(0), ReadOnlyAttribute(true)]
|
||||
public int UnlockedPanelsNumber
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_unlockedPanelsNumber;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_unlockedPanelsNumber = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// stores how many mullions there are in the grid
|
||||
/// </summary>
|
||||
[CategoryAttribute("Other Data"), DefaultValueAttribute(0), ReadOnlyAttribute(true)]
|
||||
public int MullionsNumber
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_mullionsNumber;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_mullionsNumber = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// stores how many unlocked mullions there are in the grid
|
||||
/// </summary>
|
||||
[CategoryAttribute("Other Data"), DefaultValueAttribute(0), ReadOnlyAttribute(true)]
|
||||
public int UnlockedmullionsNumber
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_unlockedmullionsNumber;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_unlockedmullionsNumber = value;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
} // end of class
|
||||
}
|
||||
@@ -0,0 +1,543 @@
|
||||
//
|
||||
// (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.Text;
|
||||
|
||||
using Autodesk.Revit.DB;
|
||||
|
||||
namespace Revit.SDK.Samples.CurtainWallGrid.CS
|
||||
{
|
||||
/// <summary>
|
||||
/// Vector4 is a homogeneous coordinate class used to store vector
|
||||
/// and contain method to handle the vector
|
||||
/// </summary>
|
||||
public class Vector4
|
||||
{
|
||||
#region Fields
|
||||
private float m_x;
|
||||
private float m_y;
|
||||
private float m_z;
|
||||
private float m_w = 1.0f;
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
/// <summary>
|
||||
/// X property to get/set x value of Vector4
|
||||
/// </summary>
|
||||
public float X
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_x;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_x = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Y property to get/set y value of Vector4
|
||||
/// </summary>
|
||||
public float Y
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_y;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_y = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Z property to get/set z value of Vector4
|
||||
/// </summary>
|
||||
public float Z
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_z;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_z = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// W property to get/set fourth value of Vector4
|
||||
/// </summary>
|
||||
public float W
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_w;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_w = value;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
/// <summary>
|
||||
/// constructor
|
||||
/// </summary>
|
||||
public Vector4(float x, float y, float z)
|
||||
{
|
||||
this.X = x; this.Y = y; this.Z = z;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// constructor, transfer Autodesk.Revit.DB.XYZ to vector
|
||||
/// </summary>
|
||||
/// <param name="v">Autodesk.Revit.DB.XYZ structure which needs to be transfered</param>
|
||||
public Vector4(Autodesk.Revit.DB.XYZ v)
|
||||
{
|
||||
this.X = (float)v.X; this.Y = (float)v.Y; this.Z = (float)v.Z;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Public methods
|
||||
/// <summary>
|
||||
/// adds two vectors
|
||||
/// </summary>
|
||||
/// <param name="va">first vector</param>
|
||||
/// <param name="vb">second vector</param>
|
||||
public static Vector4 operator +(Vector4 va, Vector4 vb)
|
||||
{
|
||||
return new Vector4(va.X + vb.X, va.Y + vb.Y, va.Z + vb.Z);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// subtracts two vectors
|
||||
/// </summary>
|
||||
/// <param name="va">first vector</param>
|
||||
/// <param name="vb">second vector</param>
|
||||
/// <returns>subtraction of two vectors</returns>
|
||||
public static Vector4 operator -(Vector4 va, Vector4 vb)
|
||||
{
|
||||
return new Vector4(va.X - vb.X, va.Y - vb.Y, va.Z - vb.Z);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// multiplies a vector by a floating type value
|
||||
/// </summary>
|
||||
/// <param name="v">vector</param>
|
||||
/// <param name="factor">multiplier of floating type</param>
|
||||
/// <returns> the result vector </returns>
|
||||
public static Vector4 operator *(Vector4 v, float factor)
|
||||
{
|
||||
return new Vector4(v.X * factor, v.Y * factor, v.Z * factor);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// divides vector by a float type value
|
||||
/// </summary>
|
||||
/// <param name="v">vector</param>
|
||||
/// <param name="factor">floating type value</param>
|
||||
/// <returns> vector divided by a floating type value </returns>
|
||||
public static Vector4 operator /(Vector4 v, float factor)
|
||||
{
|
||||
return new Vector4(v.X / factor, v.Y / factor, v.Z / factor);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// dot multiply vector
|
||||
/// </summary>
|
||||
/// <param name="v"> the result vector </param>
|
||||
public float DotProduct(Vector4 v)
|
||||
{
|
||||
return (this.X * v.X + this.Y * v.Y + this.Z * v.Z);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// get normal vector of plane contains two vectors
|
||||
/// </summary>
|
||||
/// <param name="v">second vector</param>
|
||||
/// <returns> normal vector of two vectors</returns>
|
||||
public Vector4 CrossProduct(Vector4 v)
|
||||
{
|
||||
return new Vector4(this.Y * v.Z - this.Z * v.Y, this.Z * v.X
|
||||
- this.X * v.Z, this.X * v.Y - this.Y * v.X);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// dot multiply two vectors
|
||||
/// </summary>
|
||||
/// <param name="va">first vector</param>
|
||||
/// <param name="vb">second vector</param>
|
||||
public static float DotProduct(Vector4 va, Vector4 vb)
|
||||
{
|
||||
return (va.X * vb.X + va.Y * vb.Y + va.Z * vb.Z);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// get normal vector of two vectors
|
||||
/// </summary>
|
||||
/// <param name="va">first vector</param>
|
||||
/// <param name="vb">second vector</param>
|
||||
/// <returns> normal vector of two vectors </returns>
|
||||
public static Vector4 CrossProduct(Vector4 va, Vector4 vb)
|
||||
{
|
||||
return new Vector4(va.Y * vb.Z - va.Z * vb.Y, va.Z * vb.X
|
||||
- va.X * vb.Z, va.X * vb.Y - va.Y * vb.X);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// get unit vector
|
||||
/// </summary>
|
||||
public void Normalize()
|
||||
{
|
||||
float length = Length();
|
||||
if (length == 0)
|
||||
{
|
||||
length = 1;
|
||||
}
|
||||
this.X /= length;
|
||||
this.Y /= length;
|
||||
this.Z /= length;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// calculate the length of vector
|
||||
/// </summary>
|
||||
public float Length()
|
||||
{
|
||||
return (float)Math.Sqrt(this.X * this.X + this.Y * this.Y + this.Z * this.Z);
|
||||
}
|
||||
#endregion
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// Matrix used to transform between ucs coordinate and world coordinate.
|
||||
/// </summary>
|
||||
public class Matrix4
|
||||
{
|
||||
/// <summary>
|
||||
/// MatrixType Enum use to define function of matrix
|
||||
/// </summary>
|
||||
public enum MatrixType
|
||||
{
|
||||
/// <summary>
|
||||
/// matrix use to rotate
|
||||
/// </summary>
|
||||
Rotation,
|
||||
|
||||
/// <summary>
|
||||
/// matrix used to Translation
|
||||
/// </summary>
|
||||
Translation,
|
||||
|
||||
/// <summary>
|
||||
/// matrix used to Scale
|
||||
/// </summary>
|
||||
Scale,
|
||||
|
||||
/// <summary>
|
||||
/// matrix used to Rotation and Translation
|
||||
/// </summary>
|
||||
RotationAndTranslation,
|
||||
|
||||
/// <summary>
|
||||
/// normal matrix
|
||||
/// </summary>
|
||||
Normal
|
||||
};
|
||||
|
||||
#region Fields
|
||||
// an array stores the matrix
|
||||
private float[,] m_matrix = new float[4, 4];
|
||||
|
||||
//type of matrix
|
||||
private MatrixType m_type;
|
||||
#endregion
|
||||
|
||||
#region Properties and indexeres
|
||||
/// <summary>
|
||||
/// indexer of matrix
|
||||
/// </summary>
|
||||
/// <param name="row">row number</param>
|
||||
/// <param name="column">column number</param>
|
||||
/// <returns></returns>
|
||||
public float this[int row, int column]
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.m_matrix[row, column];
|
||||
}
|
||||
set
|
||||
{
|
||||
this.m_matrix[row, column] = value;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
/// <summary>
|
||||
/// default constructor
|
||||
/// </summary>
|
||||
public Matrix4()
|
||||
{
|
||||
m_type = MatrixType.Normal;
|
||||
Identity();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ctor,rotation matrix,origin at (0,0,0)
|
||||
/// </summary>
|
||||
/// <param name="xAxis">identity of x axis</param>
|
||||
/// <param name="yAxis">identity of y axis</param>
|
||||
/// <param name="zAxis">identity of z axis</param>
|
||||
public Matrix4(Vector4 xAxis, Vector4 yAxis, Vector4 zAxis)
|
||||
{
|
||||
m_type = MatrixType.Rotation;
|
||||
Identity();
|
||||
m_matrix[0, 0] = xAxis.X; m_matrix[0, 1] = xAxis.Y; m_matrix[0, 2] = xAxis.Z;
|
||||
m_matrix[1, 0] = yAxis.X; m_matrix[1, 1] = yAxis.Y; m_matrix[1, 2] = yAxis.Z;
|
||||
m_matrix[2, 0] = zAxis.X; m_matrix[2, 1] = zAxis.Y; m_matrix[2, 2] = zAxis.Z;
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ctor,translation matrix.
|
||||
/// </summary>
|
||||
/// <param name="origin">origin of ucs in world coordinate</param>
|
||||
public Matrix4(Vector4 origin)
|
||||
{
|
||||
m_type = MatrixType.Translation;
|
||||
Identity();
|
||||
m_matrix[3, 0] = origin.X; m_matrix[3, 1] = origin.Y; m_matrix[3, 2] = origin.Z;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// rotation and translation matrix constructor
|
||||
/// </summary>
|
||||
/// <param name="xAxis">x Axis</param>
|
||||
/// <param name="yAxis">y Axis</param>
|
||||
/// <param name="zAxis">z Axis</param>
|
||||
/// <param name="origin">origin</param>
|
||||
public Matrix4(Vector4 xAxis, Vector4 yAxis, Vector4 zAxis, Vector4 origin)
|
||||
{
|
||||
m_type = MatrixType.RotationAndTranslation;
|
||||
Identity();
|
||||
m_matrix[0, 0] = xAxis.X; m_matrix[0, 1] = xAxis.Y; m_matrix[0, 2] = xAxis.Z;
|
||||
m_matrix[1, 0] = yAxis.X; m_matrix[1, 1] = yAxis.Y; m_matrix[1, 2] = yAxis.Z;
|
||||
m_matrix[2, 0] = zAxis.X; m_matrix[2, 1] = zAxis.Y; m_matrix[2, 2] = zAxis.Z;
|
||||
m_matrix[3, 0] = origin.X; m_matrix[3, 1] = origin.Y; m_matrix[3, 2] = origin.Z;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// scale matrix constructor
|
||||
/// </summary>
|
||||
/// <param name="scale">scale factor</param>
|
||||
public Matrix4(float scale)
|
||||
{
|
||||
m_type = MatrixType.Scale;
|
||||
Identity();
|
||||
m_matrix[0, 0] = scale;
|
||||
m_matrix[1, 1] = scale;
|
||||
m_matrix[2, 2] = scale;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Public methods
|
||||
/// <summary>
|
||||
/// Identity matrix
|
||||
/// </summary>
|
||||
public void Identity()
|
||||
{
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
for (int j = 0; j < 4; j++)
|
||||
{
|
||||
this.m_matrix[i, j] = 0.0f;
|
||||
}
|
||||
}
|
||||
this.m_matrix[0, 0] = 1.0f;
|
||||
this.m_matrix[1, 1] = 1.0f;
|
||||
this.m_matrix[2, 2] = 1.0f;
|
||||
this.m_matrix[3, 3] = 1.0f;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// multiply matrix left and right
|
||||
/// </summary>
|
||||
/// <param name="left">left matrix</param>
|
||||
/// <param name="right">right matrix</param>
|
||||
/// <returns></returns>
|
||||
public static Matrix4 Multiply(Matrix4 left, Matrix4 right)
|
||||
{
|
||||
Matrix4 result = new Matrix4();
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
for (int j = 0; j < 4; j++)
|
||||
{
|
||||
result[i, j] = left[i, 0] * right[0, j] + left[i, 1] * right[1, j]
|
||||
+ left[i, 2] * right[2, j] + left[i, 3] * right[3, j];
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// transform point using this matrix
|
||||
/// </summary>
|
||||
/// <param name="point">point to be transformed</param>
|
||||
/// <returns>transform result</returns>
|
||||
public Vector4 Transform(Vector4 point)
|
||||
{
|
||||
return new Vector4(point.X * this[0, 0] + point.Y * this[1, 0]
|
||||
+ point.Z * this[2, 0] + point.W * this[3, 0],
|
||||
point.X * this[0, 1] + point.Y * this[1, 1]
|
||||
+ point.Z * this[2, 1] + point.W * this[3, 1],
|
||||
point.X * this[0, 2] + point.Y * this[1, 2]
|
||||
+ point.Z * this[2, 2] + point.W * this[3, 2]);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// if m_matrix is a rotation matrix,this method can get the rotation inverse matrix.
|
||||
/// </summary>
|
||||
/// <returns>inverse of rotation matrix</returns>
|
||||
public Matrix4 RotationInverse()
|
||||
{
|
||||
return new Matrix4(new Vector4(this[0, 0], this[1, 0], this[2, 0]),
|
||||
new Vector4(this[0, 1], this[1, 1], this[2, 1]),
|
||||
new Vector4(this[0, 2], this[1, 2], this[2, 2]));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// if this m_matrix is a translation matrix,
|
||||
/// this method can get the translation inverse matrix.
|
||||
/// </summary>
|
||||
/// <returns>inverse of translation matrix</returns>
|
||||
public Matrix4 TranslationInverse()
|
||||
{
|
||||
return new Matrix4(new Vector4(-this[3, 0], -this[3, 1], -this[3, 2]));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// get inverse matrix
|
||||
/// </summary>
|
||||
/// <returns>inverse matrix</returns>
|
||||
public Matrix4 Inverse()
|
||||
{
|
||||
switch (m_type)
|
||||
{
|
||||
case MatrixType.Rotation:
|
||||
return RotationInverse();
|
||||
|
||||
case MatrixType.Translation:
|
||||
return TranslationInverse();
|
||||
|
||||
case MatrixType.RotationAndTranslation:
|
||||
return Multiply(TranslationInverse(), RotationInverse());
|
||||
|
||||
case MatrixType.Scale:
|
||||
return ScaleInverse();
|
||||
|
||||
case MatrixType.Normal:
|
||||
return new Matrix4();
|
||||
|
||||
default: return null;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// if m_matrix is a scale matrix,this method can get the scale inverse matrix.
|
||||
/// </summary>
|
||||
/// <returns>inverse of scale matrix</returns>
|
||||
public Matrix4 ScaleInverse()
|
||||
{
|
||||
return new Matrix4(1 / m_matrix[0, 0]);
|
||||
}
|
||||
#endregion
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// the 2D point class which contains double value for its coordinates
|
||||
/// </summary>
|
||||
public struct PointD
|
||||
{
|
||||
#region Fields
|
||||
// X coordinate
|
||||
double m_x;
|
||||
|
||||
// Y coordinate
|
||||
double m_y;
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
/// <summary>
|
||||
/// X coordinate
|
||||
/// </summary>
|
||||
public double X
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_x;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_x = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Y coordinate
|
||||
/// </summary>
|
||||
public double Y
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_y;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_y = value;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
/// <summary>
|
||||
/// constructor
|
||||
/// </summary>
|
||||
/// <param name="x">
|
||||
/// X value of the point
|
||||
/// </param>
|
||||
/// <param name="y">
|
||||
/// Y value of the point
|
||||
/// </param>
|
||||
public PointD(double x, double y)
|
||||
{
|
||||
m_x = x;
|
||||
m_y = y;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,361 @@
|
||||
//
|
||||
// (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.Data;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Drawing2D;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
using System.Linq;
|
||||
|
||||
using Autodesk.Revit;
|
||||
using Autodesk.Revit.DB;
|
||||
using Autodesk.Revit.UI;
|
||||
|
||||
namespace Revit.SDK.Samples.CurtainWallGrid.CS
|
||||
{
|
||||
/// <summary>
|
||||
/// maintains all the data used in the sample
|
||||
/// </summary>
|
||||
public class MyDocument
|
||||
{
|
||||
#region Fields
|
||||
// object which contains reference of Revit Application
|
||||
ExternalCommandData m_commandData;
|
||||
/// <summary>
|
||||
/// object which contains reference of Revit Application
|
||||
/// </summary>
|
||||
public ExternalCommandData CommandData
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_commandData;
|
||||
}
|
||||
}
|
||||
|
||||
// the active document of Revit
|
||||
UIDocument m_uiDocument;
|
||||
/// <summary>
|
||||
/// the active document of Revit
|
||||
/// </summary>
|
||||
public UIDocument UIDocument
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_uiDocument;
|
||||
}
|
||||
}
|
||||
|
||||
// the active document of Revit
|
||||
Document m_document;
|
||||
/// <summary>
|
||||
/// the active document of Revit
|
||||
/// </summary>
|
||||
public Document Document
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_document;
|
||||
}
|
||||
}
|
||||
|
||||
// stores all the Curtain WallTypes in the active Revit document
|
||||
List<WallType> m_wallTypes;
|
||||
|
||||
// stores all the ViewPlans in the active Revit document
|
||||
List<Autodesk.Revit.DB.View> m_views;
|
||||
|
||||
// stores the wall creation related data and operations
|
||||
WallGeometry m_wallGeometry;
|
||||
|
||||
// stores the curtain wall created
|
||||
Wall m_curtainWall;
|
||||
|
||||
// indicates whether the curtain wall has been created
|
||||
bool m_wallCreated;
|
||||
|
||||
// store the grid information of the created curtain wall
|
||||
GridGeometry m_gridGeometry;
|
||||
|
||||
// store the active grid line operation
|
||||
LineOperation m_activeOperation;
|
||||
|
||||
// the length unit type for the active Revit document
|
||||
ForgeTypeId m_LengthUnit;
|
||||
|
||||
// store the message of the sample
|
||||
private KeyValuePair<string/*msgText*/, bool/*is warningOrError*/> m_message;
|
||||
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// stores all the Curtain WallTypes in the active Revit document
|
||||
/// </summary>
|
||||
public List<WallType> WallTypes
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_wallTypes;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// stores all the ViewPlans in the active Revit document
|
||||
/// </summary>
|
||||
public List<Autodesk.Revit.DB.View> Views
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_views;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// stores the wall creation related data and operations
|
||||
/// </summary>
|
||||
public WallGeometry WallGeometry
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_wallGeometry;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// stores the curtain wall created
|
||||
/// </summary>
|
||||
public Wall CurtainWall
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_curtainWall;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_curtainWall = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// indicates whether the curtain wall has been created
|
||||
/// </summary>
|
||||
public bool WallCreated
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_wallCreated;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_wallCreated = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// store the grid information of the created curtain wall
|
||||
/// </summary>
|
||||
public GridGeometry GridGeometry
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_gridGeometry;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// store the active grid line operation
|
||||
/// </summary>
|
||||
public LineOperation ActiveOperation
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_activeOperation;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_activeOperation = value;
|
||||
}
|
||||
}
|
||||
|
||||
public ForgeTypeId LengthUnit
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_LengthUnit;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// store the message of the sample
|
||||
/// </summary>
|
||||
public KeyValuePair<string/*msgText*/, bool/*is warningOrError*/> Message
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_message;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_message = value;
|
||||
if (null != MessageChanged)
|
||||
{
|
||||
MessageChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Delegates and Events
|
||||
// occurs only when the message was updated
|
||||
public delegate void MessageChangedHandler();
|
||||
public event MessageChangedHandler MessageChanged;
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
/// <summary>
|
||||
/// constructor
|
||||
/// </summary>
|
||||
/// <param name="commandData">
|
||||
/// object which contains reference of Revit Application
|
||||
/// </param>
|
||||
public MyDocument(ExternalCommandData commandData)
|
||||
{
|
||||
if (null != commandData.Application.ActiveUIDocument)
|
||||
{
|
||||
m_commandData = commandData;
|
||||
m_uiDocument = m_commandData.Application.ActiveUIDocument;
|
||||
m_document = m_uiDocument.Document;
|
||||
m_views = new List<Autodesk.Revit.DB.View>();
|
||||
m_wallTypes = new List<WallType>();
|
||||
m_wallGeometry = new WallGeometry(this);
|
||||
m_wallCreated = false;
|
||||
m_gridGeometry = new GridGeometry(this);
|
||||
|
||||
// get all the wall types and all the view plans
|
||||
InitializeData();
|
||||
|
||||
// get the length unit type of the active Revit document
|
||||
GetLengthUnitType();
|
||||
|
||||
// initialize the curtain grid operation type
|
||||
m_activeOperation = new LineOperation(LineOperationType.Waiting);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Private methods
|
||||
/// <summary>
|
||||
/// Get current length display unit type
|
||||
/// </summary>
|
||||
private void GetLengthUnitType()
|
||||
{
|
||||
ForgeTypeId specTypeId = SpecTypeId.Length;
|
||||
Units projectUnit = m_document.GetUnits();
|
||||
try
|
||||
{
|
||||
Autodesk.Revit.DB.FormatOptions formatOption = projectUnit.GetFormatOptions(specTypeId);
|
||||
m_LengthUnit = formatOption.GetUnitTypeId();
|
||||
}
|
||||
catch (System.Exception /*e*/)
|
||||
{
|
||||
m_LengthUnit = UnitTypeId.Feet;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// get all the wall types for curtain wall and all the view plans from the active document
|
||||
/// </summary>
|
||||
private void InitializeData()
|
||||
{
|
||||
// get all the wall types
|
||||
FilteredElementCollector filteredElementCollector = new FilteredElementCollector(m_document);
|
||||
filteredElementCollector.OfClass(typeof(WallType));
|
||||
// just get all the curtain wall type
|
||||
m_wallTypes = filteredElementCollector.Cast<WallType>().Where<WallType>(wallType => wallType.Kind == WallKind.Curtain).ToList<WallType>();
|
||||
|
||||
// sort them alphabetically
|
||||
WallTypeComparer wallComp = new WallTypeComparer();
|
||||
m_wallTypes.Sort(wallComp);
|
||||
|
||||
// get all the ViewPlans
|
||||
m_views = SkipTemplateViews(GetElements<Autodesk.Revit.DB.View>());
|
||||
|
||||
// sort them alphabetically
|
||||
ViewComparer viewComp = new ViewComparer();
|
||||
m_views.Sort(viewComp);
|
||||
|
||||
// get one of the mullion types
|
||||
MullionTypeSet mullTypes = m_document.MullionTypes;
|
||||
foreach (MullionType type in mullTypes)
|
||||
{
|
||||
if (null != type)
|
||||
{
|
||||
BuiltInParameter bip = BuiltInParameter.ALL_MODEL_FAMILY_NAME;
|
||||
Parameter para = type.get_Parameter(bip);
|
||||
if (null != para)
|
||||
{
|
||||
string name = para.AsString().ToLower();
|
||||
if (name.StartsWith("circular mullion"))
|
||||
{
|
||||
m_gridGeometry.MullionType = type;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected List<T> GetElements<T>() where T : Element
|
||||
{
|
||||
List<T> returns = new List<T>();
|
||||
FilteredElementCollector collector = new FilteredElementCollector(m_document);
|
||||
ICollection<Element> founds = collector.OfClass(typeof(T)).ToElements();
|
||||
foreach (Element elem in founds)
|
||||
{
|
||||
returns.Add(elem as T);
|
||||
}
|
||||
return returns;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// View elements filtered by new iteration will include template views.
|
||||
/// These views are not invalid for test(because they're invisible in project browser)
|
||||
/// Skip template views for regression test
|
||||
/// </summary>
|
||||
/// <param name="views"></param>
|
||||
/// <returns></returns>
|
||||
private List<T> SkipTemplateViews<T>(List<T> views) where T : Autodesk.Revit.DB.View
|
||||
{
|
||||
List<T> returns = new List<T>();
|
||||
foreach (Autodesk.Revit.DB.View curView in views)
|
||||
{
|
||||
if (null != curView && !curView.IsTemplate)
|
||||
returns.Add(curView as T);
|
||||
}
|
||||
return returns;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -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("CurtainWallGrid")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("CurtainWallGrid")]
|
||||
[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("74330e0c-5550-4300-9d85-8d28a777a8ba")]
|
||||
|
||||
// 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")]
|
||||
@@ -0,0 +1,63 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:4.0.30319.42000
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace CurtainWallGrid.Properties {
|
||||
using System;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// A strongly-typed resource class, for looking up localized strings, etc.
|
||||
/// </summary>
|
||||
// This class was auto-generated by the StronglyTypedResourceBuilder
|
||||
// class via a tool like ResGen or Visual Studio.
|
||||
// To add or remove a member, edit your .ResX file then rerun ResGen
|
||||
// with the /str option, or rebuild your VS project.
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
internal class Resources {
|
||||
|
||||
private static global::System.Resources.ResourceManager resourceMan;
|
||||
|
||||
private static global::System.Globalization.CultureInfo resourceCulture;
|
||||
|
||||
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
|
||||
internal Resources() {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the cached ResourceManager instance used by this class.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Resources.ResourceManager ResourceManager {
|
||||
get {
|
||||
if (object.ReferenceEquals(resourceMan, null)) {
|
||||
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("CurtainWallGrid.Properties.Resources", typeof(Resources).Assembly);
|
||||
resourceMan = temp;
|
||||
}
|
||||
return resourceMan;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Overrides the current thread's CurrentUICulture property for all
|
||||
/// resource lookups using this strongly typed resource class.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Globalization.CultureInfo Culture {
|
||||
get {
|
||||
return resourceCulture;
|
||||
}
|
||||
set {
|
||||
resourceCulture = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,114 @@
|
||||
//
|
||||
// (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.Text;
|
||||
using System.Configuration;
|
||||
using System.Reflection;
|
||||
|
||||
using Autodesk.Revit;
|
||||
using Autodesk.Revit.DB;
|
||||
|
||||
namespace Revit.SDK.Samples.CurtainWallGrid.CS
|
||||
{
|
||||
/// <summary>
|
||||
/// Provides static functions to convert unit
|
||||
/// </summary>
|
||||
static class Unit
|
||||
{
|
||||
#region Methods
|
||||
/// <summary>
|
||||
/// Convert the value get from RevitAPI to the value indicated by ForgeTypeId
|
||||
/// </summary>
|
||||
/// <param name="to">
|
||||
/// ForgeTypeId indicates unit of target value
|
||||
/// </param>
|
||||
/// <param name="value">
|
||||
/// value get from RevitAPI
|
||||
/// </param>
|
||||
/// <returns>
|
||||
/// Target value
|
||||
/// </returns>
|
||||
public static double CovertFromAPI(ForgeTypeId to, double value)
|
||||
{
|
||||
return value *= ImperialDutRatio(to);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Convert a value indicated by ForgeTypeId to the value used by RevitAPI
|
||||
/// </summary>
|
||||
/// <param name="value">
|
||||
/// Value to be converted
|
||||
/// </param>
|
||||
/// <param name="from">
|
||||
/// ForgeTypeId indicates the unit of the value to be converted
|
||||
/// </param>
|
||||
/// <returns>
|
||||
/// Target value
|
||||
/// </returns>
|
||||
public static double CovertToAPI(double value, ForgeTypeId from)
|
||||
{
|
||||
return value /= ImperialDutRatio(from);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get ratio between value in RevitAPI and value to display indicated by ForgeTypeId
|
||||
/// </summary>
|
||||
/// <param name="dut">
|
||||
/// ForgeTypeId indicates display unit type
|
||||
/// </param>
|
||||
/// <returns>
|
||||
/// Ratio
|
||||
/// </returns>
|
||||
private static double ImperialDutRatio(ForgeTypeId unitTypeId)
|
||||
{
|
||||
if (unitTypeId == UnitTypeId.Feet) return 1;
|
||||
if (unitTypeId == UnitTypeId.FeetFractionalInches) return 1;
|
||||
if (unitTypeId == UnitTypeId.Inches) return 12;
|
||||
if (unitTypeId == UnitTypeId.FractionalInches) return 12;
|
||||
if (unitTypeId == UnitTypeId.Meters) return 0.3048;
|
||||
if (unitTypeId == UnitTypeId.Centimeters) return 30.48;
|
||||
if (unitTypeId == UnitTypeId.Millimeters) return 304.8;
|
||||
if (unitTypeId == UnitTypeId.MetersCentimeters) return 0.3048;
|
||||
return 1;
|
||||
}
|
||||
|
||||
public static string GetUnitLabel(ForgeTypeId unitTypeId)
|
||||
{
|
||||
Dictionary<ForgeTypeId, string> unitLabels = new Dictionary<ForgeTypeId, string> {
|
||||
{ UnitTypeId.Centimeters, "cm" },
|
||||
{ UnitTypeId.Feet, "'" },
|
||||
{ UnitTypeId.Inches, "\"" },
|
||||
{ UnitTypeId.FeetFractionalInches, "'" },
|
||||
{ UnitTypeId.FractionalInches, "\"" },
|
||||
{ UnitTypeId.Meters, "m" },
|
||||
{ UnitTypeId.MetersCentimeters, "m" },
|
||||
{ UnitTypeId.Millimeters, "mm" }
|
||||
};
|
||||
if (unitLabels.ContainsKey(unitTypeId))
|
||||
return unitLabels[unitTypeId];
|
||||
return string.Empty;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,94 @@
|
||||
//
|
||||
// (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;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
using Autodesk.Revit;
|
||||
using Autodesk.Revit.DB;
|
||||
|
||||
namespace Revit.SDK.Samples.CurtainWallGrid.CS
|
||||
{
|
||||
/// <summary>
|
||||
/// compare 2 wall types and sort them by their type names
|
||||
/// </summary>
|
||||
class WallTypeComparer : IComparer<WallType>
|
||||
{
|
||||
#region IComparer<WallType> Members
|
||||
|
||||
/// <summary>
|
||||
/// compare 2 walltypes by their names
|
||||
/// </summary>
|
||||
/// <param name="x">
|
||||
/// wall type to be compared
|
||||
/// </param>
|
||||
/// <param name="y">
|
||||
/// wall type to be compared
|
||||
/// </param>
|
||||
/// <returns>
|
||||
/// returns the result by comparing their names with CaseInsensitiveComparer
|
||||
/// </returns>
|
||||
public int Compare(WallType x, WallType y)
|
||||
{
|
||||
string xName = x.Name;
|
||||
string yName = y.Name;
|
||||
|
||||
IComparer comp = new CaseInsensitiveComparer();
|
||||
return comp.Compare(xName, yName);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// compare 2 views and sort them by their type names
|
||||
/// </summary>
|
||||
class ViewComparer : IComparer<Autodesk.Revit.DB.View>
|
||||
{
|
||||
#region IComparer<View> Members
|
||||
|
||||
/// <summary>
|
||||
/// compare 2 views by their names
|
||||
/// </summary>
|
||||
/// <param name="x">
|
||||
/// view to be compared
|
||||
/// </param>
|
||||
/// <param name="y">
|
||||
/// view to be compared
|
||||
/// </param>
|
||||
/// <returns>
|
||||
/// returns the result by comparing their names with CaseInsensitiveComparer
|
||||
/// </returns>
|
||||
public int Compare(Autodesk.Revit.DB.View x, Autodesk.Revit.DB.View y)
|
||||
{
|
||||
string xName = x.ViewType.ToString() + " : " + x.Name;
|
||||
string yName = y.ViewType.ToString() + " : " + y.Name;
|
||||
|
||||
IComparer comp = new CaseInsensitiveComparer();
|
||||
return comp.Compare(xName, yName);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,295 @@
|
||||
//
|
||||
// (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.Text;
|
||||
using System.Drawing;
|
||||
using System.Resources;
|
||||
using System.Reflection;
|
||||
|
||||
namespace Revit.SDK.Samples.CurtainWallGrid.CS
|
||||
{
|
||||
/// <summary>
|
||||
/// maintain the baseline of the curtain wall
|
||||
/// </summary>
|
||||
public class WallDrawing
|
||||
{
|
||||
#region Fields
|
||||
// zoom the baseline to a suitable length
|
||||
public double SCALEFACTOR = 5.0;
|
||||
|
||||
// the boundary of the canvas for the baseline drawing
|
||||
Rectangle m_boundary;
|
||||
|
||||
// the origin for the baseline (it's the center of the canvas)
|
||||
Point m_origin;
|
||||
|
||||
// the referred parent wall geometry
|
||||
WallGeometry m_refGeometry;
|
||||
|
||||
// store the document of this sample
|
||||
MyDocument m_myDocument;
|
||||
|
||||
// the font used in drawing the baseline of the curtain wall
|
||||
Font m_coordinateFont;
|
||||
|
||||
// the baseline of the curtain wall
|
||||
WallBaseline2D m_wallLine2D;
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
/// <summary>
|
||||
/// the boundary of the canvas for the baseline drawing
|
||||
/// </summary>
|
||||
public Rectangle Boundary
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_boundary;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_boundary = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// the origin for the baseline (it's the center of the canvas)
|
||||
/// </summary>
|
||||
public Point Origin
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_origin;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_origin = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// the baseline of the curtain wall
|
||||
/// </summary>
|
||||
public WallBaseline2D WallLine2D
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_wallLine2D;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
/// <summary>
|
||||
/// default constructor
|
||||
/// </summary>
|
||||
/// <param name="wallGeo">
|
||||
/// the mapped wall geometry information
|
||||
/// </param>
|
||||
public WallDrawing(WallGeometry wallGeo)
|
||||
{
|
||||
m_coordinateFont = new Font("Verdana", 10, FontStyle.Regular);
|
||||
m_wallLine2D = new WallBaseline2D();
|
||||
m_myDocument = wallGeo.MyDocument;
|
||||
m_refGeometry = wallGeo;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Public methods
|
||||
/// <summary>
|
||||
/// Add point to baseline of the curtain wall
|
||||
/// </summary>
|
||||
/// <param name="mousePosition">
|
||||
/// the location of the mouse cursor
|
||||
/// </param>
|
||||
public void AddPoint(Point mousePosition)
|
||||
{
|
||||
// both end points of the baseline specified, can't add more points
|
||||
if (Point.Empty != m_wallLine2D.StartPoint &&
|
||||
Point.Empty != m_wallLine2D.EndPoint)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// start point isn't specified, specify it
|
||||
if (Point.Empty == m_wallLine2D.StartPoint)
|
||||
{
|
||||
m_wallLine2D.StartPoint = mousePosition;
|
||||
m_refGeometry.StartPointD = ConvertToPointD(mousePosition);
|
||||
}
|
||||
// start point specified, end point isn't, so specify the end point
|
||||
else if (Point.Empty == m_wallLine2D.EndPoint)
|
||||
{
|
||||
// don't let the length of the 2 points too small
|
||||
if (Math.Abs(m_wallLine2D.StartPoint.X - mousePosition.X) >= 2 ||
|
||||
Math.Abs(m_wallLine2D.StartPoint.Y - mousePosition.Y) >= 2)
|
||||
{
|
||||
m_wallLine2D.EndPoint = mousePosition;
|
||||
m_refGeometry.EndPointD = ConvertToPointD(mousePosition);
|
||||
m_wallLine2D.AssistantPoint = Point.Empty;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// store mouse position when mouse moves (the location will be the candidate end points of the baseline)
|
||||
/// </summary>
|
||||
/// <param name="mousePosition">
|
||||
/// the location of the mouse cursor
|
||||
/// </param>
|
||||
public void AddMousePosition(Point mousePosition)
|
||||
{
|
||||
// both endpoints for the baseline have been confirmed, no need to record the mouse location
|
||||
if (Point.Empty != m_wallLine2D.StartPoint &&
|
||||
Point.Empty != m_wallLine2D.EndPoint)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// we just start to draw the baseline, no end points are specified
|
||||
// or just the start point was specified, so the mouse position will be the "candidate end point"
|
||||
m_wallLine2D.AssistantPoint = mousePosition;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// draw the baseline for the curtain wall creation in the picture box
|
||||
/// in the "Create Curtain Wall" tab page, user needs to draw the baseline for wall creation
|
||||
/// </summary>
|
||||
/// <param name="graphics">
|
||||
/// form graphic
|
||||
/// </param>
|
||||
/// <param name="pen">
|
||||
/// pen used to draw line in pictureBox
|
||||
/// </param>
|
||||
public void Draw(Graphics graphics, Pen pen)
|
||||
{
|
||||
// draw the coordinate system origin
|
||||
DrawCoordinateOrigin(graphics, pen);
|
||||
|
||||
// draw the baseline
|
||||
DrawBaseline(graphics, pen);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Clear points in baseline
|
||||
/// </summary>
|
||||
public void RemovePoints()
|
||||
{
|
||||
m_wallLine2D.Clear();
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Private methods
|
||||
/// <summary>
|
||||
/// scale the point and store them in PointD format
|
||||
/// </summary>
|
||||
/// <param name="srcPoint">
|
||||
/// the point to-be-zoomed
|
||||
/// </param>
|
||||
/// <returns>
|
||||
/// the scaled result point
|
||||
/// </returns>
|
||||
private PointD ConvertToPointD(Point srcPoint)
|
||||
{
|
||||
double x = -1;
|
||||
double y = -1;
|
||||
x = srcPoint.X - m_origin.X;
|
||||
y = m_origin.Y - srcPoint.Y;
|
||||
x /= SCALEFACTOR;
|
||||
y /= SCALEFACTOR;
|
||||
return new PointD(x, y);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// draw the coordinate system origin for the baseline drawing
|
||||
/// </summary>
|
||||
/// <param name="graphics">
|
||||
/// form graphic
|
||||
/// </param>
|
||||
/// <param name="pen">
|
||||
/// pen used to draw line in pictureBox
|
||||
/// </param>
|
||||
private void DrawCoordinateOrigin(Graphics graphics, Pen pen)
|
||||
{
|
||||
// draw the coordinate system origin
|
||||
graphics.DrawLine(pen, new Point(m_origin.X - 10, m_origin.Y), new Point(m_origin.X + 10, m_origin.Y));
|
||||
graphics.DrawLine(pen, new Point(m_origin.X, m_origin.Y - 10), new Point(m_origin.X, m_origin.Y + 10));
|
||||
graphics.DrawString("(0,0)", m_coordinateFont, Brushes.Blue, new PointF(m_origin.X + 2, m_origin.Y + 2));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// draw the baseline / the candidate baseline (start point confirmed, end point didn't)
|
||||
/// </summary>
|
||||
/// <param name="graphics">
|
||||
/// form graphic
|
||||
/// </param>
|
||||
/// <param name="pen">
|
||||
/// pen used to draw line in pictureBox
|
||||
/// </param>
|
||||
private void DrawBaseline(Graphics graphics, Pen pen)
|
||||
{
|
||||
if (Point.Empty != m_wallLine2D.AssistantPoint)
|
||||
{
|
||||
if (Point.Empty != m_wallLine2D.StartPoint)
|
||||
{
|
||||
graphics.DrawLine(pen, m_wallLine2D.StartPoint, m_wallLine2D.AssistantPoint);
|
||||
}
|
||||
|
||||
// show the real-time coordinate of the mouse position
|
||||
WriteCoordinate(graphics, pen);
|
||||
}
|
||||
|
||||
if (Point.Empty != m_wallLine2D.EndPoint &&
|
||||
Point.Empty != m_wallLine2D.EndPoint)
|
||||
{
|
||||
graphics.DrawLine(pen, m_wallLine2D.StartPoint, m_wallLine2D.EndPoint);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// write the coordinate for moving mouse
|
||||
/// </summary>
|
||||
/// <param name="graphics">
|
||||
/// form graphic
|
||||
/// </param>
|
||||
/// <param name="pen">
|
||||
/// pen used to draw line in pictureBox
|
||||
/// </param>
|
||||
private void WriteCoordinate(Graphics graphics, Pen pen)
|
||||
{
|
||||
PointD assistPointD = ConvertToPointD(m_wallLine2D.AssistantPoint);
|
||||
double x = Unit.CovertFromAPI(m_myDocument.LengthUnit, assistPointD.X);
|
||||
double y = Unit.CovertFromAPI(m_myDocument.LengthUnit, assistPointD.Y);
|
||||
|
||||
string xCoorString = Convert.ToString(Math.Round(x, 1));
|
||||
string yCoorString = Convert.ToString(Math.Round(y, 1));
|
||||
|
||||
string unitType = Unit.GetUnitLabel(m_myDocument.LengthUnit);
|
||||
String coordinate = "(" + xCoorString + unitType + "," + yCoorString + unitType + ")";
|
||||
graphics.DrawString(coordinate, m_coordinateFont, Brushes.Blue,
|
||||
new PointF(m_wallLine2D.AssistantPoint.X + 2, m_wallLine2D.AssistantPoint.Y + 2));
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,237 @@
|
||||
//
|
||||
// (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.Text;
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
|
||||
using Autodesk.Revit.DB;
|
||||
using Autodesk.Revit.UI;
|
||||
|
||||
namespace Revit.SDK.Samples.CurtainWallGrid.CS
|
||||
{
|
||||
/// <summary>
|
||||
/// the class manages the creation operation for the curtain wall
|
||||
/// </summary>
|
||||
public class WallGeometry
|
||||
{
|
||||
#region Fields
|
||||
// the document of this sample
|
||||
MyDocument m_myDocument;
|
||||
|
||||
// the refferred drawing class for the curtain wall
|
||||
private WallDrawing m_drawing;
|
||||
|
||||
// the selected ViewPlan used for curtain wall creation
|
||||
Autodesk.Revit.DB.ViewPlan m_selectedView;
|
||||
|
||||
// the selected wall type
|
||||
WallType m_selectedWallType;
|
||||
|
||||
// store the start point of baseline (in PointD format)
|
||||
PointD m_startPointD;
|
||||
|
||||
//store the start point of baseline (in Autodesk.Revit.DB.XYZ format)
|
||||
Autodesk.Revit.DB.XYZ m_startXYZ;
|
||||
|
||||
// store the end point of baseline (in PointD format)
|
||||
PointD m_endPointD;
|
||||
|
||||
//store the end point of baseline (in Autodesk.Revit.DB.XYZ format)
|
||||
Autodesk.Revit.DB.XYZ m_endXYZ;
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
/// <summary>
|
||||
/// the document of this sample
|
||||
/// </summary>
|
||||
public MyDocument MyDocument
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_myDocument;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// the refferred drawing class for the curtain wall
|
||||
/// </summary>
|
||||
public WallDrawing Drawing
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_drawing;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// the selected ViewPlan used for curtain wall creation
|
||||
/// </summary>
|
||||
public Autodesk.Revit.DB.ViewPlan SelectedView
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_selectedView;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_selectedView = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// the selected wall type
|
||||
/// </summary>
|
||||
public WallType SelectedWallType
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_selectedWallType;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_selectedWallType = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// store the start point of baseline (in PointD format)
|
||||
/// </summary>
|
||||
public PointD StartPointD
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_startPointD;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_startPointD = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get start point of baseline
|
||||
/// </summary>
|
||||
public Autodesk.Revit.DB.XYZ StartXYZ
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_startXYZ;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_startXYZ = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// store the end point of baseline (in PointD format)
|
||||
/// </summary>
|
||||
public PointD EndPointD
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_endPointD;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_endPointD = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get end point of baseline
|
||||
/// </summary>
|
||||
public Autodesk.Revit.DB.XYZ EndXYZ
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_endXYZ;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_endXYZ = value;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
/// <summary>
|
||||
/// default constructor
|
||||
/// </summary>
|
||||
/// <param name="myDoc">
|
||||
/// the document of the sample
|
||||
/// </param>
|
||||
public WallGeometry(MyDocument myDoc)
|
||||
{
|
||||
m_myDocument = myDoc;
|
||||
m_drawing = new WallDrawing(this);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Public methods
|
||||
/// <summary>
|
||||
/// create the curtain wall to the active document of Revit
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// the created curtain wall
|
||||
/// </returns>
|
||||
public Wall CreateCurtainWall()
|
||||
{
|
||||
if (null == m_selectedWallType || null == m_selectedView)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
Autodesk.Revit.Creation.Document createDoc = m_myDocument.Document.Create;
|
||||
Autodesk.Revit.Creation.Application createApp = m_myDocument.CommandData.Application.Application.Create;
|
||||
//baseline
|
||||
System.Drawing.Point point0 = m_drawing.WallLine2D.StartPoint;
|
||||
System.Drawing.Point point1 = m_drawing.WallLine2D.EndPoint;
|
||||
//new baseline and transform coordinate on windows UI to Revit UI
|
||||
m_startXYZ = new Autodesk.Revit.DB.XYZ(m_startPointD.X, m_startPointD.Y, 0);
|
||||
m_endXYZ = new Autodesk.Revit.DB.XYZ(m_endPointD.X, m_endPointD.Y, 0);
|
||||
Autodesk.Revit.DB.Line baseline = null;
|
||||
try
|
||||
{
|
||||
baseline = Line.CreateBound(m_startXYZ, m_endXYZ);
|
||||
}
|
||||
catch (System.ArgumentException)
|
||||
{
|
||||
TaskDialog.Show("Revit", "The start point and the end point of the line are too close, please re-draw it.");
|
||||
}
|
||||
Transaction act = new Transaction(m_myDocument.Document);
|
||||
act.Start(Guid.NewGuid().GetHashCode().ToString());
|
||||
Wall wall = Wall.Create(m_myDocument.Document, baseline, m_selectedWallType.Id,
|
||||
m_selectedView.GenLevel.Id, 20, 0, false, false);
|
||||
act.Commit();
|
||||
Transaction act2 = new Transaction(m_myDocument.Document);
|
||||
act2.Start(Guid.NewGuid().GetHashCode().ToString());
|
||||
m_myDocument.UIDocument.ShowElements(wall);
|
||||
act2.Commit();
|
||||
return wall;
|
||||
}
|
||||
#endregion
|
||||
}// end of class
|
||||
}
|
||||
Reference in New Issue
Block a user