应用程序名称:MeasurePanelArea
Revit 平台:所有版本
Revit 版本:2011.0
首次发布于:2010.0
编程语言:C#
技能级别:初级
类别:几何
类型:外部命令
主题:分割表面面板的测量和修改
摘要:
测量分割表面中幕墙面板的面积。识别面积大于和小于用户指定值的面板。在样本 DLL 文件所在的同一文件夹中创建一个文本文件,列出每个面板的面积和元素 ID。
类:
Autodesk.Revit.UI.IExternalCommand
Autodesk.Revit.DB.DividedSurface
Autodesk.Revit.DB.Panel
项目文件:
Command.cs
该文件包含 MeasurePanelArea 类,并在外部命令运行时被调用。
FormPanelArea.cs
创建用户界面和计算 btnCompute_Click 事件中的面积。
描述:
1. 查找加载到体量族中的面板族。
2. 创建一个包含已选 DividedSurface 元素的列表。如果未选择 DividedSurface 元素,则包括模型中的所有 DividedSurface 元素。
3. 找到 DividedSurface 元素中的所有面板。这些面板是由 DividedSurface.GetTileFamilyInstance(GridNode, tileIndex) 方法返回的 FamilyInstance 元素。
4. 使用 FamilyInstance.get_Geometry(opt) 获取每个面板的面积
a. 对于部分边界面板,get_Geometry 以 Solid 对象的形式返回面板的几何图形
b. 对于未切割的面板,它们的几何图形通过 Instance.SymbolGeometry.Objects 找到。
5. 根据面板面积与对话框中用户指定的范围的相对关系,更改 FamilyInstance.Symbol。
说明:
1. 创建一个或多个带分割表面和面板的体量形体。
2. 如果不想分析模型中的所有分割表面,则选择感兴趣的表面。
3. 运行此命令。
4. 输入最大值和最小值,以定义允许的面板面积范围。
5. 选择要用于标识在范围之下、之上和之间的面板类型。
6. 点击“计算”。
源代码
完整的源代码请加入QQ群649037449,在群文件中下载RevitSDK.exe,解压后在文件夹中搜索本文中应用程序名称即可获得完整源码
FormPanelArea.cs
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;
}
}
版权所有 :无锡模信建筑科技有限公司 苏ICP备2021028830号-1 BIM建模|BIM技术应用|BIM软件开发
联系地址:江苏省无锡市新吴区龙山路4号B座705 手机:18761516598