mirror of
https://github.com/jeremytammik/RevitSdkSamples.git
synced 2026-10-02 15:11:28 +00:00
cleaned up old snapshots
This commit is contained in:
@@ -0,0 +1,77 @@
|
||||
//
|
||||
// (C) Copyright 2003-2009 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 notify appears in all copies and
|
||||
// that both that copyright notify and the limited warranty and
|
||||
// restricted rights notify 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.Windows.Forms;
|
||||
|
||||
using Autodesk.Revit;
|
||||
using Autodesk.Revit.Elements;
|
||||
|
||||
namespace Revit.SDK.Samples.TransactionControl.CS
|
||||
{
|
||||
/// <summary>
|
||||
/// Implements the Revit add-in interface IExternalCommand
|
||||
/// </summary>
|
||||
public class Command : 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 IExternalCommand.Result Execute(ExternalCommandData commandData,
|
||||
ref string message, ElementSet elements)
|
||||
{
|
||||
try
|
||||
{
|
||||
// process data from Revit and show dialog
|
||||
using (TransactionForm transactionFrm = new TransactionForm(commandData))
|
||||
{
|
||||
if (transactionFrm.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
return IExternalCommand.Result.Succeeded;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
message = ex.Message;
|
||||
return IExternalCommand.Result.Failed;
|
||||
}
|
||||
return IExternalCommand.Result.Cancelled;
|
||||
}
|
||||
}
|
||||
}
|
||||
+313
@@ -0,0 +1,313 @@
|
||||
//
|
||||
// (C) Copyright 2003-2009 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 notify appears in all copies and
|
||||
// that both that copyright notify and the limited warranty and
|
||||
// restricted rights notify 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.TransactionControl.CS
|
||||
{
|
||||
partial class CreateWallForm
|
||||
{
|
||||
/// <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.okButton = new System.Windows.Forms.Button();
|
||||
this.cancelButton = new System.Windows.Forms.Button();
|
||||
this.spXTextBox = new System.Windows.Forms.TextBox();
|
||||
this.label1 = new System.Windows.Forms.Label();
|
||||
this.label2 = new System.Windows.Forms.Label();
|
||||
this.spYTextBox = new System.Windows.Forms.TextBox();
|
||||
this.label3 = new System.Windows.Forms.Label();
|
||||
this.spZTextBox = new System.Windows.Forms.TextBox();
|
||||
this.label4 = new System.Windows.Forms.Label();
|
||||
this.epXTextBox = new System.Windows.Forms.TextBox();
|
||||
this.epYTextBox = new System.Windows.Forms.TextBox();
|
||||
this.epZTextBox = new System.Windows.Forms.TextBox();
|
||||
this.label5 = new System.Windows.Forms.Label();
|
||||
this.label6 = new System.Windows.Forms.Label();
|
||||
this.label7 = new System.Windows.Forms.Label();
|
||||
this.label8 = new System.Windows.Forms.Label();
|
||||
this.label9 = new System.Windows.Forms.Label();
|
||||
this.levelsComboBox = new System.Windows.Forms.ComboBox();
|
||||
this.wallTypesComboBox = new System.Windows.Forms.ComboBox();
|
||||
this.label10 = new System.Windows.Forms.Label();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// okButton
|
||||
//
|
||||
this.okButton.Location = new System.Drawing.Point(96, 253);
|
||||
this.okButton.Name = "okButton";
|
||||
this.okButton.Size = new System.Drawing.Size(75, 23);
|
||||
this.okButton.TabIndex = 8;
|
||||
this.okButton.Text = "&OK";
|
||||
this.okButton.UseVisualStyleBackColor = true;
|
||||
this.okButton.Click += new System.EventHandler(this.okButton_Click);
|
||||
//
|
||||
// cancelButton
|
||||
//
|
||||
this.cancelButton.DialogResult = System.Windows.Forms.DialogResult.Cancel;
|
||||
this.cancelButton.Location = new System.Drawing.Point(177, 253);
|
||||
this.cancelButton.Name = "cancelButton";
|
||||
this.cancelButton.Size = new System.Drawing.Size(75, 23);
|
||||
this.cancelButton.TabIndex = 9;
|
||||
this.cancelButton.Text = "&Cancel";
|
||||
this.cancelButton.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// spXTextBox
|
||||
//
|
||||
this.spXTextBox.Location = new System.Drawing.Point(26, 40);
|
||||
this.spXTextBox.Name = "spXTextBox";
|
||||
this.spXTextBox.Size = new System.Drawing.Size(61, 20);
|
||||
this.spXTextBox.TabIndex = 0;
|
||||
this.spXTextBox.Text = "0";
|
||||
//
|
||||
// label1
|
||||
//
|
||||
this.label1.AutoSize = true;
|
||||
this.label1.Location = new System.Drawing.Point(7, 43);
|
||||
this.label1.Name = "label1";
|
||||
this.label1.Size = new System.Drawing.Size(17, 13);
|
||||
this.label1.TabIndex = 11;
|
||||
this.label1.Text = "X:";
|
||||
//
|
||||
// label2
|
||||
//
|
||||
this.label2.AutoSize = true;
|
||||
this.label2.Location = new System.Drawing.Point(7, 16);
|
||||
this.label2.Name = "label2";
|
||||
this.label2.Size = new System.Drawing.Size(58, 13);
|
||||
this.label2.TabIndex = 10;
|
||||
this.label2.Text = "Start point:";
|
||||
//
|
||||
// spYTextBox
|
||||
//
|
||||
this.spYTextBox.Location = new System.Drawing.Point(109, 40);
|
||||
this.spYTextBox.Name = "spYTextBox";
|
||||
this.spYTextBox.Size = new System.Drawing.Size(61, 20);
|
||||
this.spYTextBox.TabIndex = 1;
|
||||
this.spYTextBox.Text = "0";
|
||||
//
|
||||
// label3
|
||||
//
|
||||
this.label3.AutoSize = true;
|
||||
this.label3.Location = new System.Drawing.Point(90, 43);
|
||||
this.label3.Name = "label3";
|
||||
this.label3.Size = new System.Drawing.Size(17, 13);
|
||||
this.label3.TabIndex = 12;
|
||||
this.label3.Text = "Y:";
|
||||
//
|
||||
// spZTextBox
|
||||
//
|
||||
this.spZTextBox.Location = new System.Drawing.Point(191, 40);
|
||||
this.spZTextBox.Name = "spZTextBox";
|
||||
this.spZTextBox.Size = new System.Drawing.Size(61, 20);
|
||||
this.spZTextBox.TabIndex = 2;
|
||||
this.spZTextBox.Text = "0";
|
||||
//
|
||||
// label4
|
||||
//
|
||||
this.label4.AutoSize = true;
|
||||
this.label4.Location = new System.Drawing.Point(172, 43);
|
||||
this.label4.Name = "label4";
|
||||
this.label4.Size = new System.Drawing.Size(17, 13);
|
||||
this.label4.TabIndex = 13;
|
||||
this.label4.Text = "Z:";
|
||||
//
|
||||
// epXTextBox
|
||||
//
|
||||
this.epXTextBox.Location = new System.Drawing.Point(26, 97);
|
||||
this.epXTextBox.Name = "epXTextBox";
|
||||
this.epXTextBox.Size = new System.Drawing.Size(61, 20);
|
||||
this.epXTextBox.TabIndex = 3;
|
||||
this.epXTextBox.Text = "0";
|
||||
//
|
||||
// epYTextBox
|
||||
//
|
||||
this.epYTextBox.Location = new System.Drawing.Point(109, 97);
|
||||
this.epYTextBox.Name = "epYTextBox";
|
||||
this.epYTextBox.Size = new System.Drawing.Size(61, 20);
|
||||
this.epYTextBox.TabIndex = 4;
|
||||
this.epYTextBox.Text = "0";
|
||||
//
|
||||
// epZTextBox
|
||||
//
|
||||
this.epZTextBox.Location = new System.Drawing.Point(191, 97);
|
||||
this.epZTextBox.Name = "epZTextBox";
|
||||
this.epZTextBox.Size = new System.Drawing.Size(61, 20);
|
||||
this.epZTextBox.TabIndex = 5;
|
||||
this.epZTextBox.Text = "0";
|
||||
//
|
||||
// label5
|
||||
//
|
||||
this.label5.AutoSize = true;
|
||||
this.label5.Location = new System.Drawing.Point(7, 100);
|
||||
this.label5.Name = "label5";
|
||||
this.label5.Size = new System.Drawing.Size(17, 13);
|
||||
this.label5.TabIndex = 15;
|
||||
this.label5.Text = "X:";
|
||||
//
|
||||
// label6
|
||||
//
|
||||
this.label6.AutoSize = true;
|
||||
this.label6.Location = new System.Drawing.Point(90, 100);
|
||||
this.label6.Name = "label6";
|
||||
this.label6.Size = new System.Drawing.Size(17, 13);
|
||||
this.label6.TabIndex = 16;
|
||||
this.label6.Text = "Y:";
|
||||
//
|
||||
// label7
|
||||
//
|
||||
this.label7.AutoSize = true;
|
||||
this.label7.Location = new System.Drawing.Point(172, 100);
|
||||
this.label7.Name = "label7";
|
||||
this.label7.Size = new System.Drawing.Size(17, 13);
|
||||
this.label7.TabIndex = 17;
|
||||
this.label7.Text = "Z:";
|
||||
//
|
||||
// label8
|
||||
//
|
||||
this.label8.AutoSize = true;
|
||||
this.label8.Location = new System.Drawing.Point(7, 73);
|
||||
this.label8.Name = "label8";
|
||||
this.label8.Size = new System.Drawing.Size(55, 13);
|
||||
this.label8.TabIndex = 14;
|
||||
this.label8.Text = "End point:";
|
||||
//
|
||||
// label9
|
||||
//
|
||||
this.label9.AutoSize = true;
|
||||
this.label9.Location = new System.Drawing.Point(7, 187);
|
||||
this.label9.Name = "label9";
|
||||
this.label9.Size = new System.Drawing.Size(36, 13);
|
||||
this.label9.TabIndex = 19;
|
||||
this.label9.Text = "Level:";
|
||||
//
|
||||
// levelsComboBox
|
||||
//
|
||||
this.levelsComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.levelsComboBox.FormattingEnabled = true;
|
||||
this.levelsComboBox.Location = new System.Drawing.Point(26, 211);
|
||||
this.levelsComboBox.Name = "levelsComboBox";
|
||||
this.levelsComboBox.Size = new System.Drawing.Size(103, 21);
|
||||
this.levelsComboBox.TabIndex = 7;
|
||||
//
|
||||
// wallTypesComboBox
|
||||
//
|
||||
this.wallTypesComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.wallTypesComboBox.FormattingEnabled = true;
|
||||
this.wallTypesComboBox.Location = new System.Drawing.Point(26, 155);
|
||||
this.wallTypesComboBox.Name = "wallTypesComboBox";
|
||||
this.wallTypesComboBox.Size = new System.Drawing.Size(226, 21);
|
||||
this.wallTypesComboBox.TabIndex = 6;
|
||||
//
|
||||
// label10
|
||||
//
|
||||
this.label10.AutoSize = true;
|
||||
this.label10.Location = new System.Drawing.Point(7, 131);
|
||||
this.label10.Name = "label10";
|
||||
this.label10.Size = new System.Drawing.Size(54, 13);
|
||||
this.label10.TabIndex = 18;
|
||||
this.label10.Text = "Wall type:";
|
||||
//
|
||||
// CreateWallForm
|
||||
//
|
||||
this.AcceptButton = this.okButton;
|
||||
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(264, 288);
|
||||
this.Controls.Add(this.label10);
|
||||
this.Controls.Add(this.wallTypesComboBox);
|
||||
this.Controls.Add(this.levelsComboBox);
|
||||
this.Controls.Add(this.label9);
|
||||
this.Controls.Add(this.label8);
|
||||
this.Controls.Add(this.label2);
|
||||
this.Controls.Add(this.label7);
|
||||
this.Controls.Add(this.label4);
|
||||
this.Controls.Add(this.label6);
|
||||
this.Controls.Add(this.label3);
|
||||
this.Controls.Add(this.label5);
|
||||
this.Controls.Add(this.label1);
|
||||
this.Controls.Add(this.epZTextBox);
|
||||
this.Controls.Add(this.spZTextBox);
|
||||
this.Controls.Add(this.epYTextBox);
|
||||
this.Controls.Add(this.spYTextBox);
|
||||
this.Controls.Add(this.epXTextBox);
|
||||
this.Controls.Add(this.spXTextBox);
|
||||
this.Controls.Add(this.cancelButton);
|
||||
this.Controls.Add(this.okButton);
|
||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
|
||||
this.MaximizeBox = false;
|
||||
this.MinimizeBox = false;
|
||||
this.Name = "CreateWallForm";
|
||||
this.ShowInTaskbar = false;
|
||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
|
||||
this.Text = "Create Wall";
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.Button okButton;
|
||||
private System.Windows.Forms.Button cancelButton;
|
||||
private System.Windows.Forms.TextBox spXTextBox;
|
||||
private System.Windows.Forms.Label label1;
|
||||
private System.Windows.Forms.Label label2;
|
||||
private System.Windows.Forms.TextBox spYTextBox;
|
||||
private System.Windows.Forms.Label label3;
|
||||
private System.Windows.Forms.TextBox spZTextBox;
|
||||
private System.Windows.Forms.Label label4;
|
||||
private System.Windows.Forms.TextBox epXTextBox;
|
||||
private System.Windows.Forms.TextBox epYTextBox;
|
||||
private System.Windows.Forms.TextBox epZTextBox;
|
||||
private System.Windows.Forms.Label label5;
|
||||
private System.Windows.Forms.Label label6;
|
||||
private System.Windows.Forms.Label label7;
|
||||
private System.Windows.Forms.Label label8;
|
||||
private System.Windows.Forms.Label label9;
|
||||
private System.Windows.Forms.ComboBox levelsComboBox;
|
||||
private System.Windows.Forms.ComboBox wallTypesComboBox;
|
||||
private System.Windows.Forms.Label label10;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,165 @@
|
||||
//
|
||||
// (C) Copyright 2003-2009 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 notify appears in all copies and
|
||||
// that both that copyright notify and the limited warranty and
|
||||
// restricted rights notify 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;
|
||||
|
||||
using Autodesk.Revit;
|
||||
using Autodesk.Revit.Elements;
|
||||
using Autodesk.Revit.Symbols;
|
||||
|
||||
namespace Revit.SDK.Samples.TransactionControl.CS
|
||||
{
|
||||
/// <summary>
|
||||
/// A Form used to create a wall
|
||||
/// </summary>
|
||||
public partial class CreateWallForm : System.Windows.Forms.Form
|
||||
{
|
||||
//a reference to the external command data.
|
||||
private ExternalCommandData m_commandData;
|
||||
|
||||
/// <summary>
|
||||
/// Constructor
|
||||
/// </summary>
|
||||
/// <param name="commandData">the external command data</param>
|
||||
public CreateWallForm(ExternalCommandData commandData)
|
||||
{
|
||||
InitializeComponent();
|
||||
m_commandData = commandData;
|
||||
Initialize();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// do some initialization work: get all levels and wall types in active document
|
||||
/// and add them to combo box
|
||||
/// </summary>
|
||||
private void Initialize()
|
||||
{
|
||||
//add levels to combo box levelsComboBox
|
||||
Document document = m_commandData.Application.ActiveDocument;
|
||||
ElementIterator iter = document.get_Elements(typeof(Level));
|
||||
iter.Reset();
|
||||
for(;iter.MoveNext();)
|
||||
{
|
||||
if(null != iter.Current)
|
||||
{
|
||||
this.levelsComboBox.Items.Add(iter.Current);
|
||||
}
|
||||
}
|
||||
if(this.levelsComboBox.Items.Count > 0)
|
||||
{
|
||||
this.levelsComboBox.DisplayMember = "Name";
|
||||
this.levelsComboBox.SelectedIndex = 0;
|
||||
}
|
||||
|
||||
//add wall types to combo box wallTypesComboBox
|
||||
foreach (WallType wallType in document.WallTypes)
|
||||
{
|
||||
if (null == wallType)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
this.wallTypesComboBox.Items.Add(wallType);
|
||||
}
|
||||
if(this.wallTypesComboBox.Items.Count > 0)
|
||||
{
|
||||
this.wallTypesComboBox.DisplayMember = "Name";
|
||||
this.wallTypesComboBox.SelectedIndex = 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// try to create a wall. if failed, keep this dialog,
|
||||
/// otherwise, close it.
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void okButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
Document document = m_commandData.Application.ActiveDocument;
|
||||
double x, y, z;
|
||||
Autodesk.Revit.Geometry.XYZ sPoint;
|
||||
|
||||
//try to convert string to double, and return without closing dialog if failed
|
||||
if(Double.TryParse(this.spXTextBox.Text,out x) &&
|
||||
Double.TryParse(this.spYTextBox.Text,out y) &&
|
||||
Double.TryParse(this.spZTextBox.Text,out z))
|
||||
{
|
||||
sPoint = new Autodesk.Revit.Geometry.XYZ(x, y, z);
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Get start point failed.");
|
||||
return;
|
||||
}
|
||||
|
||||
//try to convert string to double, and return without closing dialog if failed
|
||||
Autodesk.Revit.Geometry.XYZ ePoint;
|
||||
if (Double.TryParse(this.epXTextBox.Text, out x) &&
|
||||
Double.TryParse(this.epYTextBox.Text, out y) &&
|
||||
Double.TryParse(this.epZTextBox.Text, out z))
|
||||
{
|
||||
ePoint = new Autodesk.Revit.Geometry.XYZ(x, y, z);
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Get end point failed.");
|
||||
return;
|
||||
}
|
||||
|
||||
Autodesk.Revit.Geometry.Line line = m_commandData.Application.Create.NewLine(sPoint, ePoint, true);
|
||||
|
||||
Level level = this.levelsComboBox.SelectedItem as Level;
|
||||
WallType wallType = this.wallTypesComboBox.SelectedItem as WallType;
|
||||
|
||||
//check whether parameters used to create wall are not null
|
||||
if (null == line)
|
||||
{
|
||||
MessageBox.Show("Create line failed.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (null == level || null == wallType)
|
||||
{
|
||||
MessageBox.Show("Please select a level and a wall type.");
|
||||
return;
|
||||
}
|
||||
|
||||
document.Create.NewWall(line, wallType, level, 10, 0, true, true);
|
||||
this.DialogResult = DialogResult.OK;
|
||||
this.Close();
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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,35 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("TransactionControl")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("TransactionControl")]
|
||||
[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("18f5d6d3-6f43-40cd-b274-b0f286625e08")]
|
||||
|
||||
// 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,6 @@
|
||||
[ExternalCommands]
|
||||
ECCount=1
|
||||
ECName1=Transaction
|
||||
ECClassName1=Revit.SDK.Samples.TransactionControl.CS.Command
|
||||
ECAssembly1=TransactionControl.dll
|
||||
ECDescription1=Demonstrate how to use transaction control.
|
||||
@@ -0,0 +1,80 @@
|
||||
<Project ToolsVersion="3.5" 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>{CABE1E71-BAD8-4B8F-9001-D9D2A484F146}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>TransactionControl</RootNamespace>
|
||||
<AssemblyName>TransactionControl</AssemblyName>
|
||||
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
|
||||
</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>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="RevitAPI, Version=10.0.0.0, Culture=neutral, processorArchitecture=x86">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>C:\Program Files\Autodesk Revit Architecture 2010\Program\RevitAPI.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="System.Core">
|
||||
<RequiredTargetFramework>3.5</RequiredTargetFramework>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Command.cs" />
|
||||
<Compile Include="CreateWallForm.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="CreateWallForm.Designer.cs">
|
||||
<DependentUpon>CreateWallForm.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="TransactionForm.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="TransactionForm.Designer.cs">
|
||||
<DependentUpon>TransactionForm.cs</DependentUpon>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="CreateWallForm.resx">
|
||||
<SubType>Designer</SubType>
|
||||
<DependentUpon>CreateWallForm.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="TransactionForm.resx">
|
||||
<SubType>Designer</SubType>
|
||||
<DependentUpon>TransactionForm.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.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>
|
||||
-->
|
||||
</Project>
|
||||
+217
@@ -0,0 +1,217 @@
|
||||
//
|
||||
// (C) Copyright 2003-2009 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 notify appears in all copies and
|
||||
// that both that copyright notify and the limited warranty and
|
||||
// restricted rights notify 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.TransactionControl.CS
|
||||
{
|
||||
partial class TransactionForm
|
||||
{
|
||||
/// <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.okButton = new System.Windows.Forms.Button();
|
||||
this.cancelButton = new System.Windows.Forms.Button();
|
||||
this.groupBox1 = new System.Windows.Forms.GroupBox();
|
||||
this.abortTransButton = new System.Windows.Forms.Button();
|
||||
this.endTransButton = new System.Windows.Forms.Button();
|
||||
this.beginTransButton = new System.Windows.Forms.Button();
|
||||
this.groupBox2 = new System.Windows.Forms.GroupBox();
|
||||
this.deleteWallButton = new System.Windows.Forms.Button();
|
||||
this.moveWallButton = new System.Windows.Forms.Button();
|
||||
this.createWallbutton = new System.Windows.Forms.Button();
|
||||
this.transactionsTreeView = new System.Windows.Forms.TreeView();
|
||||
this.groupBox1.SuspendLayout();
|
||||
this.groupBox2.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// okButton
|
||||
//
|
||||
this.okButton.Location = new System.Drawing.Point(212, 271);
|
||||
this.okButton.Name = "okButton";
|
||||
this.okButton.Size = new System.Drawing.Size(75, 23);
|
||||
this.okButton.TabIndex = 7;
|
||||
this.okButton.Text = "&OK";
|
||||
this.okButton.UseVisualStyleBackColor = true;
|
||||
this.okButton.Click += new System.EventHandler(this.okButton_Click);
|
||||
//
|
||||
// cancelButton
|
||||
//
|
||||
this.cancelButton.DialogResult = System.Windows.Forms.DialogResult.Cancel;
|
||||
this.cancelButton.Location = new System.Drawing.Point(293, 271);
|
||||
this.cancelButton.Name = "cancelButton";
|
||||
this.cancelButton.Size = new System.Drawing.Size(75, 23);
|
||||
this.cancelButton.TabIndex = 8;
|
||||
this.cancelButton.Text = "&Cancel";
|
||||
this.cancelButton.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// groupBox1
|
||||
//
|
||||
this.groupBox1.Controls.Add(this.abortTransButton);
|
||||
this.groupBox1.Controls.Add(this.endTransButton);
|
||||
this.groupBox1.Controls.Add(this.beginTransButton);
|
||||
this.groupBox1.Location = new System.Drawing.Point(13, 13);
|
||||
this.groupBox1.Name = "groupBox1";
|
||||
this.groupBox1.Size = new System.Drawing.Size(115, 115);
|
||||
this.groupBox1.TabIndex = 9;
|
||||
this.groupBox1.TabStop = false;
|
||||
this.groupBox1.Text = "Transaction";
|
||||
//
|
||||
// abortTransButton
|
||||
//
|
||||
this.abortTransButton.Location = new System.Drawing.Point(20, 77);
|
||||
this.abortTransButton.Name = "abortTransButton";
|
||||
this.abortTransButton.Size = new System.Drawing.Size(75, 23);
|
||||
this.abortTransButton.TabIndex = 2;
|
||||
this.abortTransButton.Text = "&Abort";
|
||||
this.abortTransButton.UseVisualStyleBackColor = true;
|
||||
this.abortTransButton.Click += new System.EventHandler(this.abortTransButton_Click);
|
||||
//
|
||||
// endTransButton
|
||||
//
|
||||
this.endTransButton.Location = new System.Drawing.Point(20, 48);
|
||||
this.endTransButton.Name = "endTransButton";
|
||||
this.endTransButton.Size = new System.Drawing.Size(75, 23);
|
||||
this.endTransButton.TabIndex = 1;
|
||||
this.endTransButton.Text = "&End";
|
||||
this.endTransButton.UseVisualStyleBackColor = true;
|
||||
this.endTransButton.Click += new System.EventHandler(this.endTransButton_Click);
|
||||
//
|
||||
// beginTransButton
|
||||
//
|
||||
this.beginTransButton.Location = new System.Drawing.Point(20, 19);
|
||||
this.beginTransButton.Name = "beginTransButton";
|
||||
this.beginTransButton.Size = new System.Drawing.Size(75, 23);
|
||||
this.beginTransButton.TabIndex = 0;
|
||||
this.beginTransButton.Text = "&Begin";
|
||||
this.beginTransButton.UseVisualStyleBackColor = true;
|
||||
this.beginTransButton.Click += new System.EventHandler(this.beginTransButton_Click);
|
||||
//
|
||||
// groupBox2
|
||||
//
|
||||
this.groupBox2.Controls.Add(this.deleteWallButton);
|
||||
this.groupBox2.Controls.Add(this.moveWallButton);
|
||||
this.groupBox2.Controls.Add(this.createWallbutton);
|
||||
this.groupBox2.Location = new System.Drawing.Point(13, 134);
|
||||
this.groupBox2.Name = "groupBox2";
|
||||
this.groupBox2.Size = new System.Drawing.Size(115, 117);
|
||||
this.groupBox2.TabIndex = 10;
|
||||
this.groupBox2.TabStop = false;
|
||||
this.groupBox2.Text = "Operations";
|
||||
//
|
||||
// deleteWallButton
|
||||
//
|
||||
this.deleteWallButton.Location = new System.Drawing.Point(20, 77);
|
||||
this.deleteWallButton.Name = "deleteWallButton";
|
||||
this.deleteWallButton.Size = new System.Drawing.Size(75, 23);
|
||||
this.deleteWallButton.TabIndex = 2;
|
||||
this.deleteWallButton.Text = "&Delete Wall";
|
||||
this.deleteWallButton.UseVisualStyleBackColor = true;
|
||||
this.deleteWallButton.Click += new System.EventHandler(this.deleteWallButton_Click);
|
||||
//
|
||||
// moveWallButton
|
||||
//
|
||||
this.moveWallButton.Location = new System.Drawing.Point(20, 48);
|
||||
this.moveWallButton.Name = "moveWallButton";
|
||||
this.moveWallButton.Size = new System.Drawing.Size(75, 23);
|
||||
this.moveWallButton.TabIndex = 1;
|
||||
this.moveWallButton.Text = "&Move Wall";
|
||||
this.moveWallButton.UseVisualStyleBackColor = true;
|
||||
this.moveWallButton.Click += new System.EventHandler(this.moveWallButton_Click);
|
||||
//
|
||||
// createWallbutton
|
||||
//
|
||||
this.createWallbutton.Location = new System.Drawing.Point(20, 19);
|
||||
this.createWallbutton.Name = "createWallbutton";
|
||||
this.createWallbutton.Size = new System.Drawing.Size(75, 23);
|
||||
this.createWallbutton.TabIndex = 0;
|
||||
this.createWallbutton.Text = "C&reate Wall";
|
||||
this.createWallbutton.UseVisualStyleBackColor = true;
|
||||
this.createWallbutton.Click += new System.EventHandler(this.createWallbutton_Click);
|
||||
//
|
||||
// transactionsTreeView
|
||||
//
|
||||
this.transactionsTreeView.Location = new System.Drawing.Point(134, 13);
|
||||
this.transactionsTreeView.Name = "transactionsTreeView";
|
||||
this.transactionsTreeView.Size = new System.Drawing.Size(234, 252);
|
||||
this.transactionsTreeView.TabIndex = 11;
|
||||
//
|
||||
// TransactionForm
|
||||
//
|
||||
this.AcceptButton = this.okButton;
|
||||
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(380, 302);
|
||||
this.Controls.Add(this.transactionsTreeView);
|
||||
this.Controls.Add(this.groupBox2);
|
||||
this.Controls.Add(this.groupBox1);
|
||||
this.Controls.Add(this.cancelButton);
|
||||
this.Controls.Add(this.okButton);
|
||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
|
||||
this.MaximizeBox = false;
|
||||
this.MinimizeBox = false;
|
||||
this.Name = "TransactionForm";
|
||||
this.ShowInTaskbar = false;
|
||||
this.Text = "Transaction";
|
||||
this.groupBox1.ResumeLayout(false);
|
||||
this.groupBox2.ResumeLayout(false);
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.Button okButton;
|
||||
private System.Windows.Forms.Button cancelButton;
|
||||
private System.Windows.Forms.GroupBox groupBox1;
|
||||
private System.Windows.Forms.Button abortTransButton;
|
||||
private System.Windows.Forms.Button endTransButton;
|
||||
private System.Windows.Forms.Button beginTransButton;
|
||||
private System.Windows.Forms.GroupBox groupBox2;
|
||||
private System.Windows.Forms.Button deleteWallButton;
|
||||
private System.Windows.Forms.Button moveWallButton;
|
||||
private System.Windows.Forms.Button createWallbutton;
|
||||
private System.Windows.Forms.TreeView transactionsTreeView;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,370 @@
|
||||
//
|
||||
// (C) Copyright 2003-2009 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 notify appears in all copies and
|
||||
// that both that copyright notify and the limited warranty and
|
||||
// restricted rights notify 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;
|
||||
|
||||
using Autodesk.Revit;
|
||||
using Autodesk.Revit.Elements;
|
||||
|
||||
namespace Revit.SDK.Samples.TransactionControl.CS
|
||||
{
|
||||
using SystemColor = System.Drawing.Color;
|
||||
|
||||
/// <summary>
|
||||
/// A Form used to deal with transaction and create, move or delete a wall
|
||||
/// </summary>
|
||||
public partial class TransactionForm : System.Windows.Forms.Form
|
||||
{
|
||||
/// <summary>
|
||||
/// an enum used to indicate which operation is executed
|
||||
/// </summary>
|
||||
private enum OperationType
|
||||
{
|
||||
BeginTransaction,
|
||||
EndTransaction,
|
||||
AbortTransaction,
|
||||
APIOperation
|
||||
}
|
||||
|
||||
private ExternalCommandData m_commandData; //a reference to the external command data
|
||||
private TreeNode m_parentNode; //a reference to tree node where sub node will be added
|
||||
private int m_activeTransCount = 0; //the number of transactions which is not over
|
||||
private int m_totalTransCount = 0; //the number of all transactions or method "BeginTransaction" is called
|
||||
private SystemColor m_beginTransColor = SystemColor.Green; //fore color of tree node before a transaction is over
|
||||
private SystemColor m_endTransColor = SystemColor.Black; //fore color of tree node after ending a transaction
|
||||
private SystemColor m_abortTransColor = SystemColor.Gray; //fore color of tree node after aborting a transaction
|
||||
private SystemColor m_normalColor = SystemColor.Blue; //fore color of tree node which is not executed during a transaction
|
||||
|
||||
/// <summary>
|
||||
/// Constructor
|
||||
/// </summary>
|
||||
/// <param name="commandData">the external command data</param>
|
||||
public TransactionForm(ExternalCommandData commandData)
|
||||
{
|
||||
InitializeComponent();
|
||||
m_commandData = commandData;
|
||||
|
||||
m_parentNode = new TreeNode("Flow");
|
||||
this.transactionsTreeView.Nodes.Add(m_parentNode);
|
||||
|
||||
UpdateButtonsStatus();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Begin a transaction, append transaction node to tree view
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void beginTransButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
m_commandData.Application.ActiveDocument.BeginTransaction();
|
||||
AddNode(OperationType.BeginTransaction);
|
||||
UpdateButtonsStatus();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// End a transaction
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void endTransButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (m_activeTransCount < 1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
m_commandData.Application.ActiveDocument.EndTransaction();
|
||||
AddNode(OperationType.EndTransaction);
|
||||
UpdateButtonsStatus();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Abort a transaction
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void abortTransButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (m_activeTransCount < 1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
m_commandData.Application.ActiveDocument.AbortTransaction();
|
||||
AddNode(OperationType.AbortTransaction);
|
||||
UpdateButtonsStatus();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create a wall, append a node to tree view
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void createWallbutton_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
using (CreateWallForm createWallForm = new CreateWallForm(m_commandData))
|
||||
{
|
||||
createWallForm.ShowDialog();
|
||||
if (DialogResult.OK == createWallForm.DialogResult)
|
||||
{
|
||||
AddNode(OperationType.APIOperation, "Create a wall");
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show("Create wall failed: " + ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Move a wall, append a node to tree view
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void moveWallButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
Document document = m_commandData.Application.ActiveDocument;
|
||||
// iterate elements to find a wall to move
|
||||
ElementIterator iter = document.get_Elements(typeof(Wall));
|
||||
iter.Reset();
|
||||
while (iter.MoveNext())
|
||||
{
|
||||
if (null != iter.Current)
|
||||
{
|
||||
Autodesk.Revit.Geometry.XYZ translationVec =
|
||||
new Autodesk.Revit.Geometry.XYZ(10, 10, 0);
|
||||
document.Move(iter.Current as Wall, translationVec);
|
||||
AddNode(OperationType.APIOperation, "Move a wall");
|
||||
return;
|
||||
}
|
||||
}
|
||||
//if no wall was found, show a message box to notify user
|
||||
MessageBox.Show("No wall exists.");
|
||||
}
|
||||
catch
|
||||
{
|
||||
//if an Exception was thrown, show a message box to notify user
|
||||
MessageBox.Show("Move wall failed.");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Delete a wall, append a node to tree view
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void deleteWallButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
Document document = m_commandData.Application.ActiveDocument;
|
||||
ElementIterator iter = document.get_Elements(typeof(Wall));
|
||||
iter.Reset();
|
||||
// iterate elements to find a wall to delete
|
||||
while (iter.MoveNext())
|
||||
{
|
||||
if (null != iter.Current)
|
||||
{
|
||||
//show a message box for user to confirm
|
||||
if (DialogResult.Yes ==
|
||||
MessageBox.Show("Delete a wall?", "Warning", MessageBoxButtons.YesNo))
|
||||
{
|
||||
document.Delete(iter.Current as Wall);
|
||||
AddNode(OperationType.APIOperation, "Delete a wall");
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
//if did not find a wall, show a message box to notify user
|
||||
MessageBox.Show("No wall exists.");
|
||||
}
|
||||
catch
|
||||
{
|
||||
//if an Exception is thrown, show a message box to notify user
|
||||
MessageBox.Show("Delete wall failed.");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// End the transactions that are not over and close this dialog
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void okButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
//if some transactions are not over, notify user to deal with
|
||||
if (0 != m_activeTransCount)
|
||||
{
|
||||
DialogResult dialogResult = MessageBox.Show("Some transactions are not over. Do you want to end all of them?", "Warning", MessageBoxButtons.YesNoCancel);
|
||||
if(DialogResult.Cancel == dialogResult)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (DialogResult.Yes == dialogResult)
|
||||
{
|
||||
while (0 != m_activeTransCount)
|
||||
{
|
||||
m_commandData.Application.ActiveDocument.EndTransaction();
|
||||
m_activeTransCount--;
|
||||
}
|
||||
}
|
||||
}
|
||||
this.DialogResult = DialogResult.OK;
|
||||
this.Close();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// If there are transactions, enable endButton and abortButton
|
||||
/// otherwise disable them.
|
||||
/// </summary>
|
||||
private void UpdateButtonsStatus()
|
||||
{
|
||||
endTransButton.Enabled = abortTransButton.Enabled = m_activeTransCount > 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// add node to tree view control
|
||||
/// </summary>
|
||||
/// <param name="type">indicate operation type</param>
|
||||
private void AddNode(OperationType type)
|
||||
{
|
||||
AddNode(type, null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// add node to tree view control
|
||||
/// </summary>
|
||||
/// <param name="type">indicate operation type</param>
|
||||
/// <param name="info">tree node text</param>
|
||||
private void AddNode(OperationType type, string info)
|
||||
{
|
||||
//add tree node according to operation type
|
||||
if (type == OperationType.BeginTransaction)
|
||||
{
|
||||
m_activeTransCount++;
|
||||
m_totalTransCount++;
|
||||
TreeNode childNode =
|
||||
new TreeNode("Transaction(" + m_totalTransCount.ToString() + ")");
|
||||
childNode.ForeColor = m_beginTransColor;
|
||||
m_parentNode.Nodes.Add(childNode);
|
||||
m_parentNode.Expand();
|
||||
m_parentNode = childNode;
|
||||
}
|
||||
else if (type == OperationType.EndTransaction)
|
||||
{
|
||||
m_activeTransCount--;
|
||||
UpdateTreeNode(m_parentNode, type);
|
||||
m_parentNode.Expand();
|
||||
//current transaction is over,so change m_parentNode to its parent
|
||||
m_parentNode = m_parentNode.Parent;
|
||||
|
||||
}
|
||||
else if (type == OperationType.AbortTransaction)
|
||||
{
|
||||
m_activeTransCount--;
|
||||
UpdateTreeNode(m_parentNode, type);
|
||||
m_parentNode.Expand();
|
||||
//current transaction is over,so change m_parentNode to its parent
|
||||
m_parentNode = m_parentNode.Parent;
|
||||
}
|
||||
else
|
||||
{
|
||||
string childNodeText = null;
|
||||
SystemColor childNodeColor;
|
||||
|
||||
//if variable "info" is null, use default value
|
||||
if (info == null)
|
||||
{
|
||||
childNodeText = "Operation";
|
||||
}
|
||||
else
|
||||
{
|
||||
childNodeText = info;
|
||||
}
|
||||
|
||||
//if m_activeTransCount is not zero, the operation creating wall,
|
||||
//moving wall or deleting wall must occur during a transaction
|
||||
if (m_activeTransCount == 0)
|
||||
{
|
||||
childNodeColor = m_normalColor;
|
||||
}
|
||||
else
|
||||
{
|
||||
childNodeColor = m_beginTransColor;
|
||||
}
|
||||
|
||||
TreeNode childNode = new TreeNode(childNodeText);
|
||||
childNode.ForeColor = childNodeColor;
|
||||
m_parentNode.Nodes.Add(childNode);
|
||||
m_parentNode.Expand();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Update the color of tree node
|
||||
/// </summary>
|
||||
/// <param name="parentNode">indicate child nodes of which will be updated</param>
|
||||
/// <param name="type">operation type</param>
|
||||
private void UpdateTreeNode(TreeNode parentNode, OperationType type)
|
||||
{
|
||||
if (type == OperationType.BeginTransaction)
|
||||
{
|
||||
UpdateTreeNode(parentNode, m_beginTransColor);
|
||||
}
|
||||
else if (type == OperationType.EndTransaction)
|
||||
{
|
||||
UpdateTreeNode(parentNode, m_endTransColor);
|
||||
}
|
||||
else if (type == OperationType.AbortTransaction)
|
||||
{
|
||||
UpdateTreeNode(parentNode, m_abortTransColor);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Update the color of tree node
|
||||
/// </summary>
|
||||
/// <param name="parentNode">indicate child nodes of which will be updated</param>
|
||||
/// <param name="color">Color to change</param>
|
||||
private void UpdateTreeNode(TreeNode parentNode, SystemColor color)
|
||||
{
|
||||
parentNode.ForeColor = color;
|
||||
foreach (TreeNode childNode in parentNode.Nodes)
|
||||
{
|
||||
UpdateTreeNode(childNode, color);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -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>
|
||||
Reference in New Issue
Block a user