mirror of
https://github.com/jeremytammik/RevitSdkSamples.git
synced 2026-09-10 13:37:40 +00:00
added Revit 2022 SDK minus except *rvt and *rfa
This commit is contained in:
@@ -0,0 +1,70 @@
|
||||
//
|
||||
// (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.Windows.Forms;
|
||||
|
||||
using Autodesk.Revit;
|
||||
using Autodesk.Revit.UI;
|
||||
|
||||
namespace Revit.SDK.Samples.MeasurePanelArea.CS
|
||||
{
|
||||
/// <summary>
|
||||
/// A class inherits IExternalCommand interface.
|
||||
/// this class creates an instance of the UI window and pop it up.
|
||||
/// </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 MeasurePanelArea : IExternalCommand
|
||||
{
|
||||
/// <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)
|
||||
{
|
||||
using (frmPanelArea form = new frmPanelArea(commandData))
|
||||
{
|
||||
// The form is created successfully
|
||||
if (null != form && !form.IsDisposed)
|
||||
{
|
||||
form.ShowDialog();
|
||||
}
|
||||
}
|
||||
|
||||
return Autodesk.Revit.UI.Result.Succeeded;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,227 @@
|
||||
namespace Revit.SDK.Samples.MeasurePanelArea.CS
|
||||
{
|
||||
partial class frmPanelArea
|
||||
{
|
||||
/// <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.btnCompute = new System.Windows.Forms.Button();
|
||||
this.groupBox1 = new System.Windows.Forms.GroupBox();
|
||||
this.label2 = new System.Windows.Forms.Label();
|
||||
this.label1 = new System.Windows.Forms.Label();
|
||||
this.txtMax = new System.Windows.Forms.TextBox();
|
||||
this.txtMin = new System.Windows.Forms.TextBox();
|
||||
this.groupBox2 = new System.Windows.Forms.GroupBox();
|
||||
this.label4 = new System.Windows.Forms.Label();
|
||||
this.label3 = new System.Windows.Forms.Label();
|
||||
this.cboxMin = new System.Windows.Forms.ComboBox();
|
||||
this.cboxMax = new System.Windows.Forms.ComboBox();
|
||||
this.cboxMid = new System.Windows.Forms.ComboBox();
|
||||
this.label5 = new System.Windows.Forms.Label();
|
||||
this.label6 = new System.Windows.Forms.Label();
|
||||
this.groupBox1.SuspendLayout();
|
||||
this.groupBox2.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// btnCompute
|
||||
//
|
||||
this.btnCompute.Location = new System.Drawing.Point(263, 274);
|
||||
this.btnCompute.Name = "btnCompute";
|
||||
this.btnCompute.Size = new System.Drawing.Size(75, 23);
|
||||
this.btnCompute.TabIndex = 5;
|
||||
this.btnCompute.Text = "&Compute";
|
||||
this.btnCompute.UseVisualStyleBackColor = true;
|
||||
this.btnCompute.Click += new System.EventHandler(this.btnCompute_Click);
|
||||
//
|
||||
// groupBox1
|
||||
//
|
||||
this.groupBox1.Controls.Add(this.label2);
|
||||
this.groupBox1.Controls.Add(this.label1);
|
||||
this.groupBox1.Controls.Add(this.txtMax);
|
||||
this.groupBox1.Controls.Add(this.txtMin);
|
||||
this.groupBox1.Location = new System.Drawing.Point(8, 48);
|
||||
this.groupBox1.Name = "groupBox1";
|
||||
this.groupBox1.Size = new System.Drawing.Size(330, 59);
|
||||
this.groupBox1.TabIndex = 10;
|
||||
this.groupBox1.TabStop = false;
|
||||
this.groupBox1.Text = "Desired Panel Area";
|
||||
//
|
||||
// label2
|
||||
//
|
||||
this.label2.AutoSize = true;
|
||||
this.label2.Location = new System.Drawing.Point(219, 25);
|
||||
this.label2.Name = "label2";
|
||||
this.label2.Size = new System.Drawing.Size(51, 13);
|
||||
this.label2.TabIndex = 8;
|
||||
this.label2.Text = "Maximum";
|
||||
//
|
||||
// label1
|
||||
//
|
||||
this.label1.AutoSize = true;
|
||||
this.label1.Location = new System.Drawing.Point(10, 25);
|
||||
this.label1.Name = "label1";
|
||||
this.label1.Size = new System.Drawing.Size(48, 13);
|
||||
this.label1.TabIndex = 7;
|
||||
this.label1.Text = "Minimum";
|
||||
//
|
||||
// txtMax
|
||||
//
|
||||
this.txtMax.Location = new System.Drawing.Point(287, 22);
|
||||
this.txtMax.Name = "txtMax";
|
||||
this.txtMax.Size = new System.Drawing.Size(32, 20);
|
||||
this.txtMax.TabIndex = 6;
|
||||
this.txtMax.Text = "102";
|
||||
//
|
||||
// txtMin
|
||||
//
|
||||
this.txtMin.Location = new System.Drawing.Point(75, 22);
|
||||
this.txtMin.Name = "txtMin";
|
||||
this.txtMin.Size = new System.Drawing.Size(32, 20);
|
||||
this.txtMin.TabIndex = 5;
|
||||
this.txtMin.Text = "98";
|
||||
//
|
||||
// groupBox2
|
||||
//
|
||||
this.groupBox2.Controls.Add(this.label4);
|
||||
this.groupBox2.Controls.Add(this.label3);
|
||||
this.groupBox2.Controls.Add(this.cboxMin);
|
||||
this.groupBox2.Controls.Add(this.cboxMax);
|
||||
this.groupBox2.Location = new System.Drawing.Point(8, 122);
|
||||
this.groupBox2.Name = "groupBox2";
|
||||
this.groupBox2.Size = new System.Drawing.Size(330, 100);
|
||||
this.groupBox2.TabIndex = 11;
|
||||
this.groupBox2.TabStop = false;
|
||||
this.groupBox2.Text = "Panels Outside Desired Range";
|
||||
//
|
||||
// label4
|
||||
//
|
||||
this.label4.AutoSize = true;
|
||||
this.label4.Location = new System.Drawing.Point(8, 65);
|
||||
this.label4.Name = "label4";
|
||||
this.label4.Size = new System.Drawing.Size(107, 13);
|
||||
this.label4.TabIndex = 13;
|
||||
this.label4.Text = "Larger than maximum";
|
||||
//
|
||||
// label3
|
||||
//
|
||||
this.label3.AutoSize = true;
|
||||
this.label3.Location = new System.Drawing.Point(8, 34);
|
||||
this.label3.Name = "label3";
|
||||
this.label3.Size = new System.Drawing.Size(108, 13);
|
||||
this.label3.TabIndex = 12;
|
||||
this.label3.Text = "Smaller than minimum";
|
||||
//
|
||||
// cboxMin
|
||||
//
|
||||
this.cboxMin.FormattingEnabled = true;
|
||||
this.cboxMin.Location = new System.Drawing.Point(126, 29);
|
||||
this.cboxMin.Name = "cboxMin";
|
||||
this.cboxMin.Size = new System.Drawing.Size(197, 21);
|
||||
this.cboxMin.TabIndex = 11;
|
||||
//
|
||||
// cboxMax
|
||||
//
|
||||
this.cboxMax.FormattingEnabled = true;
|
||||
this.cboxMax.Location = new System.Drawing.Point(126, 62);
|
||||
this.cboxMax.Name = "cboxMax";
|
||||
this.cboxMax.Size = new System.Drawing.Size(197, 21);
|
||||
this.cboxMax.TabIndex = 10;
|
||||
//
|
||||
// cboxMid
|
||||
//
|
||||
this.cboxMid.FormattingEnabled = true;
|
||||
this.cboxMid.Location = new System.Drawing.Point(134, 237);
|
||||
this.cboxMid.Name = "cboxMid";
|
||||
this.cboxMid.Size = new System.Drawing.Size(197, 21);
|
||||
this.cboxMid.TabIndex = 12;
|
||||
//
|
||||
// label5
|
||||
//
|
||||
this.label5.AutoSize = true;
|
||||
this.label5.Location = new System.Drawing.Point(20, 240);
|
||||
this.label5.Name = "label5";
|
||||
this.label5.Size = new System.Drawing.Size(82, 13);
|
||||
this.label5.TabIndex = 14;
|
||||
this.label5.Text = "All Other Panels";
|
||||
//
|
||||
// label6
|
||||
//
|
||||
this.label6.AutoSize = true;
|
||||
this.label6.Location = new System.Drawing.Point(5, 9);
|
||||
this.label6.Name = "label6";
|
||||
this.label6.Size = new System.Drawing.Size(310, 26);
|
||||
this.label6.TabIndex = 9;
|
||||
this.label6.Text = "Select divided surfaces to analyze before running this command.\nRun this command " +
|
||||
"with nothing selected to analyze all surfaces.";
|
||||
//
|
||||
// frmPanelArea
|
||||
//
|
||||
this.AcceptButton = this.btnCompute;
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(351, 309);
|
||||
this.Controls.Add(this.label6);
|
||||
this.Controls.Add(this.label5);
|
||||
this.Controls.Add(this.cboxMid);
|
||||
this.Controls.Add(this.groupBox2);
|
||||
this.Controls.Add(this.groupBox1);
|
||||
this.Controls.Add(this.btnCompute);
|
||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
|
||||
this.MaximizeBox = false;
|
||||
this.MinimizeBox = false;
|
||||
this.Name = "frmPanelArea";
|
||||
this.ShowIcon = false;
|
||||
this.ShowInTaskbar = false;
|
||||
this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide;
|
||||
this.Text = "Check Panel Area";
|
||||
this.groupBox1.ResumeLayout(false);
|
||||
this.groupBox1.PerformLayout();
|
||||
this.groupBox2.ResumeLayout(false);
|
||||
this.groupBox2.PerformLayout();
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.Button btnCompute;
|
||||
private System.Windows.Forms.GroupBox groupBox1;
|
||||
private System.Windows.Forms.Label label2;
|
||||
private System.Windows.Forms.Label label1;
|
||||
private System.Windows.Forms.TextBox txtMax;
|
||||
private System.Windows.Forms.TextBox txtMin;
|
||||
private System.Windows.Forms.GroupBox groupBox2;
|
||||
private System.Windows.Forms.Label label3;
|
||||
private System.Windows.Forms.ComboBox cboxMin;
|
||||
private System.Windows.Forms.ComboBox cboxMax;
|
||||
private System.Windows.Forms.Label label4;
|
||||
private System.Windows.Forms.ComboBox cboxMid;
|
||||
private System.Windows.Forms.Label label5;
|
||||
private System.Windows.Forms.Label label6;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,361 @@
|
||||
//
|
||||
// (C) Copyright 2003-2019 by Autodesk, Inc.
|
||||
//
|
||||
// Permission to use, copy, modify, and distribute this software in
|
||||
// object code form for any purpose and without fee is hereby granted,
|
||||
// provided that the above copyright notice appears in all copies and
|
||||
// that both that copyright notice and the limited warranty and
|
||||
// restricted rights notice below appear in all supporting
|
||||
// documentation.
|
||||
//
|
||||
// AUTODESK PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS.
|
||||
// AUTODESK SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF
|
||||
// MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE. AUTODESK, INC.
|
||||
// DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE
|
||||
// UNINTERRUPTED OR ERROR FREE.
|
||||
//
|
||||
// Use, duplication, or disclosure by the U.S. Government is subject to
|
||||
// restrictions set forth in FAR 52.227-19 (Commercial Computer
|
||||
// Software - Restricted Rights) and DFAR 252.227-7013(c)(1)(ii)
|
||||
// (Rights in Technical Data and Computer Software), as applicable.
|
||||
//
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
|
||||
using Autodesk.Revit;
|
||||
using Autodesk.Revit.DB;
|
||||
using Autodesk.Revit.UI;
|
||||
using Panel = Autodesk.Revit.DB.Panel;
|
||||
using Element = Autodesk.Revit.DB.Element;
|
||||
using Instance = Autodesk.Revit.DB.Instance;
|
||||
|
||||
namespace Revit.SDK.Samples.MeasurePanelArea.CS
|
||||
{
|
||||
/// <summary>
|
||||
/// The window designed for interactive operations
|
||||
/// </summary>
|
||||
public partial class frmPanelArea : System.Windows.Forms.Form
|
||||
{
|
||||
/// <summary>
|
||||
/// The revit application instance
|
||||
/// </summary>
|
||||
Autodesk.Revit.UI.UIApplication m_uiApp;
|
||||
/// <summary>
|
||||
/// The active Revit document
|
||||
/// </summary>
|
||||
UIDocument m_uiDoc;
|
||||
/// <summary>
|
||||
/// record the panel type specified by the user.
|
||||
/// the panel with an area is greater than "m_maxValue" will be changed to this type
|
||||
/// </summary>
|
||||
string m_maxType = "";
|
||||
/// <summary>
|
||||
/// record the panel type specified by the user.
|
||||
/// the panel with an area in the range [m_minValue, m_maxValue] will be changed to this type
|
||||
/// </summary>
|
||||
string m_midType = "";
|
||||
/// <summary>
|
||||
/// record the panel type specified by the user.
|
||||
/// the panel with an area is smaller than "m_minValue" will be changed to this type
|
||||
/// </summary>
|
||||
string m_minType = "";
|
||||
/// <summary>
|
||||
/// Record the minimum value of the desired panel area
|
||||
/// </summary>
|
||||
double m_minValue = 0;
|
||||
/// <summary>
|
||||
/// Record the maximum value of the desired panel area
|
||||
/// </summary>
|
||||
double m_maxValue = 0;
|
||||
/// <summary>
|
||||
/// Record how many panels have an area larger than the maximum value
|
||||
/// </summary>
|
||||
int m_maxCounter = 0;
|
||||
/// <summary>
|
||||
/// Record how many panels have an area smaller than the minimum value
|
||||
/// </summary>
|
||||
int m_minCounter = 0;
|
||||
/// <summary>
|
||||
/// Record how many panels have an area in the range [m_minValue, m_maxValue]
|
||||
/// </summary>
|
||||
int m_okCounter = 0;
|
||||
/// <summary>
|
||||
/// Store all the divided surface selected by user or store all the divided surface in the document if user selects nothing
|
||||
/// </summary>
|
||||
List<DividedSurface> m_dividedSurfaceList = new List<DividedSurface>();
|
||||
/// <summary>
|
||||
/// A stream used to record the panel's element id and area to a text file
|
||||
/// </summary>
|
||||
StreamWriter m_writeFile = null;
|
||||
|
||||
/// <summary>
|
||||
/// Constructor
|
||||
/// </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>
|
||||
public frmPanelArea(ExternalCommandData commandData)
|
||||
{
|
||||
m_uiApp = commandData.Application;
|
||||
m_uiDoc = m_uiApp.ActiveUIDocument;
|
||||
|
||||
InitializeComponent();
|
||||
BuildPanelTypeList(commandData);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Handle the event triggered when user clicks the "Compute" button:
|
||||
/// 1. compute all the panel areas;
|
||||
/// 2. compare the areas with the range, mark the panels with different types;
|
||||
/// 3. record the result to a text file
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void btnCompute_Click(object sender, EventArgs e)
|
||||
{
|
||||
m_minValue = Convert.ToDouble(txtMin.Text);
|
||||
m_maxValue = Convert.ToDouble(txtMax.Text);
|
||||
|
||||
SetPanelTypesFromUI();
|
||||
|
||||
string assemblyName = Assembly.GetExecutingAssembly().Location;
|
||||
string assemblyDirectory = Path.GetDirectoryName(assemblyName);
|
||||
m_writeFile = new StreamWriter(assemblyDirectory + @"\" + "_PanelArea.txt");
|
||||
m_writeFile.WriteLine("Panel Element ID : Area");
|
||||
|
||||
GetDividedSurfaces();
|
||||
|
||||
foreach (DividedSurface ds in m_dividedSurfaceList)
|
||||
{
|
||||
ExamineDividedSurface(ds);
|
||||
}
|
||||
m_writeFile.WriteLine(m_maxCounter + " panels larger than " + m_maxValue);
|
||||
m_writeFile.WriteLine(m_minCounter + " panels smaller than " + m_minValue);
|
||||
m_writeFile.WriteLine(m_okCounter + " panels within desired range");
|
||||
m_writeFile.Close();
|
||||
Close();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get names of Panel families and populate drop-down lists in the UI
|
||||
/// </summary>
|
||||
private void BuildPanelTypeList(ExternalCommandData commandData)
|
||||
{
|
||||
List<FamilyInstance> list = GetElements<FamilyInstance>();
|
||||
if (list.Count == 0)
|
||||
{
|
||||
TaskDialog.Show("Revit", "There are no panel families loaded in your project");
|
||||
btnCompute.Enabled = false;
|
||||
Close();
|
||||
return;
|
||||
}
|
||||
|
||||
FamilySymbol fs = commandData.Application.ActiveUIDocument.Document.GetElement(list[0].GetTypeId()) as FamilySymbol;
|
||||
string famDelimiter = ":";
|
||||
foreach (Autodesk.Revit.DB.ElementId famSymbolId in fs.Family.GetFamilySymbolIds())
|
||||
{
|
||||
Autodesk.Revit.DB.FamilySymbol famSymbol = (FamilySymbol)commandData.Application.ActiveUIDocument.Document.GetElement(famSymbolId);
|
||||
cboxMax.Items.Add(fs.Family.Name + famDelimiter + famSymbol.Name);
|
||||
cboxMin.Items.Add(fs.Family.Name + famDelimiter + famSymbol.Name);
|
||||
cboxMid.Items.Add(fs.Family.Name + famDelimiter + famSymbol.Name);
|
||||
}
|
||||
cboxMax.SelectedIndex = 0;
|
||||
cboxMin.SelectedIndex = 0;
|
||||
cboxMid.SelectedIndex = 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Analyse the panel types set by UI operation
|
||||
/// </summary>
|
||||
private void SetPanelTypesFromUI()
|
||||
{
|
||||
//Set the min, mid, and max panel types based on user selections in the UI
|
||||
string minFamilyAndType = Convert.ToString(cboxMin.Text);
|
||||
string maxFamilyAndType = Convert.ToString(cboxMax.Text);
|
||||
string midFamilyAndType = Convert.ToString(cboxMid.Text);
|
||||
|
||||
string delimStr = ":";
|
||||
char[] delimiter = delimStr.ToCharArray();
|
||||
string[] split = minFamilyAndType.Split(delimiter);
|
||||
m_minType = split[1];
|
||||
split = maxFamilyAndType.Split(delimiter);
|
||||
m_maxType = split[1];
|
||||
split = midFamilyAndType.Split(delimiter);
|
||||
m_midType = split[1];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Populate DividedSurfaceArray with the selected surfaces or all surfaces in the model
|
||||
/// </summary>
|
||||
private void GetDividedSurfaces()
|
||||
{
|
||||
// want to compute all the divided surfaces
|
||||
if (m_uiDoc.Selection.GetElementIds().Count == 0)
|
||||
{
|
||||
m_dividedSurfaceList = GetElements<DividedSurface>();
|
||||
return;
|
||||
}
|
||||
|
||||
// user selects some divided surface
|
||||
foreach (ElementId elementId in m_uiDoc.Selection.GetElementIds())
|
||||
{
|
||||
Element element = m_uiDoc.Document.GetElement(elementId);
|
||||
DividedSurface ds = element as DividedSurface;
|
||||
if (ds != null)
|
||||
{
|
||||
m_dividedSurfaceList.Add(ds);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Compute the area of the curtain panel instance
|
||||
/// </summary>
|
||||
/// <param name="familyinstance">
|
||||
/// the curtain panel which needs to be computed
|
||||
/// </param>
|
||||
/// <returns>
|
||||
/// the area of the curtain panel
|
||||
/// </returns>
|
||||
private double GetAreaOfTileInstance(FamilyInstance familyinstance)
|
||||
{
|
||||
double panelArea = 0d;
|
||||
Autodesk.Revit.DB.Options opt = m_uiApp.Application.Create.NewGeometryOptions();
|
||||
opt.ComputeReferences = true;
|
||||
Autodesk.Revit.DB.GeometryElement geomElem = familyinstance.get_Geometry(opt);
|
||||
//foreach (GeometryObject geomObject1 in geomElem.Objects)
|
||||
IEnumerator<GeometryObject> Objects = geomElem.GetEnumerator();
|
||||
while (Objects.MoveNext())
|
||||
{
|
||||
GeometryObject geomObject1 = Objects.Current;
|
||||
|
||||
Solid solid = null;
|
||||
// find area of partial border panels
|
||||
if (geomObject1 is Solid)
|
||||
{
|
||||
solid = (Solid)geomObject1;
|
||||
if (null == solid)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
// find area of non-partial panels
|
||||
else if (geomObject1 is GeometryInstance)
|
||||
{
|
||||
GeometryInstance geomInst = geomObject1 as GeometryInstance;
|
||||
//foreach (Object geomObj in geomInst.SymbolGeometry.Objects)
|
||||
IEnumerator<GeometryObject> Objects1 = geomInst.SymbolGeometry.GetEnumerator();
|
||||
while (Objects1.MoveNext())
|
||||
{
|
||||
Object geomObj = Objects1.Current;
|
||||
|
||||
solid = geomObj as Solid;
|
||||
if (solid != null)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (null == solid.Faces || 0 == solid.Faces.Size)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// get the area and write the data to a text file
|
||||
foreach (Face face in solid.Faces)
|
||||
{
|
||||
panelArea = face.Area;
|
||||
m_writeFile.WriteLine(familyinstance.Id.IntegerValue + " : " + panelArea);
|
||||
}
|
||||
}
|
||||
return panelArea;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Check all the panels whose areas are below/above/within the range in the divided surface, mark them with different symbols
|
||||
/// </summary>
|
||||
/// <param name="ds">
|
||||
/// The divided surfaces created in the document, it contains the panels for checking
|
||||
/// </param>
|
||||
void ExamineDividedSurface(DividedSurface ds)
|
||||
{
|
||||
ElementType sym = ds.Document.GetElement(ds.GetTypeId()) as ElementType;
|
||||
FamilySymbol fs_min = null;
|
||||
FamilySymbol fs_max = null;
|
||||
FamilySymbol fs_mid = null;
|
||||
|
||||
// get the panel types which are used to identify the panels in the divided surface
|
||||
FamilySymbol fs = sym as FamilySymbol;
|
||||
foreach (ElementId symbolId in fs.Family.GetFamilySymbolIds())
|
||||
{
|
||||
FamilySymbol symbol = (FamilySymbol)m_uiDoc.Document.GetElement(symbolId);
|
||||
if (symbol.Name == m_maxType)
|
||||
{
|
||||
fs_max = symbol;
|
||||
}
|
||||
if (symbol.Name == m_minType)
|
||||
{
|
||||
fs_min = symbol;
|
||||
}
|
||||
if (symbol.Name == m_midType)
|
||||
{
|
||||
fs_mid = symbol;
|
||||
}
|
||||
}
|
||||
|
||||
// find all the panels areas and compare with the range
|
||||
for (int u = 0; u < ds.NumberOfUGridlines; u++)
|
||||
{
|
||||
for (int v = 0; v < ds.NumberOfVGridlines; v++)
|
||||
{
|
||||
GridNode gn = new GridNode(u, v);
|
||||
if (false == ds.IsSeedNode(gn))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
FamilyInstance familyinstance = ds.GetTileFamilyInstance(gn, 0);
|
||||
if (familyinstance != null)
|
||||
{
|
||||
double panelArea = GetAreaOfTileInstance(familyinstance);
|
||||
// identify the panels drop in different ranges with different types
|
||||
if (panelArea > m_maxValue)
|
||||
{
|
||||
familyinstance.Symbol = fs_max;
|
||||
m_maxCounter++;
|
||||
}
|
||||
else if (panelArea < m_minValue)
|
||||
{
|
||||
familyinstance.Symbol = fs_min;
|
||||
m_minCounter++;
|
||||
}
|
||||
else
|
||||
{
|
||||
familyinstance.Symbol = fs_mid;
|
||||
m_okCounter++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected List<T> GetElements<T>() where T : Element
|
||||
{
|
||||
List<T> returns = new List<T>();
|
||||
FilteredElementCollector collector = new FilteredElementCollector(m_uiDoc.Document);
|
||||
ICollection<Element> founds = collector.OfClass(typeof(T)).ToElements();
|
||||
foreach (Element elem in founds)
|
||||
{
|
||||
returns.Add(elem as T);
|
||||
}
|
||||
return returns;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -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,13 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RevitAddIns>
|
||||
<AddIn Type="Command">
|
||||
<Assembly>MeasurePanelArea.dll</Assembly>
|
||||
<ClientId>3646be54-4bf7-41cb-abbd-52ede40351e7</ClientId>
|
||||
<FullClassName>Revit.SDK.Samples.MeasurePanelArea.CS.MeasurePanelArea</FullClassName>
|
||||
<Text>Measure Panel Area</Text>
|
||||
<Description>Measure curtain panels on divided surfaces and identify panels beyond a user-specified range</Description>
|
||||
<VisibilityMode>AlwaysVisible</VisibilityMode>
|
||||
<VendorId>ADSK</VendorId>
|
||||
<VendorDescription>Autodesk, www.autodesk.com</VendorDescription>
|
||||
</AddIn>
|
||||
</RevitAddIns>
|
||||
@@ -0,0 +1,143 @@
|
||||
<?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>{C8EF18E0-E9E6-4F81-83DC-1581BABBB057}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>Revit.SDK.Samples.MeasurePanelArea.CS</RootNamespace>
|
||||
<AssemblyName>MeasurePanelArea</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<PublishUrl>publish\</PublishUrl>
|
||||
<Install>true</Install>
|
||||
<InstallFrom>Disk</InstallFrom>
|
||||
<UpdateEnabled>false</UpdateEnabled>
|
||||
<UpdateMode>Foreground</UpdateMode>
|
||||
<UpdateInterval>7</UpdateInterval>
|
||||
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
|
||||
<UpdatePeriodically>false</UpdatePeriodically>
|
||||
<UpdateRequired>false</UpdateRequired>
|
||||
<MapFileExtensions>true</MapFileExtensions>
|
||||
<ApplicationRevision>0</ApplicationRevision>
|
||||
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
|
||||
<IsWebBootstrapper>false</IsWebBootstrapper>
|
||||
<UseApplicationTrust>false</UseApplicationTrust>
|
||||
<BootstrapperEnabled>true</BootstrapperEnabled>
|
||||
<StartupObject>
|
||||
</StartupObject>
|
||||
<TargetFrameworkProfile />
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<OutputPath>bin\x64\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<DebugType>full</DebugType>
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
|
||||
<OutputPath>bin\x64\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<Optimize>true</Optimize>
|
||||
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<RunPostBuildEvent>OnOutputUpdated</RunPostBuildEvent>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core">
|
||||
<RequiredTargetFramework>3.5</RequiredTargetFramework>
|
||||
</Reference>
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="FormPanelArea.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="FormPanelArea.Designer.cs">
|
||||
<DependentUpon>FormPanelArea.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Command.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<EmbeddedResource Include="FormPanelArea.resx">
|
||||
<DependentUpon>FormPanelArea.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<BootstrapperPackage Include="Microsoft.Net.Client.3.5">
|
||||
<Visible>False</Visible>
|
||||
<ProductName>.NET Framework Client Profile</ProductName>
|
||||
<Install>false</Install>
|
||||
</BootstrapperPackage>
|
||||
<BootstrapperPackage Include="Microsoft.Net.Framework.2.0">
|
||||
<Visible>False</Visible>
|
||||
<ProductName>.NET Framework 2.0 %28x86%29</ProductName>
|
||||
<Install>false</Install>
|
||||
</BootstrapperPackage>
|
||||
<BootstrapperPackage Include="Microsoft.Net.Framework.3.0">
|
||||
<Visible>False</Visible>
|
||||
<ProductName>.NET Framework 3.0 %28x86%29</ProductName>
|
||||
<Install>false</Install>
|
||||
</BootstrapperPackage>
|
||||
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5">
|
||||
<Visible>False</Visible>
|
||||
<ProductName>.NET Framework 3.5</ProductName>
|
||||
<Install>false</Install>
|
||||
</BootstrapperPackage>
|
||||
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
|
||||
<Visible>False</Visible>
|
||||
<ProductName>.NET Framework 3.5 SP1</ProductName>
|
||||
<Install>true</Install>
|
||||
</BootstrapperPackage>
|
||||
<BootstrapperPackage Include="Microsoft.Windows.Installer.3.1">
|
||||
<Visible>False</Visible>
|
||||
<ProductName>Windows Installer 3.1</ProductName>
|
||||
<Install>true</Install>
|
||||
</BootstrapperPackage>
|
||||
</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,36 @@
|
||||
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("DividedSurfaceAnalysis")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("Autodesk, Inc.")]
|
||||
[assembly: AssemblyProduct("DividedSurfaceAnalysis")]
|
||||
[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("4c7445dd-3e59-4b60-82af-610114a75e6e")]
|
||||
|
||||
// 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 Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
Binary file not shown.
Reference in New Issue
Block a user