mirror of
https://github.com/jeremytammik/RevitSdkSamples.git
synced 2026-09-22 03:40:55 +00:00
added Revit 2022 SDK minus except *rvt and *rfa
This commit is contained in:
@@ -0,0 +1,232 @@
|
||||
//
|
||||
// (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;
|
||||
using Autodesk.Revit.UI;
|
||||
using Autodesk.Revit;
|
||||
using Autodesk.Revit.ApplicationServices;
|
||||
|
||||
namespace Revit.SDK.Samples.Openings.CS
|
||||
{
|
||||
/// <summary>
|
||||
/// This class which inherit from Autodesk.Revit.DB.BoundingBoxXYZ
|
||||
/// store the information about Max (Min) coordinate of object
|
||||
/// can get all the corner point coordinate and create X model line
|
||||
/// </summary>
|
||||
public class BoundingBox : BoundingBoxXYZ
|
||||
{
|
||||
/// <summary>
|
||||
/// define whether we have created Model Line on this BoundingBox
|
||||
/// </summary>
|
||||
private bool m_isCreated;
|
||||
|
||||
/// <summary>
|
||||
/// store all the corner points in BoundingBox
|
||||
/// </summary>
|
||||
private readonly List<Autodesk.Revit.DB.XYZ> m_points = new List<Autodesk.Revit.DB.XYZ>();
|
||||
|
||||
/// <summary>
|
||||
/// property to get all the points
|
||||
/// </summary>
|
||||
public List<Autodesk.Revit.DB.XYZ> Points
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_points;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// property to get width of BoundingBox (short side)
|
||||
/// </summary>
|
||||
public double Width
|
||||
{
|
||||
get
|
||||
{
|
||||
double yDistance = 0;
|
||||
double xDistance = 0;
|
||||
yDistance = m_points[2].Y - m_points[1].Y;
|
||||
xDistance = m_points[5].X - m_points[2].X;
|
||||
return xDistance < yDistance ? xDistance : yDistance;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// property to get Length of BoundingBox (long side)
|
||||
/// </summary>
|
||||
public double Length
|
||||
{
|
||||
get
|
||||
{
|
||||
double yDistance = 0;
|
||||
double xDistance = 0;
|
||||
yDistance = m_points[2].Y - m_points[1].Y;
|
||||
xDistance = m_points[5].X - m_points[2].X;
|
||||
return xDistance > yDistance ? xDistance : yDistance;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The default constructor
|
||||
/// </summary>
|
||||
/// <param name="boundBoxXYZ">The reference of the application in revit</param>
|
||||
public BoundingBox(BoundingBoxXYZ boundBoxXYZ)
|
||||
{
|
||||
this.Min = boundBoxXYZ.Min;
|
||||
this.Max = boundBoxXYZ.Max;
|
||||
|
||||
GetCorners();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create X model line with the BoundBox
|
||||
/// Create 12 lines to makeup an cube
|
||||
/// </summary>
|
||||
/// <param name="app">Application get from RevitAPI</param>
|
||||
public void CreateLines(UIApplication app)
|
||||
{
|
||||
if (m_isCreated)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//create 12 lines
|
||||
for (int i = 0; i < 7; i++)
|
||||
{
|
||||
NewModelLine(app, i, i + 1);
|
||||
}
|
||||
|
||||
for (int i = 0; i < 5; i = i + 2)
|
||||
{
|
||||
NewModelLine(app, i, i + 3);
|
||||
}
|
||||
|
||||
NewModelLine(app, 1, 6);
|
||||
NewModelLine(app, 0, 7);
|
||||
|
||||
m_isCreated = true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// get all the Corner points of Cube Box via Min and Max
|
||||
/// </summary>
|
||||
private void GetCorners()
|
||||
{
|
||||
m_points.Add(this.Min);
|
||||
|
||||
Autodesk.Revit.DB.XYZ point = new Autodesk.Revit.DB.XYZ(
|
||||
this.Min.X,
|
||||
this.Min.Y,
|
||||
this.Max.Z);
|
||||
m_points.Add(point);
|
||||
|
||||
Autodesk.Revit.DB.XYZ point2 = new Autodesk.Revit.DB.XYZ(
|
||||
this.Min.X,
|
||||
this.Max.Y,
|
||||
this.Max.Z);
|
||||
m_points.Add(point2);
|
||||
|
||||
Autodesk.Revit.DB.XYZ point3 = new Autodesk.Revit.DB.XYZ(
|
||||
this.Min.X,
|
||||
this.Max.Y,
|
||||
this.Min.Z);
|
||||
m_points.Add(point3);
|
||||
|
||||
Autodesk.Revit.DB.XYZ point4 = new Autodesk.Revit.DB.XYZ(
|
||||
this.Max.X,
|
||||
this.Max.Y,
|
||||
this.Min.Z);
|
||||
m_points.Add(point4);
|
||||
|
||||
m_points.Add(this.Max);
|
||||
|
||||
Autodesk.Revit.DB.XYZ point5 = new Autodesk.Revit.DB.XYZ(
|
||||
this.Max.X,
|
||||
this.Min.Y,
|
||||
this.Max.Z);
|
||||
m_points.Add(point5);
|
||||
|
||||
Autodesk.Revit.DB.XYZ point6 = new Autodesk.Revit.DB.XYZ(
|
||||
this.Max.X,
|
||||
this.Min.Y,
|
||||
this.Min.Z);
|
||||
m_points.Add(point6);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create a Sketch Plane which pass the defined line
|
||||
/// the defined line must be one of BoundingBox Profile
|
||||
/// </summary>
|
||||
/// <param name="app">Application get from RevitAPI</param>
|
||||
/// <param name="aline">a line which sketch plane pass</param>
|
||||
private SketchPlane NewSketchPlanePassLine(Line aline, UIApplication app)
|
||||
{
|
||||
//in a cube only
|
||||
Autodesk.Revit.DB.XYZ norm;
|
||||
if (aline.GetEndPoint(0).X == aline.GetEndPoint(1).X)
|
||||
{
|
||||
norm = new Autodesk.Revit.DB.XYZ(1, 0, 0);
|
||||
}
|
||||
else if (aline.GetEndPoint(0).Y == aline.GetEndPoint(1).Y)
|
||||
{
|
||||
norm = new Autodesk.Revit.DB.XYZ(0, 1, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
norm = new Autodesk.Revit.DB.XYZ(0, 0, 1);
|
||||
}
|
||||
|
||||
Autodesk.Revit.DB.XYZ point = aline.GetEndPoint(0);
|
||||
Plane plane = Plane.CreateByNormalAndOrigin(norm, point);
|
||||
SketchPlane sketchPlane = SketchPlane.Create(app.ActiveUIDocument.Document, plane);
|
||||
return sketchPlane;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// new ModelLine in BoundingBox
|
||||
/// </summary>
|
||||
/// <param name="app">Application get from RevitAPI</param>
|
||||
/// <param name="pointIndex1">index of point in BoundingBox acme</param>
|
||||
/// <param name="pointIndex2">index of another point in BoundingBox acme</param>
|
||||
private void NewModelLine(UIApplication app, int pointIndex1, int pointIndex2)
|
||||
{
|
||||
Autodesk.Revit.DB.XYZ startP2 = m_points[pointIndex1];
|
||||
Autodesk.Revit.DB.XYZ endP2 = m_points[pointIndex2];
|
||||
|
||||
try
|
||||
{
|
||||
Line line = Line.CreateBound(startP2, endP2);
|
||||
SketchPlane sketchPlane = NewSketchPlanePassLine(line, app);
|
||||
Line line2 = Line.CreateBound(startP2, endP2);
|
||||
app.ActiveUIDocument.Document.Create.NewModelCurve(line2, sketchPlane);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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 Autodesk.Revit;
|
||||
using Autodesk.Revit.ApplicationServices;
|
||||
using Autodesk.Revit.DB;
|
||||
using Autodesk.Revit.UI;
|
||||
using Autodesk.Revit.DB.Structure;
|
||||
|
||||
|
||||
namespace Revit.SDK.Samples.Openings.CS
|
||||
{
|
||||
/// <summary>
|
||||
/// The entrance of this example, implement the Execute method of IExternalCommand
|
||||
/// </summary>
|
||||
[Autodesk.Revit.Attributes.Transaction(Autodesk.Revit.Attributes.TransactionMode.Manual)]
|
||||
[Autodesk.Revit.Attributes.Regeneration(Autodesk.Revit.Attributes.RegenerationOption.Manual)]
|
||||
[Autodesk.Revit.Attributes.Journaling(Autodesk.Revit.Attributes.JournalingMode.NoCommandData)]
|
||||
public class Command : IExternalCommand
|
||||
{
|
||||
#region IExternalCommand Members
|
||||
|
||||
/// <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)
|
||||
{
|
||||
Transaction transaction = new Transaction(commandData.Application.ActiveUIDocument.Document, "External Tool");
|
||||
try
|
||||
{
|
||||
transaction.Start();
|
||||
Application app = commandData.Application.Application;
|
||||
bool haveOpening = false;
|
||||
|
||||
//search Opening in Revit
|
||||
List<OpeningInfo> openingInfos = new List<OpeningInfo>();
|
||||
FilteredElementIterator iter = (new FilteredElementCollector(commandData.Application.ActiveUIDocument.Document)).OfClass(typeof(Opening)).GetElementIterator();
|
||||
iter.Reset();
|
||||
while (iter.MoveNext())
|
||||
{
|
||||
Object obj = iter.Current;
|
||||
if (obj is Opening)
|
||||
{
|
||||
haveOpening = true;
|
||||
Opening opening = obj as Opening;
|
||||
OpeningInfo openingInfo = new OpeningInfo(opening, commandData.Application);
|
||||
openingInfos.Add(openingInfo);
|
||||
}
|
||||
}
|
||||
|
||||
if (!haveOpening)
|
||||
{
|
||||
message = "don't have opening in the project";
|
||||
return Autodesk.Revit.UI.Result.Cancelled;
|
||||
}
|
||||
|
||||
//show dialogue
|
||||
using (OpeningForm openingForm = new OpeningForm(openingInfos))
|
||||
{
|
||||
openingForm.ShowDialog();
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
message = e.ToString();
|
||||
return Autodesk.Revit.UI.Result.Failed;
|
||||
}
|
||||
finally
|
||||
{
|
||||
transaction.Commit();
|
||||
}
|
||||
|
||||
return Autodesk.Revit.UI.Result.Succeeded;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,166 @@
|
||||
//
|
||||
// (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.Openings.CS
|
||||
{
|
||||
/// <summary>
|
||||
/// creat model line options form
|
||||
/// </summary>
|
||||
partial class CreateModelLineOptionsForm
|
||||
{
|
||||
/// <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.CreateAllRadioButton = new System.Windows.Forms.RadioButton();
|
||||
this.CreateShaftRadioButton = new System.Windows.Forms.RadioButton();
|
||||
this.CreateDisplayRadioButton = new System.Windows.Forms.RadioButton();
|
||||
this.CreateButton = new System.Windows.Forms.Button();
|
||||
this.cancelButton = new System.Windows.Forms.Button();
|
||||
this.OptionsGroupBox = new System.Windows.Forms.GroupBox();
|
||||
this.OptionsGroupBox.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// CreateAllRadioButton
|
||||
//
|
||||
this.CreateAllRadioButton.AutoSize = true;
|
||||
this.CreateAllRadioButton.Location = new System.Drawing.Point(17, 32);
|
||||
this.CreateAllRadioButton.Name = "CreateAllRadioButton";
|
||||
this.CreateAllRadioButton.Size = new System.Drawing.Size(197, 17);
|
||||
this.CreateAllRadioButton.TabIndex = 0;
|
||||
this.CreateAllRadioButton.TabStop = true;
|
||||
this.CreateAllRadioButton.Text = "Create X Model Line on all Openings";
|
||||
this.CreateAllRadioButton.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// CreateShaftRadioButton
|
||||
//
|
||||
this.CreateShaftRadioButton.AutoSize = true;
|
||||
this.CreateShaftRadioButton.Location = new System.Drawing.Point(17, 66);
|
||||
this.CreateShaftRadioButton.Name = "CreateShaftRadioButton";
|
||||
this.CreateShaftRadioButton.Size = new System.Drawing.Size(225, 17);
|
||||
this.CreateShaftRadioButton.TabIndex = 1;
|
||||
this.CreateShaftRadioButton.TabStop = true;
|
||||
this.CreateShaftRadioButton.Text = "Create X Model Line on all Shaft Openings";
|
||||
this.CreateShaftRadioButton.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// CreateDisplayRadioButton
|
||||
//
|
||||
this.CreateDisplayRadioButton.AutoSize = true;
|
||||
this.CreateDisplayRadioButton.Checked = true;
|
||||
this.CreateDisplayRadioButton.Location = new System.Drawing.Point(17, 105);
|
||||
this.CreateDisplayRadioButton.Name = "CreateDisplayRadioButton";
|
||||
this.CreateDisplayRadioButton.Size = new System.Drawing.Size(244, 17);
|
||||
this.CreateDisplayRadioButton.TabIndex = 2;
|
||||
this.CreateDisplayRadioButton.TabStop = true;
|
||||
this.CreateDisplayRadioButton.Text = "Create X Model Line on the displayed Opening";
|
||||
this.CreateDisplayRadioButton.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// CreateButton
|
||||
//
|
||||
this.CreateButton.Location = new System.Drawing.Point(141, 164);
|
||||
this.CreateButton.Name = "CreateButton";
|
||||
this.CreateButton.Size = new System.Drawing.Size(75, 23);
|
||||
this.CreateButton.TabIndex = 3;
|
||||
this.CreateButton.Text = "C&reate";
|
||||
this.CreateButton.UseVisualStyleBackColor = true;
|
||||
this.CreateButton.Click += new System.EventHandler(this.CreateButton_Click);
|
||||
//
|
||||
// cancelButton
|
||||
//
|
||||
this.cancelButton.DialogResult = System.Windows.Forms.DialogResult.Cancel;
|
||||
this.cancelButton.Location = new System.Drawing.Point(222, 164);
|
||||
this.cancelButton.Name = "cancelButton";
|
||||
this.cancelButton.Size = new System.Drawing.Size(75, 23);
|
||||
this.cancelButton.TabIndex = 4;
|
||||
this.cancelButton.Text = "&Cancel";
|
||||
this.cancelButton.UseVisualStyleBackColor = true;
|
||||
this.cancelButton.Click += new System.EventHandler(this.cancelButton_Click);
|
||||
//
|
||||
// OptionsGroupBox
|
||||
//
|
||||
this.OptionsGroupBox.Controls.Add(this.CreateAllRadioButton);
|
||||
this.OptionsGroupBox.Controls.Add(this.CreateShaftRadioButton);
|
||||
this.OptionsGroupBox.Controls.Add(this.CreateDisplayRadioButton);
|
||||
this.OptionsGroupBox.Location = new System.Drawing.Point(12, 12);
|
||||
this.OptionsGroupBox.Name = "OptionsGroupBox";
|
||||
this.OptionsGroupBox.Size = new System.Drawing.Size(285, 146);
|
||||
this.OptionsGroupBox.TabIndex = 5;
|
||||
this.OptionsGroupBox.TabStop = false;
|
||||
this.OptionsGroupBox.Text = "Options :";
|
||||
//
|
||||
// CreateModelLineOptionsForm
|
||||
//
|
||||
this.AcceptButton = this.CreateButton;
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.CancelButton = this.cancelButton;
|
||||
this.ClientSize = new System.Drawing.Size(309, 197);
|
||||
this.Controls.Add(this.OptionsGroupBox);
|
||||
this.Controls.Add(this.cancelButton);
|
||||
this.Controls.Add(this.CreateButton);
|
||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
|
||||
this.MaximizeBox = false;
|
||||
this.MinimizeBox = false;
|
||||
this.Name = "CreateModelLineOptionsForm";
|
||||
this.ShowIcon = false;
|
||||
this.ShowInTaskbar = false;
|
||||
this.Text = "Create X Model Line Options";
|
||||
this.OptionsGroupBox.ResumeLayout(false);
|
||||
this.OptionsGroupBox.PerformLayout();
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.RadioButton CreateAllRadioButton;
|
||||
private System.Windows.Forms.RadioButton CreateShaftRadioButton;
|
||||
private System.Windows.Forms.RadioButton CreateDisplayRadioButton;
|
||||
private System.Windows.Forms.Button CreateButton;
|
||||
private System.Windows.Forms.Button cancelButton;
|
||||
private System.Windows.Forms.GroupBox OptionsGroupBox;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,96 @@
|
||||
//
|
||||
// (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.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace Revit.SDK.Samples.Openings.CS
|
||||
{
|
||||
/// <summary>
|
||||
/// create model line options form
|
||||
/// </summary>
|
||||
public partial class CreateModelLineOptionsForm : System.Windows.Forms.Form
|
||||
{
|
||||
/// <summary>
|
||||
/// The default constructor
|
||||
/// </summary>
|
||||
public CreateModelLineOptionsForm()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// constructor of CreateModelLineOptionsForm
|
||||
/// </summary>
|
||||
/// <param name="openingInfos">a list of OpeningInfo</param>
|
||||
/// /// <param name="selectOpening">current displayed (in preview) Opening</param>
|
||||
public CreateModelLineOptionsForm(List<OpeningInfo> openingInfos,
|
||||
OpeningInfo selectOpening)
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
m_openingInfos = openingInfos;
|
||||
m_selectedOpeningInfo = selectOpening;
|
||||
}
|
||||
|
||||
private List<OpeningInfo> m_openingInfos; //store all the OpeningInfo class
|
||||
private OpeningInfo m_selectedOpeningInfo; //current displayed (in preview) OpeningInfo
|
||||
|
||||
private void CreateButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (CreateDisplayRadioButton.Checked)
|
||||
{
|
||||
m_selectedOpeningInfo.BoundingBox.CreateLines(m_selectedOpeningInfo.Revit);
|
||||
}
|
||||
else if (CreateAllRadioButton.Checked)
|
||||
{
|
||||
foreach (OpeningInfo openingInfo in m_openingInfos)
|
||||
{
|
||||
openingInfo.BoundingBox.CreateLines(m_selectedOpeningInfo.Revit);
|
||||
}
|
||||
}
|
||||
else if (CreateShaftRadioButton.Checked)
|
||||
{
|
||||
foreach (OpeningInfo openingInfo in m_openingInfos)
|
||||
{
|
||||
if (openingInfo.IsShaft)
|
||||
{
|
||||
openingInfo.BoundingBox.CreateLines(m_selectedOpeningInfo.Revit);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.Close();
|
||||
}
|
||||
|
||||
private void cancelButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
this.Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
||||
@@ -0,0 +1,225 @@
|
||||
//
|
||||
// (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.Openings.CS
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Drawing;
|
||||
|
||||
/// <summary>
|
||||
/// represent a geometry segment line
|
||||
/// </summary>
|
||||
public class Line2D
|
||||
{
|
||||
private PointF m_startPnt = new PointF(); // start point
|
||||
private PointF m_endPnt = new PointF(); // end point
|
||||
private float m_length; // length of the line
|
||||
// normal of the line; start point to end point
|
||||
private PointF m_normal = new PointF();
|
||||
private RectangleF m_boundingBox = new RectangleF();// rectangle box contains the line
|
||||
|
||||
/// <summary>
|
||||
/// rectangle box contains the line
|
||||
/// </summary>
|
||||
public RectangleF BoundingBox
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_boundingBox;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// start point of the line; if it is set to new value,
|
||||
/// EndPoint is changeless; Length, Normal and BoundingBox will updated
|
||||
/// </summary>
|
||||
public PointF StartPnt
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_startPnt;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (m_startPnt == value)
|
||||
{
|
||||
return;
|
||||
}
|
||||
m_startPnt = value;
|
||||
CalculateDirection();
|
||||
CalculateBoundingBox();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// end point of the line; if it is set to new value,
|
||||
/// StartPoint is changeless; Length, Normal and BoundingBox will updated
|
||||
/// </summary>
|
||||
public PointF EndPnt
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_endPnt;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (m_endPnt == value)
|
||||
{
|
||||
return;
|
||||
}
|
||||
m_endPnt = value;
|
||||
CalculateDirection();
|
||||
CalculateBoundingBox();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Length of the line; if it is set to new value,
|
||||
/// StartPoint and Normal is changeless; EndPoint and BoundingBox will updated
|
||||
/// </summary>
|
||||
public float Length
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_length;
|
||||
|
||||
}
|
||||
set
|
||||
{
|
||||
if (m_length == value)
|
||||
{
|
||||
return;
|
||||
}
|
||||
m_length = value;
|
||||
CalculateEndPoint();
|
||||
CalculateBoundingBox();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Normal of the line; if it is set to new value,
|
||||
/// StartPoint is changeless; EndPoint and BoundingBox will updated
|
||||
/// </summary>
|
||||
public PointF Normal
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_normal;
|
||||
|
||||
}
|
||||
set
|
||||
{
|
||||
if (m_normal == value)
|
||||
{
|
||||
return;
|
||||
}
|
||||
m_normal = value;
|
||||
CalculateEndPoint();
|
||||
CalculateBoundingBox();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// constructor
|
||||
/// default StartPoint = (0.0, 0.0), EndPoint = (1.0, 0.0)
|
||||
/// </summary>
|
||||
public Line2D()
|
||||
{
|
||||
m_startPnt.X = 0.0f;
|
||||
m_startPnt.Y = 0.0f;
|
||||
m_endPnt.X = 1.0f;
|
||||
m_endPnt.Y = 0.0f;
|
||||
CalculateDirection();
|
||||
CalculateBoundingBox();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// constructor
|
||||
/// </summary>
|
||||
/// <param name="startPnt">StartPoint</param>
|
||||
/// <param name="endPnt">EndPoint</param>
|
||||
public Line2D(PointF startPnt, PointF endPnt)
|
||||
{
|
||||
m_startPnt = startPnt;
|
||||
m_endPnt = endPnt;
|
||||
CalculateDirection();
|
||||
CalculateBoundingBox();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// calculate BoundingBox according to StartPoint and EndPoint
|
||||
/// </summary>
|
||||
private void CalculateBoundingBox()
|
||||
{
|
||||
float x1 = m_endPnt.X;
|
||||
float x2 = m_startPnt.X;
|
||||
float y1 = m_endPnt.Y;
|
||||
float y2 = m_startPnt.Y;
|
||||
|
||||
float width = Math.Abs(x1 - x2);
|
||||
float height = Math.Abs(y1 - y2);
|
||||
|
||||
if (x1 > x2)
|
||||
{
|
||||
x1 = x2;
|
||||
}
|
||||
if (y1 > y2)
|
||||
{
|
||||
y1 = y2;
|
||||
}
|
||||
m_boundingBox = new RectangleF(x1, y1, width, height);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// calculate length by StartPoint and EndPoint
|
||||
/// </summary>
|
||||
private void CalculateLength()
|
||||
{
|
||||
m_length =
|
||||
(float)Math.Sqrt(Math.Pow((m_startPnt.X - m_endPnt.X), 2) +
|
||||
Math.Pow((m_startPnt.Y - m_endPnt.Y), 2));
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// calculate Direction by StartPoint and EndPoint
|
||||
/// </summary>
|
||||
private void CalculateDirection()
|
||||
{
|
||||
CalculateLength();
|
||||
m_normal.X = (m_endPnt.X - m_startPnt.X) / m_length;
|
||||
m_normal.Y = (m_endPnt.Y - m_startPnt.Y) / m_length;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// calculate EndPoint by StartPoint, Length and Direction
|
||||
/// </summary>
|
||||
private void CalculateEndPoint()
|
||||
{
|
||||
m_endPnt.X = m_startPnt.X + m_length * m_normal.X;
|
||||
m_endPnt.Y = m_startPnt.Y + m_length * m_normal.Y;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,170 @@
|
||||
//
|
||||
// (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;
|
||||
|
||||
namespace Revit.SDK.Samples.Openings.CS
|
||||
{
|
||||
/// <summary>
|
||||
/// Line class use to store information about line(include startPoint and endPoint)
|
||||
/// and get the value via (startPoint, endPoint)property
|
||||
/// </summary>
|
||||
public class Line3D
|
||||
{
|
||||
Vector m_startPnt; //start point
|
||||
Vector m_endPnt; //end point
|
||||
Vector m_normal; //normal
|
||||
double m_length; //length of line
|
||||
|
||||
//property
|
||||
/// <summary>
|
||||
/// Property to get and set length of line
|
||||
/// </summary>
|
||||
public double Length
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_length;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (m_length == value)
|
||||
{
|
||||
return;
|
||||
}
|
||||
m_length = value;
|
||||
CalculateEndPoint();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Property to get and set Start Point of line
|
||||
/// </summary>
|
||||
public Vector StartPoint
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_startPnt;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (m_startPnt == value)
|
||||
{
|
||||
return;
|
||||
}
|
||||
m_startPnt = value;
|
||||
CalculateDirection();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Property to get and set End Point of line
|
||||
/// </summary>
|
||||
public Vector EndPoint
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_endPnt;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (m_endPnt == value)
|
||||
{
|
||||
return;
|
||||
}
|
||||
m_endPnt = value;
|
||||
CalculateDirection();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Property to get and set Normal of line
|
||||
/// </summary>
|
||||
public Vector Normal
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_normal;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (m_normal == value)
|
||||
{
|
||||
return;
|
||||
}
|
||||
m_normal = value;
|
||||
CalculateEndPoint();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The default constructor
|
||||
/// </summary>
|
||||
public Line3D()
|
||||
{
|
||||
m_startPnt = new Vector(0.0, 0.0, 0.0);
|
||||
m_endPnt = new Vector(1.0, 0.0, 0.0);
|
||||
m_length = 1.0;
|
||||
m_normal = new Vector(1.0, 0.0, 0.0);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The default constructor
|
||||
/// </summary>
|
||||
/// <param name="startPnt">start point of line</param>
|
||||
/// <param name="endPnt">enn point of line</param>
|
||||
public Line3D(Vector startPnt, Vector endPnt)
|
||||
{
|
||||
m_startPnt = startPnt;
|
||||
m_endPnt = endPnt;
|
||||
CalculateDirection();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// calculate length by StartPoint and EndPoint
|
||||
/// </summary>
|
||||
private void CalculateLength()
|
||||
{
|
||||
m_length = ~(m_startPnt - m_endPnt);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// calculate Direction by StartPoint and EndPoint
|
||||
/// </summary>
|
||||
private void CalculateDirection()
|
||||
{
|
||||
CalculateLength();
|
||||
m_normal = (m_endPnt - m_startPnt) / m_length;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// calculate EndPoint by StartPoint, Length and Direction
|
||||
/// </summary>
|
||||
private void CalculateEndPoint()
|
||||
{
|
||||
m_endPnt = m_startPnt + m_normal * m_length;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
//
|
||||
// (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.Drawing.Drawing2D;
|
||||
|
||||
using Autodesk.Revit.DB;
|
||||
|
||||
namespace Revit.SDK.Samples.Openings.CS
|
||||
{
|
||||
/// <summary>
|
||||
/// sketch line and any tag on it
|
||||
/// </summary>
|
||||
public class LineSketch : ObjectSketch
|
||||
{
|
||||
private Line2D m_line = new Line2D(); // geometry line to draw
|
||||
|
||||
/// <summary>
|
||||
/// constructor
|
||||
/// </summary>
|
||||
/// <param name="line"></param>
|
||||
public LineSketch(Line2D line)
|
||||
{
|
||||
m_line = line;
|
||||
m_boundingBox = line.BoundingBox;
|
||||
m_pen.Color = System.Drawing.Color.Yellow;
|
||||
m_pen.Width = 1f;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// draw the line
|
||||
/// </summary>
|
||||
/// <param name="g">drawing object</param>
|
||||
/// <param name="translate">translation between drawn sketch and geometry object</param>
|
||||
public override void Draw(Graphics g, Matrix translate)
|
||||
{
|
||||
m_transform = translate;
|
||||
GraphicsPath path = new GraphicsPath();
|
||||
path.AddLine(m_line.StartPnt, m_line.EndPnt);
|
||||
path.Transform(translate);
|
||||
g.DrawPath(m_pen, path);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
//
|
||||
// (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.Drawing.Drawing2D;
|
||||
|
||||
namespace Revit.SDK.Samples.Openings.CS
|
||||
{
|
||||
/// <summary>
|
||||
/// base class of sketch object to draw 2D geometry object
|
||||
/// </summary>
|
||||
public abstract class ObjectSketch
|
||||
{
|
||||
/// <summary>
|
||||
/// bounding box of the geometry object
|
||||
/// </summary>
|
||||
protected RectangleF m_boundingBox = new RectangleF();
|
||||
|
||||
/// <summary>
|
||||
/// pen to draw the object
|
||||
/// </summary>
|
||||
protected Pen m_pen = new Pen(System.Drawing.Color.DarkGreen);
|
||||
|
||||
/// <summary>
|
||||
/// defines a local geometric transform
|
||||
/// </summary>
|
||||
protected Matrix m_transform;
|
||||
|
||||
/// <summary>
|
||||
/// reserve lines that form the profile
|
||||
/// </summary>
|
||||
protected List<ObjectSketch> m_objects = new List<ObjectSketch>();
|
||||
|
||||
/// <summary>
|
||||
/// bounding box of the geometry object
|
||||
/// </summary>
|
||||
public RectangleF BoundingBox
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_boundingBox;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// geometric object draw itself
|
||||
/// </summary>
|
||||
/// <param name="g"></param>
|
||||
/// <param name="translate"></param>
|
||||
public abstract void Draw(Graphics g, Matrix translate);
|
||||
}
|
||||
}
|
||||
+156
@@ -0,0 +1,156 @@
|
||||
//
|
||||
// (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.Openings.CS
|
||||
{
|
||||
partial class OpeningForm
|
||||
{
|
||||
/// <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.PreviewPictureBox = new System.Windows.Forms.PictureBox();
|
||||
this.Createbutton = new System.Windows.Forms.Button();
|
||||
this.OpeningPropertyGrid = new System.Windows.Forms.PropertyGrid();
|
||||
this.OKButton = new System.Windows.Forms.Button();
|
||||
this.OpeningListComboBox = new System.Windows.Forms.ComboBox();
|
||||
this.label1 = new System.Windows.Forms.Label();
|
||||
((System.ComponentModel.ISupportInitialize)(this.PreviewPictureBox)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// PreviewPictureBox
|
||||
//
|
||||
this.PreviewPictureBox.Location = new System.Drawing.Point(12, 12);
|
||||
this.PreviewPictureBox.Name = "PreviewPictureBox";
|
||||
this.PreviewPictureBox.Size = new System.Drawing.Size(286, 290);
|
||||
this.PreviewPictureBox.TabIndex = 0;
|
||||
this.PreviewPictureBox.TabStop = false;
|
||||
this.PreviewPictureBox.Paint += new System.Windows.Forms.PaintEventHandler(this.PreviewPictureBox_Paint);
|
||||
//
|
||||
// Createbutton
|
||||
//
|
||||
this.Createbutton.Location = new System.Drawing.Point(370, 308);
|
||||
this.Createbutton.Name = "Createbutton";
|
||||
this.Createbutton.Size = new System.Drawing.Size(108, 23);
|
||||
this.Createbutton.TabIndex = 2;
|
||||
this.Createbutton.Text = "&Add X Model Line";
|
||||
this.Createbutton.UseVisualStyleBackColor = true;
|
||||
this.Createbutton.Click += new System.EventHandler(this.Createbutton_Click);
|
||||
//
|
||||
// OpeningPropertyGrid
|
||||
//
|
||||
this.OpeningPropertyGrid.Location = new System.Drawing.Point(304, 70);
|
||||
this.OpeningPropertyGrid.Name = "OpeningPropertyGrid";
|
||||
this.OpeningPropertyGrid.Size = new System.Drawing.Size(254, 232);
|
||||
this.OpeningPropertyGrid.TabIndex = 4;
|
||||
//
|
||||
// OKButton
|
||||
//
|
||||
this.OKButton.DialogResult = System.Windows.Forms.DialogResult.Cancel;
|
||||
this.OKButton.Location = new System.Drawing.Point(484, 308);
|
||||
this.OKButton.Name = "OKButton";
|
||||
this.OKButton.Size = new System.Drawing.Size(75, 23);
|
||||
this.OKButton.TabIndex = 1;
|
||||
this.OKButton.Text = "&OK";
|
||||
this.OKButton.UseVisualStyleBackColor = true;
|
||||
this.OKButton.Click += new System.EventHandler(this.OKButton_Click);
|
||||
//
|
||||
// OpeningListComboBox
|
||||
//
|
||||
this.OpeningListComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.OpeningListComboBox.FormattingEnabled = true;
|
||||
this.OpeningListComboBox.Location = new System.Drawing.Point(304, 38);
|
||||
this.OpeningListComboBox.Name = "OpeningListComboBox";
|
||||
this.OpeningListComboBox.Size = new System.Drawing.Size(254, 21);
|
||||
this.OpeningListComboBox.TabIndex = 3;
|
||||
this.OpeningListComboBox.SelectedIndexChanged += new System.EventHandler(this.OpeningListComboBox_SelectedIndexChanged);
|
||||
//
|
||||
// label1
|
||||
//
|
||||
this.label1.AutoSize = true;
|
||||
this.label1.Location = new System.Drawing.Point(305, 12);
|
||||
this.label1.Name = "label1";
|
||||
this.label1.Size = new System.Drawing.Size(55, 13);
|
||||
this.label1.TabIndex = 5;
|
||||
this.label1.Text = "Openings:";
|
||||
//
|
||||
// OpeningForm
|
||||
//
|
||||
this.AcceptButton = this.Createbutton;
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.CancelButton = this.OKButton;
|
||||
this.ClientSize = new System.Drawing.Size(570, 340);
|
||||
this.Controls.Add(this.label1);
|
||||
this.Controls.Add(this.OpeningListComboBox);
|
||||
this.Controls.Add(this.OKButton);
|
||||
this.Controls.Add(this.OpeningPropertyGrid);
|
||||
this.Controls.Add(this.Createbutton);
|
||||
this.Controls.Add(this.PreviewPictureBox);
|
||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
|
||||
this.MaximizeBox = false;
|
||||
this.MinimizeBox = false;
|
||||
this.Name = "OpeningForm";
|
||||
this.ShowIcon = false;
|
||||
this.ShowInTaskbar = false;
|
||||
this.Text = "All openings";
|
||||
this.Load += new System.EventHandler(this.OpeningForm_Load);
|
||||
((System.ComponentModel.ISupportInitialize)(this.PreviewPictureBox)).EndInit();
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.PictureBox PreviewPictureBox;
|
||||
private System.Windows.Forms.Button Createbutton;
|
||||
private System.Windows.Forms.PropertyGrid OpeningPropertyGrid;
|
||||
private System.Windows.Forms.Button OKButton;
|
||||
private System.Windows.Forms.ComboBox OpeningListComboBox;
|
||||
private System.Windows.Forms.Label label1;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,117 @@
|
||||
//
|
||||
// (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.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace Revit.SDK.Samples.Openings.CS
|
||||
{
|
||||
/// <summary>
|
||||
/// Main form use to show the selected opening.
|
||||
/// </summary>
|
||||
public partial class OpeningForm : System.Windows.Forms.Form
|
||||
{
|
||||
//constructor
|
||||
/// <summary>
|
||||
/// The default constructor
|
||||
/// </summary>
|
||||
public OpeningForm()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// constructor of OpeningForm
|
||||
/// </summary>
|
||||
/// <param name="openingInfos">a list of OpeningInFo</param>
|
||||
public OpeningForm(List<OpeningInfo> openingInfos)
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
m_openingInfos = openingInfos;
|
||||
}
|
||||
|
||||
//private member
|
||||
private readonly List<OpeningInfo> m_openingInfos; //store all the OpeningInfo class
|
||||
private OpeningInfo m_selectedOpeningInfo; //current displayed (in preview) OpeningInfo
|
||||
|
||||
private void OpeningForm_Load(object sender, EventArgs e)
|
||||
{
|
||||
this.OpeningListComboBox.DataSource = m_openingInfos;
|
||||
this.OpeningListComboBox.DisplayMember = "NameAndId";
|
||||
|
||||
m_selectedOpeningInfo = (OpeningInfo)this.OpeningListComboBox.SelectedItem;
|
||||
this.OpeningPropertyGrid.SelectedObject = m_selectedOpeningInfo.Property;
|
||||
}
|
||||
|
||||
private void PreviewPictureBox_Paint(object sender, PaintEventArgs e)
|
||||
{
|
||||
int width = this.PreviewPictureBox.Width;
|
||||
int height = this.PreviewPictureBox.Height;
|
||||
if (m_selectedOpeningInfo.Sketch != null)
|
||||
{
|
||||
m_selectedOpeningInfo.Sketch.Draw2D(width,
|
||||
height, e.Graphics);
|
||||
}
|
||||
else
|
||||
{
|
||||
//if profile is a circle (or ellipse), can not get curve from API
|
||||
//so draw an Arc according to boundingBox of the Opening
|
||||
double widthBoundBox = m_selectedOpeningInfo.BoundingBox.Width;
|
||||
double lengthBoundBox = m_selectedOpeningInfo.BoundingBox.Length;
|
||||
double scale = height * 0.8 / lengthBoundBox;
|
||||
e.Graphics.Clear(System.Drawing.Color.Black);
|
||||
Pen yellowPen = new Pen(System.Drawing.Color.Yellow, 1);
|
||||
Rectangle rect = new Rectangle((int)(width / 2 - widthBoundBox * scale / 2),
|
||||
(int)(height / 2 - lengthBoundBox * scale / 2), (int)(widthBoundBox * scale),
|
||||
(int)(lengthBoundBox * scale));
|
||||
// Draw circle to screen.
|
||||
e.Graphics.DrawArc(yellowPen, rect, 0, 360);
|
||||
}
|
||||
}
|
||||
|
||||
private void Createbutton_Click(object sender, EventArgs e)
|
||||
{
|
||||
CreateModelLineOptionsForm optionForm =
|
||||
new CreateModelLineOptionsForm(m_openingInfos, m_selectedOpeningInfo);
|
||||
optionForm.ShowDialog();
|
||||
}
|
||||
|
||||
private void OpeningListComboBox_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
m_selectedOpeningInfo = (OpeningInfo)this.OpeningListComboBox.SelectedItem;
|
||||
this.OpeningPropertyGrid.SelectedObject = m_selectedOpeningInfo.Property;
|
||||
this.PreviewPictureBox.Refresh();
|
||||
}
|
||||
|
||||
private void OKButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
this.Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
||||
@@ -0,0 +1,276 @@
|
||||
//
|
||||
// (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;
|
||||
using Autodesk.Revit.UI;
|
||||
using Autodesk.Revit.ApplicationServices;
|
||||
using System.Drawing;
|
||||
using Autodesk.Revit;
|
||||
using System.Collections.ObjectModel;
|
||||
|
||||
namespace Revit.SDK.Samples.Openings.CS
|
||||
{
|
||||
/// <summary>
|
||||
/// This class contain the data about the Opening (get from Revit)
|
||||
/// Such as BoundingBox, Profile Curve...
|
||||
/// </summary>
|
||||
public class OpeningInfo
|
||||
{
|
||||
private UIApplication m_revit; //Application of Revit
|
||||
private List<Line3D> m_lines = new List<Line3D>(); //contains lines in curve
|
||||
private Opening m_opening; //Opening got from Revit
|
||||
|
||||
//OpeningProperty class which can use in PropertyGrid control
|
||||
private OpeningProperty m_property;
|
||||
private WireFrame m_sketch; //Profile information of opening
|
||||
private BoundingBox m_boundingBox; //BoundingBox of Opening
|
||||
|
||||
//property
|
||||
/// <summary>
|
||||
/// Property to get and set Application of Revit
|
||||
/// </summary>
|
||||
public UIApplication Revit
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_revit;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value != m_revit)
|
||||
m_revit = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Property to get Opening store in OpeningInfo
|
||||
/// </summary>
|
||||
public Opening Opening
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_opening;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Property to get Name and Id
|
||||
/// eg: "Opening Cut (114389)"
|
||||
/// </summary>
|
||||
public string NameAndId
|
||||
{
|
||||
get
|
||||
{
|
||||
return String.Concat(m_opening.Name, " (", m_opening.Id.IntegerValue.ToString(), ")");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Property to get bool the define whether opening is Shaft Opening
|
||||
/// </summary>
|
||||
public bool IsShaft
|
||||
{
|
||||
get
|
||||
{
|
||||
if (null != m_opening.Category)
|
||||
{
|
||||
if ("Shaft Openings" == m_opening.Category.Name)
|
||||
return true;
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Property to get OpeningProperty class
|
||||
/// which can use in PropertyGrid control
|
||||
/// </summary>
|
||||
public OpeningProperty Property
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_property;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Property to get Profile information of opening
|
||||
/// </summary>
|
||||
public WireFrame Sketch
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_sketch;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Property to get BoundingBox of Opening
|
||||
/// </summary>
|
||||
public BoundingBox BoundingBox
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_boundingBox;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The default constructor,
|
||||
/// get the information we want from Opening
|
||||
/// get OpeningProperty, BoundingBox and Profile
|
||||
/// </summary>
|
||||
/// <param name="opening">an opening in revit</param>
|
||||
/// <param name="app">application object</param>
|
||||
public OpeningInfo(Opening opening, UIApplication app)
|
||||
{
|
||||
m_opening = opening;
|
||||
m_revit = app;
|
||||
|
||||
//get OpeningProperty which can use in PropertyGrid control
|
||||
OpeningProperty openingProperty = new OpeningProperty(m_opening);
|
||||
m_property = openingProperty;
|
||||
|
||||
//get BoundingBox of Opening
|
||||
BoundingBoxXYZ boxXYZ = m_opening.get_BoundingBox(m_revit.ActiveUIDocument.Document.ActiveView);
|
||||
BoundingBox boundingBox = new BoundingBox(boxXYZ);
|
||||
m_boundingBox = boundingBox;
|
||||
|
||||
//get profile
|
||||
GetProfile();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// get Profile of Opening
|
||||
/// </summary>
|
||||
private void GetProfile()
|
||||
{
|
||||
CurveArray curveArray = m_opening.BoundaryCurves;
|
||||
if (null != curveArray)
|
||||
{
|
||||
m_lines.Clear();
|
||||
foreach (Curve curve in curveArray)
|
||||
{
|
||||
List<XYZ> points = curve.Tessellate() as List<XYZ>;
|
||||
AddLine(points);
|
||||
}
|
||||
WireFrame wireFrameSketch = new WireFrame(new ReadOnlyCollection<Line3D>(m_lines));
|
||||
m_sketch = wireFrameSketch;
|
||||
}
|
||||
else if (m_opening.IsRectBoundary)
|
||||
{
|
||||
//if opening profile is RectBoundary,
|
||||
//just can get profile info from BoundaryRect Property
|
||||
m_lines.Clear();
|
||||
List<XYZ> boundRect = m_opening.BoundaryRect as List<XYZ>;
|
||||
List<XYZ> RectPoints = GetPoints(boundRect);
|
||||
AddLine(RectPoints);
|
||||
WireFrame wireFrameSketch = new WireFrame(new ReadOnlyCollection<Line3D>(m_lines));
|
||||
m_sketch = wireFrameSketch;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_sketch = null;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// get four corner points of a rectangular in same plane
|
||||
/// </summary>
|
||||
/// <param name="boundRect">an array contain two Autodesk.Revit.DB.XYZ struct store the max and min
|
||||
/// coordinate of rectangular</param>
|
||||
private List<XYZ> GetPoints(List<XYZ> boundRect)
|
||||
{
|
||||
List<XYZ> points = new List<XYZ>();
|
||||
Autodesk.Revit.DB.XYZ p1 = boundRect[0];
|
||||
points.Add(p1);
|
||||
|
||||
Autodesk.Revit.DB.XYZ p2 = new Autodesk.Revit.DB.XYZ(
|
||||
boundRect[0].X,
|
||||
boundRect[0].Y,
|
||||
boundRect[1].Z);
|
||||
points.Add(p2);
|
||||
|
||||
Autodesk.Revit.DB.XYZ p3 = boundRect[1];
|
||||
points.Add(p3);
|
||||
|
||||
Autodesk.Revit.DB.XYZ p4 = new Autodesk.Revit.DB.XYZ (
|
||||
boundRect[1].X,
|
||||
boundRect[1].Y,
|
||||
boundRect[0].Z);
|
||||
points.Add(p4);
|
||||
|
||||
//make rectangle close
|
||||
Autodesk.Revit.DB.XYZ p5 = boundRect[0];
|
||||
points.Add(p5);
|
||||
|
||||
return points;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// get line from List<XYZ>(points) and add line to m_lines list
|
||||
/// </summary>
|
||||
/// <param name="points">a List<XYZ> contain points of the Curve</param>
|
||||
private void AddLine(List<XYZ> points)
|
||||
{
|
||||
if (null == points || 0 == points.Count)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Autodesk.Revit.DB.XYZ previousPoint;
|
||||
previousPoint = points[0];
|
||||
|
||||
for (int i = 1; i < points.Count; i++)
|
||||
{
|
||||
Autodesk.Revit.DB.XYZ point;
|
||||
point = points[i];
|
||||
|
||||
Line3D line = new Line3D();
|
||||
Vector pointStart = new Vector();
|
||||
Vector pointEnd = new Vector();
|
||||
for (int j = 0; j < 3; j++)
|
||||
{
|
||||
pointStart[j] = previousPoint[j];
|
||||
pointEnd[j] = point[j];
|
||||
}
|
||||
line.StartPoint = pointStart;
|
||||
line.EndPoint = pointEnd;
|
||||
|
||||
m_lines.Add(line);
|
||||
|
||||
previousPoint = point;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,138 @@
|
||||
//
|
||||
// (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.DB;
|
||||
|
||||
namespace Revit.SDK.Samples.Openings.CS
|
||||
{
|
||||
/// <summary>
|
||||
/// This class use to create a object can use by PropertyGrid control
|
||||
/// </summary>
|
||||
public class OpeningProperty
|
||||
{
|
||||
private string m_name = "Opening"; //name of opening
|
||||
private string m_elementId = ""; //Element Id of Opening
|
||||
private string m_hostElementId = ""; // Element Id of Opening,'s host
|
||||
private string m_hostName = "Null"; //Name of host
|
||||
private bool m_isShaft; //whether Opening is Shaft Opening
|
||||
|
||||
/// <summary>
|
||||
/// The default constructor
|
||||
/// </summary>
|
||||
/// <param name="opening">Opening in Revit</param>
|
||||
public OpeningProperty(Opening opening)
|
||||
{
|
||||
if (null == opening)
|
||||
{
|
||||
throw new ArgumentNullException();
|
||||
}
|
||||
|
||||
//get parameters which need to show
|
||||
m_name = opening.Name;
|
||||
m_elementId = opening.Id.IntegerValue.ToString();
|
||||
|
||||
if (null != opening.Host)
|
||||
{
|
||||
if (null != opening.Host.Category)
|
||||
m_hostName = opening.Host.Category.Name;
|
||||
|
||||
m_hostElementId = opening.Host.Id.IntegerValue.ToString();
|
||||
}
|
||||
|
||||
if (null != opening.Category)
|
||||
{
|
||||
if ("Shaft Openings" == opening.Category.Name)
|
||||
m_isShaft = true;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// name
|
||||
/// </summary>
|
||||
[Description("Name of current diaplayed Opening"),
|
||||
Category("Opening Name"),]
|
||||
public string Name
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_name;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///element id
|
||||
/// </summary>
|
||||
[Description("ElementId of current diaplayed Opening"),
|
||||
Category("Opening Property"),]
|
||||
public string ElementID
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_elementId;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// host name
|
||||
/// </summary>
|
||||
[Description("Name of the Host which contains Current displayed Opening"),
|
||||
CategoryAttribute("Opening Property"),]
|
||||
public string HostName
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_hostName;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// host elements id
|
||||
/// </summary>
|
||||
[Description("ElementId of Host"),
|
||||
CategoryAttribute("Opening Property"),]
|
||||
public string HostElementID
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_hostElementId;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// shaft opening
|
||||
/// </summary>
|
||||
[Description("whether displayed openging is Shaft Opening"),
|
||||
CategoryAttribute("Opening Property"),]
|
||||
public bool ShaftOpening
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_isShaft;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RevitAddIns>
|
||||
<AddIn Type="Command">
|
||||
<Assembly>Openings.dll</Assembly>
|
||||
<ClientId>de05fe52-13ed-4cdb-9c84-62e5eee3ac08</ClientId>
|
||||
<FullClassName>Revit.SDK.Samples.Openings.CS.Command</FullClassName>
|
||||
<Text>Openings</Text>
|
||||
<Description>Display openings in project, and create model lines along its edges.</Description>
|
||||
<VisibilityMode>AlwaysVisible</VisibilityMode>
|
||||
<VendorId>ADSK</VendorId>
|
||||
<VendorDescription>Autodesk, www.autodesk.com</VendorDescription>
|
||||
</AddIn>
|
||||
</RevitAddIns>
|
||||
@@ -0,0 +1,127 @@
|
||||
<?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>{C7A272AF-69E5-4E22-9CF7-5E49E67ABDB4}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>Openings</RootNamespace>
|
||||
<AssemblyName>Openings</AssemblyName>
|
||||
<SccProjectName>
|
||||
</SccProjectName>
|
||||
<SccLocalPath>
|
||||
</SccLocalPath>
|
||||
<SccAuxPath>
|
||||
</SccAuxPath>
|
||||
<SccProvider>
|
||||
</SccProvider>
|
||||
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
|
||||
<TargetFrameworkProfile />
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<CodeAnalysisRules>-Microsoft.Globalization#CA1301;-Microsoft.Globalization#CA1302;-Microsoft.Globalization#CA1303;-Microsoft.Globalization#CA1306;-Microsoft.Globalization#CA1304;-Microsoft.Globalization#CA1305;-Microsoft.Globalization#CA1300;-Microsoft.Interoperability#CA1403;-Microsoft.Interoperability#CA1406;-Microsoft.Interoperability#CA1413;-Microsoft.Interoperability#CA1402;-Microsoft.Interoperability#CA1407;-Microsoft.Interoperability#CA1404;-Microsoft.Interoperability#CA1410;-Microsoft.Interoperability#CA1411;-Microsoft.Interoperability#CA1405;-Microsoft.Interoperability#CA1409;-Microsoft.Interoperability#CA1415;-Microsoft.Interoperability#CA1408;-Microsoft.Interoperability#CA1414;-Microsoft.Interoperability#CA1412;-Microsoft.Interoperability#CA1400;-Microsoft.Interoperability#CA1401;-Microsoft.Mobility#CA1600;-Microsoft.Mobility#CA1601;-Microsoft.Portability#CA1901;-Microsoft.Portability#CA1900</CodeAnalysisRules>
|
||||
<RunCodeAnalysis>false</RunCodeAnalysis>
|
||||
</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>
|
||||
<CodeAnalysisRules>-Microsoft.Globalization#CA1301;-Microsoft.Globalization#CA1302;-Microsoft.Globalization#CA1303;-Microsoft.Globalization#CA1306;-Microsoft.Globalization#CA1304;-Microsoft.Globalization#CA1305;-Microsoft.Globalization#CA1300;-Microsoft.Interoperability#CA1403;-Microsoft.Interoperability#CA1406;-Microsoft.Interoperability#CA1413;-Microsoft.Interoperability#CA1402;-Microsoft.Interoperability#CA1407;-Microsoft.Interoperability#CA1404;-Microsoft.Interoperability#CA1410;-Microsoft.Interoperability#CA1411;-Microsoft.Interoperability#CA1405;-Microsoft.Interoperability#CA1409;-Microsoft.Interoperability#CA1415;-Microsoft.Interoperability#CA1408;-Microsoft.Interoperability#CA1414;-Microsoft.Interoperability#CA1412;-Microsoft.Interoperability#CA1400;-Microsoft.Interoperability#CA1401;-Microsoft.Mobility#CA1600;-Microsoft.Mobility#CA1601;-Microsoft.Portability#CA1901;-Microsoft.Portability#CA1900</CodeAnalysisRules>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
</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="BoundingBox.cs" />
|
||||
<Compile Include="Command.cs" />
|
||||
<Compile Include="CreateModelLineOptionsForm.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="CreateModelLineOptionsForm.Designer.cs">
|
||||
<DependentUpon>CreateModelLineOptionsForm.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Line2D.cs" />
|
||||
<Compile Include="Line3D.cs" />
|
||||
<Compile Include="LineSketch.cs" />
|
||||
<Compile Include="ObjectSketch.cs" />
|
||||
<Compile Include="OpeningForm.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="OpeningForm.Designer.cs">
|
||||
<DependentUpon>OpeningForm.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="OpeningInfo.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="OpeningProperty.cs" />
|
||||
<Compile Include="UCS.cs" />
|
||||
<Compile Include="Vector.cs" />
|
||||
<Compile Include="WireFrame.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="CreateModelLineOptionsForm.resx">
|
||||
<SubType>Designer</SubType>
|
||||
<DependentUpon>CreateModelLineOptionsForm.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="OpeningForm.resx">
|
||||
<SubType>Designer</SubType>
|
||||
<DependentUpon>OpeningForm.cs</DependentUpon>
|
||||
</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,58 @@
|
||||
//
|
||||
// (C) Copyright 2003-2019 by Autodesk, Inc.
|
||||
//
|
||||
// Permission to use, copy, modify, and distribute this software in
|
||||
// object code form for any purpose and without fee is hereby granted,
|
||||
// provided that the above copyright notice appears in all copies and
|
||||
// that both that copyright notice and the limited warranty and
|
||||
// restricted rights notice below appear in all supporting
|
||||
// documentation.
|
||||
//
|
||||
// AUTODESK PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS.
|
||||
// AUTODESK SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF
|
||||
// MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE. AUTODESK, INC.
|
||||
// DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE
|
||||
// UNINTERRUPTED OR ERROR FREE.
|
||||
//
|
||||
// Use, duplication, or disclosure by the U.S. Government is subject to
|
||||
// restrictions set forth in FAR 52.227-19 (Commercial Computer
|
||||
// Software - Restricted Rights) and DFAR 252.227-7013(c)(1)(ii)
|
||||
// (Rights in Technical Data and Computer Software), as applicable.
|
||||
//
|
||||
|
||||
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("Opening")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("Opening")]
|
||||
[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("a18e9780-4e43-4163-87cd-f534d8df3398")]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Revision and Build Numbers
|
||||
// by using the '*' as shown below:
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
Binary file not shown.
@@ -0,0 +1,162 @@
|
||||
//
|
||||
// (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;
|
||||
|
||||
namespace Revit.SDK.Samples.Openings.CS
|
||||
{
|
||||
/// <summary>
|
||||
/// This class stand for user coordinate system
|
||||
/// </summary>
|
||||
public class UCS
|
||||
{
|
||||
Vector m_origin = new Vector(0.0, 0.0, 0.0);
|
||||
Vector m_xAxis = new Vector(1.0, 0.0, 0.0);
|
||||
Vector m_yAxis = new Vector(0.0, 1.0, 0.0);
|
||||
Vector m_zAxis = new Vector(0.0, 0.0, 1.0);
|
||||
|
||||
/// <summary>
|
||||
/// Property to get origin of user coordinate system
|
||||
/// </summary>
|
||||
public Vector Origin
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_origin;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Property to get X Axis of user coordinate system
|
||||
/// </summary>
|
||||
public Vector XAxis
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_xAxis;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Property to get Y Axis of user coordinate system
|
||||
/// </summary>
|
||||
public Vector YAxis
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_yAxis;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Property to get Z Axis of user coordinate system
|
||||
/// </summary>
|
||||
public Vector ZAxis
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_zAxis;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The default constructor,
|
||||
/// </summary>
|
||||
public UCS(Vector origin, Vector xAxis, Vector yAxis)
|
||||
: this(origin, xAxis, yAxis, true)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// constructor,
|
||||
/// get a user coordinate system
|
||||
/// </summary>
|
||||
/// <param name="origin">origin of user coordinate system</param>
|
||||
/// <param name="xAxis">xAxis of user coordinate system</param>
|
||||
/// <param name="yAxis">yAxis of user coordinate system</param>
|
||||
/// <param name="flag">select left handness or right handness</param>
|
||||
public UCS(Vector origin, Vector xAxis, Vector yAxis, bool flag)
|
||||
{
|
||||
Vector x2 = xAxis / ~xAxis;
|
||||
Vector y2 = yAxis / ~yAxis;
|
||||
Vector z2 = x2 & y2;
|
||||
if (~z2 < double.Epsilon)
|
||||
{
|
||||
throw new InvalidOperationException();
|
||||
}
|
||||
|
||||
if (!flag)
|
||||
{
|
||||
z2 = -z2;
|
||||
}
|
||||
|
||||
m_origin = origin;
|
||||
m_xAxis = x2;
|
||||
m_yAxis = y2;
|
||||
m_zAxis = z2;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Transform local coordinate to global coordinate
|
||||
/// </summary>
|
||||
/// <param name="arg">a vector which need to transform</param>
|
||||
public Vector LC2GC(Vector arg)
|
||||
{
|
||||
Vector result = new Vector();
|
||||
result.X =
|
||||
arg.X * m_xAxis.X + arg.Y * m_yAxis.X + arg.Z * m_zAxis.X + m_origin.X;
|
||||
result.Y =
|
||||
arg.X * m_xAxis.Y + arg.Y * m_yAxis.Y + arg.Z * m_zAxis.Y + m_origin.Y;
|
||||
result.Z =
|
||||
arg.X * m_xAxis.Z + arg.Y * m_yAxis.Z + arg.Z * m_zAxis.Z + m_origin.Z;
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Transform global coordinate to local coordinate
|
||||
/// </summary>
|
||||
/// <param name="line">a line which need to transform</param>
|
||||
public Line3D GC2LC(Line3D line)
|
||||
{
|
||||
Vector startPnt = GC2LC(line.StartPoint);
|
||||
Vector endPnt = GC2LC(line.EndPoint);
|
||||
return new Line3D(startPnt, endPnt);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Transform global coordinate to local coordinate
|
||||
/// </summary>
|
||||
/// <param name="arg">a vector which need to transform</param>
|
||||
public Vector GC2LC(Vector arg)
|
||||
{
|
||||
Vector result = new Vector();
|
||||
arg = arg - m_origin;
|
||||
result.X = m_xAxis * arg;
|
||||
result.Y = m_yAxis * arg;
|
||||
result.Z = m_zAxis * arg;
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,370 @@
|
||||
//
|
||||
// (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;
|
||||
|
||||
namespace Revit.SDK.Samples.Openings.CS
|
||||
{
|
||||
/// <summary>
|
||||
/// Point class use to store point coordinate value
|
||||
/// and get the value via (x, y ,z)property
|
||||
/// </summary>
|
||||
public struct Vector
|
||||
{
|
||||
/// <summary>
|
||||
/// x coordinate of vector
|
||||
/// </summary>
|
||||
private double m_x;
|
||||
|
||||
/// <summary>
|
||||
/// y coordinate of vector
|
||||
/// </summary>
|
||||
private double m_y;
|
||||
|
||||
/// <summary>
|
||||
/// z coordinate of vector
|
||||
/// </summary>
|
||||
private double m_z;
|
||||
|
||||
/// <summary>
|
||||
/// Property to get X coordinate
|
||||
/// </summary>
|
||||
public double X
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_x;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_x = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Property to get Y coordinate
|
||||
/// </summary>
|
||||
public double Y
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_y;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_y = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Property to get Z coordinate
|
||||
/// </summary>
|
||||
public double Z
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_z;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_z = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Property to get x, y, z coordinate bu index 1, 2, 3
|
||||
/// </summary>
|
||||
public double this[int index]
|
||||
{
|
||||
get
|
||||
{
|
||||
switch (index)
|
||||
{
|
||||
case 0:
|
||||
return m_x;
|
||||
case 1:
|
||||
return m_y;
|
||||
case 2:
|
||||
return m_z;
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException();
|
||||
}
|
||||
}
|
||||
set
|
||||
{
|
||||
switch (index)
|
||||
{
|
||||
case 0:
|
||||
m_x = value;
|
||||
break;
|
||||
case 1:
|
||||
m_y = value;
|
||||
break;
|
||||
case 2:
|
||||
m_z = value;
|
||||
break;
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// copy constructor
|
||||
/// </summary>
|
||||
public Vector(Vector rhs)
|
||||
{
|
||||
m_x = rhs.X;
|
||||
m_y = rhs.Y;
|
||||
m_z = rhs.Z;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// constructor
|
||||
/// </summary>
|
||||
/// <param name="x">x coordinate of point</param>
|
||||
/// <param name="y">y coordinate of point</param>
|
||||
/// <param name="z">z coordinate of point</param>
|
||||
public Vector(double x, double y, double z)
|
||||
{
|
||||
m_x = x;
|
||||
m_y = y;
|
||||
m_z = z;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// get Normal by vector
|
||||
/// </summary>
|
||||
public Vector GetNormal()
|
||||
{
|
||||
Vector direct = new Vector();
|
||||
double len = GetLength();
|
||||
direct.X = m_x / len;
|
||||
direct.Y = m_y / len;
|
||||
direct.Z = m_z / len;
|
||||
return direct;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// add two vector
|
||||
/// </summary>
|
||||
/// <param name="lhs">first vector</param>
|
||||
/// <param name="rhs">second vector</param>
|
||||
/// <returns>add two vector</returns>
|
||||
public static Vector operator +(Vector lhs, Vector rhs)
|
||||
{
|
||||
Vector result = new Vector(lhs);
|
||||
result.X += rhs.X;
|
||||
result.Y += rhs.Y;
|
||||
result.Z += rhs.Z;
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// subtraction of two vector
|
||||
/// </summary>
|
||||
/// <param name="lhs">first vector</param>
|
||||
/// <param name="rhs">second vector</param>
|
||||
/// <returns>subtraction of two vector</returns>
|
||||
public static Vector operator -(Vector lhs, Vector rhs)
|
||||
{
|
||||
Vector result = new Vector(lhs);
|
||||
result.X -= rhs.X;
|
||||
result.Y -= rhs.Y;
|
||||
result.Z -= rhs.Z;
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// negative of vector
|
||||
/// </summary>
|
||||
/// <param name="lhs">vector</param>
|
||||
/// <returns>negative of vector</returns>
|
||||
public static Vector operator -(Vector lhs)
|
||||
{
|
||||
Vector result = new Vector(lhs);
|
||||
result.X = -lhs.X;
|
||||
result.Y = -lhs.Y;
|
||||
result.Z = -lhs.Z;
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// get normal vector of two vector
|
||||
/// </summary>
|
||||
/// <param name="lhs">first vector</param>
|
||||
/// <param name="rhs">second vector</param>
|
||||
/// <returns> normal vector of two vector</returns>
|
||||
public static Vector operator &(Vector lhs, Vector rhs)
|
||||
{
|
||||
double v1 = lhs.X;
|
||||
double v2 = lhs.Y;
|
||||
double v3 = lhs.Z;
|
||||
|
||||
double u1 = rhs.X;
|
||||
double u2 = rhs.Y;
|
||||
double u3 = rhs.Z;
|
||||
|
||||
double x = v2 * u3 - v3 * u2;
|
||||
double y = v3 * u1 - v1 * u3;
|
||||
double z = v1 * u2 - v2 * u1;
|
||||
|
||||
return new Vector(x, y, z);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// get cross vector of two vector
|
||||
/// </summary>
|
||||
/// <param name="lhs">first vector</param>
|
||||
/// <param name="rhs">second vector</param>
|
||||
/// <returns> cross vector of two vector</returns>
|
||||
public static double operator *(Vector lhs, Vector rhs)
|
||||
{
|
||||
return lhs.X * rhs.X + lhs.Y * rhs.Y + lhs.Z * rhs.Z;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// get vector multiply by an double value
|
||||
/// </summary>
|
||||
/// <param name="lhs">vector</param>
|
||||
/// <param name="rhs">double value</param>
|
||||
/// <returns> vector multiply by an double value</returns>
|
||||
public static Vector operator *(Vector lhs, double rhs)
|
||||
{
|
||||
return new Vector(lhs.X * rhs, lhs.Y * rhs, lhs.Z * rhs);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// estimate whether two are unequal
|
||||
/// </summary>
|
||||
/// <param name="lhs">first vector</param>
|
||||
/// <param name="rhs">second vector</param>
|
||||
/// <returns> whether two are unequal</returns>
|
||||
public static bool operator !=(Vector lhs, Vector rhs)
|
||||
{
|
||||
return !IsEqual(lhs, rhs);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// estimate whether two are equal
|
||||
/// </summary>
|
||||
/// <param name="lhs">first vector</param>
|
||||
/// <param name="rhs">second vector</param>
|
||||
/// <returns> whether two are equal</returns>
|
||||
public static bool operator ==(Vector lhs, Vector rhs)
|
||||
{
|
||||
return IsEqual(lhs, rhs);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// get the length of vector
|
||||
/// </summary>
|
||||
/// <param name="lhs">vector</param>
|
||||
/// <returns>length of vector</returns>
|
||||
public static double operator ~(Vector lhs)
|
||||
{
|
||||
return lhs.GetLength();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// get vector divided by an double value
|
||||
/// </summary>
|
||||
/// <param name="lhs">vector</param>
|
||||
/// <param name="rhs">double value</param>
|
||||
/// <returns> vector divided by an double value</returns>
|
||||
public static Vector operator /(Vector lhs, double rhs)
|
||||
{
|
||||
return new Vector(lhs.m_x / rhs, lhs.m_y / rhs, lhs.m_z / rhs);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// get angle of two vector
|
||||
/// </summary>
|
||||
/// <param name="lhs">first vector</param>
|
||||
/// <param name="rhs">second vector</param>
|
||||
/// <returns> angle of two vector</returns>
|
||||
public static double GetAngleOf2Vectors(Vector lhs, Vector rhs, bool acuteAngleDesired)
|
||||
{
|
||||
double angle = Math.Acos(lhs.GetNormal() * rhs.GetNormal());
|
||||
if (acuteAngleDesired && angle > Math.PI / 2)
|
||||
{
|
||||
angle = Math.PI - angle;
|
||||
}
|
||||
return angle;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// estimate whether two are equal
|
||||
/// </summary>
|
||||
/// <param name="obj">object which compare with</param>
|
||||
/// <returns> whether two are equal</returns>
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
try
|
||||
{
|
||||
Vector rhs = (Vector)obj;
|
||||
return IsEqual(this, rhs);
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get HashCode
|
||||
/// </summary>
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return m_x.GetHashCode() ^ m_y.GetHashCode() ^ m_z.GetHashCode();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get Length of vector
|
||||
/// </summary>
|
||||
public double GetLength()
|
||||
{
|
||||
return Math.Sqrt(m_x*m_x + m_y*m_y + m_z*m_z);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// estimate whether two vector are equal
|
||||
/// </summary>
|
||||
/// <param name="lhs">first vector</param>
|
||||
/// <param name="rhs">second vector</param>
|
||||
/// <returns> whether two are equal</returns>
|
||||
private static bool IsEqual(Vector lhs, Vector rhs)
|
||||
{
|
||||
if (lhs.X == rhs.X && lhs.X == rhs.X && lhs.X == rhs.X)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,194 @@
|
||||
//
|
||||
// (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.Collections;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Drawing2D;
|
||||
using System.Collections.ObjectModel;
|
||||
|
||||
namespace Revit.SDK.Samples.Openings.CS
|
||||
{
|
||||
/// <summary>
|
||||
/// WireFrame class for generate the model lines and fit the picture box's size to display
|
||||
/// </summary>
|
||||
public class WireFrame : ObjectSketch
|
||||
{
|
||||
/// <summary>
|
||||
/// ratio of margin to canvas width
|
||||
/// </summary>
|
||||
private const float MARGINRATIO = 0.1f;
|
||||
|
||||
//construct function
|
||||
/// <summary>
|
||||
/// The default constructor
|
||||
/// </summary>
|
||||
/// <param name="line3Ds">a list contain all the line in WireFrame</param>
|
||||
public WireFrame(ReadOnlyCollection<Line3D> line3Ds)
|
||||
{
|
||||
Frame3DTo2D(line3Ds);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// draw the line contain in m_lines in 2d Preview
|
||||
/// </summary>
|
||||
/// <param name="previewWidth">Width of Preview</param>
|
||||
/// <param name="previewHeigh">Heigh of Preview</param>
|
||||
/// /// <param name="graphics">Graphics to draw</param>
|
||||
/// <returns></returns>
|
||||
public void Draw2D(float previewWidth, float previewHeigh, Graphics graphics)
|
||||
{
|
||||
graphics.Clear(System.Drawing.Color.Black);
|
||||
CalculateTransform(previewWidth, previewHeigh);
|
||||
foreach (ObjectSketch sketch in m_objects)
|
||||
{
|
||||
sketch.Draw(graphics, m_transform);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// draw override method
|
||||
/// </summary>
|
||||
/// <param name="g">graphics object</param>
|
||||
/// <param name="translate">matrix use to transform points or vectors</param>
|
||||
public override void Draw(Graphics g, Matrix translate)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// calculate the transform between canvas and geometry objects
|
||||
/// </summary>
|
||||
private void CalculateTransform(float previewWidth, float previewHeigh)
|
||||
{
|
||||
PointF[] plgpts = CalculateCanvasRegion(previewWidth, previewHeigh);
|
||||
m_transform = new Matrix(BoundingBox, plgpts);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// get the display region, adjust the proportion and location
|
||||
/// </summary>
|
||||
/// <returns>upper-left, upper-right, and lower-left corners of the rectangle </returns>
|
||||
private PointF[] CalculateCanvasRegion(float previewWidth, float previewHeigh)
|
||||
{
|
||||
// get the area without margin
|
||||
float realWidth = previewWidth * (1 - 2 * MARGINRATIO);
|
||||
float realHeight = previewHeigh * (1 - 2 * MARGINRATIO);
|
||||
float minX = previewWidth * MARGINRATIO;
|
||||
float minY = previewHeigh * MARGINRATIO;
|
||||
// ratio of width to height
|
||||
float originRate = m_boundingBox.Width / m_boundingBox.Height;
|
||||
float displayRate = realWidth / realHeight;
|
||||
|
||||
if (originRate > displayRate)
|
||||
{
|
||||
// display area in canvas need move to center in height
|
||||
float goalHeight = realWidth / originRate;
|
||||
minY = minY + (realHeight - goalHeight) / 2;
|
||||
realHeight = goalHeight;
|
||||
}
|
||||
else
|
||||
{
|
||||
// display area in canvas need move to center in width
|
||||
float goalWidth = realHeight * originRate;
|
||||
minX = minX + (realWidth - goalWidth) / 2;
|
||||
realWidth = goalWidth;
|
||||
}
|
||||
|
||||
PointF[] plgpts = new PointF[3];
|
||||
plgpts[0] = new PointF(minX, realHeight + minY); // upper-left point
|
||||
plgpts[1] = new PointF(realWidth + minX, realHeight + minY); // upper-right point
|
||||
plgpts[2] = new PointF(minX, minY); // lower-left point
|
||||
|
||||
return plgpts;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// transform 3d point to 2d (if all points in the same plane)
|
||||
/// </summary>
|
||||
private void Frame3DTo2D(ReadOnlyCollection<Line3D> line3Ds)
|
||||
{
|
||||
const double LengthEpsilon = 0.01;
|
||||
const double AngleEpsilon = 0.1;
|
||||
// find 3 points to form 2 lines whose length is bigger than LengthEpsilon
|
||||
// and angle between them should be bigger than AngleEpsilon
|
||||
Line3D line0 = line3Ds[0];
|
||||
Vector vector0 = new Vector();
|
||||
Vector vector1 = new Vector();
|
||||
// to find the first 2 points to form first line
|
||||
int index = 0;
|
||||
for (int i = 1; i < line3Ds.Count; i++)
|
||||
{
|
||||
vector0 = line3Ds[i].StartPoint - line0.StartPoint;
|
||||
if (vector0.GetLength() > LengthEpsilon)
|
||||
{
|
||||
index = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (index == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
// to find the last points to form the second line
|
||||
for (int j = index + 1; j < line3Ds.Count; j++)
|
||||
{
|
||||
vector1 = line3Ds[j].StartPoint - line3Ds[index].StartPoint;
|
||||
double angle = Vector.GetAngleOf2Vectors(vector0, vector1, true);
|
||||
if (vector1.GetLength() > LengthEpsilon && angle > AngleEpsilon)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// find the local coordinate system in which the profile of opening is horizontal
|
||||
Vector zAxis = (vector0 & vector1).GetNormal();
|
||||
Vector xAxis = zAxis & (new Vector(0.0, 1.0, 0.0));
|
||||
Vector yAxis = zAxis & xAxis;
|
||||
Vector origin = new Vector(0.0, 0.0, 0.0);
|
||||
UCS ucs = new UCS(origin, xAxis, yAxis);
|
||||
|
||||
// transform all the 3D lines to UCS and create accordingly 2D lines
|
||||
bool isFirst = true;
|
||||
foreach (Line3D line in line3Ds)
|
||||
{
|
||||
Line3D tmp = ucs.GC2LC(line);
|
||||
PointF startPnt = new PointF((float)tmp.StartPoint.X, (float)tmp.StartPoint.Y);
|
||||
PointF endPnt = new PointF((float)tmp.EndPoint.X, (float)tmp.EndPoint.Y);
|
||||
Line2D line2D = new Line2D(startPnt, endPnt);
|
||||
LineSketch aLineSketch = new LineSketch(line2D);
|
||||
if (isFirst)
|
||||
{
|
||||
m_boundingBox = aLineSketch.BoundingBox;
|
||||
isFirst = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_boundingBox = RectangleF.Union(m_boundingBox, aLineSketch.BoundingBox);
|
||||
}
|
||||
m_objects.Add(aLineSketch);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user