mirror of
https://github.com/jeremytammik/RevitSdkSamples.git
synced 2026-09-07 04:16:23 +00:00
added Revit 2022 SDK minus except *rvt and *rfa
This commit is contained in:
@@ -0,0 +1,92 @@
|
||||
//
|
||||
// (C) Copyright 2003-2019 by Autodesk, Inc.
|
||||
//
|
||||
// Permission to use, copy, modify, and distribute this software in
|
||||
// object code form for any purpose and without fee is hereby granted,
|
||||
// provided that the above copyright notice appears in all copies and
|
||||
// that both that copyright notice and the limited warranty and
|
||||
// restricted rights notice below appear in all supporting
|
||||
// documentation.
|
||||
//
|
||||
// AUTODESK PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS.
|
||||
// AUTODESK SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF
|
||||
// MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE. AUTODESK, INC.
|
||||
// DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE
|
||||
// UNINTERRUPTED OR ERROR FREE.
|
||||
//
|
||||
// Use, duplication, or disclosure by the U.S. Government is subject to
|
||||
// restrictions set forth in FAR 52.227-19 (Commercial Computer
|
||||
// Software - Restricted Rights) and DFAR 252.227-7013(c)(1)(ii)
|
||||
// (Rights in Technical Data and Computer Software), as applicable.
|
||||
//
|
||||
|
||||
namespace Revit.SDK.Samples.ChangesMonitor.CS
|
||||
{
|
||||
partial class ChangesInformationForm
|
||||
{
|
||||
/// <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.changesdataGridView = new System.Windows.Forms.DataGridView();
|
||||
((System.ComponentModel.ISupportInitialize)(this.changesdataGridView)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// changesdataGridView
|
||||
//
|
||||
this.changesdataGridView.AllowUserToAddRows = false;
|
||||
this.changesdataGridView.AllowUserToDeleteRows = false;
|
||||
this.changesdataGridView.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
|
||||
this.changesdataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
this.changesdataGridView.Location = new System.Drawing.Point(-1, -2);
|
||||
this.changesdataGridView.Name = "changesdataGridView";
|
||||
this.changesdataGridView.ReadOnly = true;
|
||||
this.changesdataGridView.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect;
|
||||
this.changesdataGridView.Size = new System.Drawing.Size(665, 81);
|
||||
this.changesdataGridView.TabIndex = 0;
|
||||
this.changesdataGridView.RowsAdded += new System.Windows.Forms.DataGridViewRowsAddedEventHandler(this.changesdataGridView_RowsAdded);
|
||||
//
|
||||
// ChangesInformationForm
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(664, 77);
|
||||
this.Controls.Add(this.changesdataGridView);
|
||||
this.MaximizeBox = false;
|
||||
this.Name = "ChangesInformationForm";
|
||||
this.ShowIcon = false;
|
||||
this.ShowInTaskbar = false;
|
||||
this.Text = "Changes Information";
|
||||
this.Shown += new System.EventHandler(this.ChangesInfoForm_Shown);
|
||||
((System.ComponentModel.ISupportInitialize)(this.changesdataGridView)).EndInit();
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.DataGridView changesdataGridView;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
//
|
||||
// (C) Copyright 2003-2019 by Autodesk, Inc.
|
||||
//
|
||||
// Permission to use, copy, modify, and distribute this software in
|
||||
// object code form for any purpose and without fee is hereby granted,
|
||||
// provided that the above copyright notice appears in all copies and
|
||||
// that both that copyright notice and the limited warranty and
|
||||
// restricted rights notice below appear in all supporting
|
||||
// documentation.
|
||||
//
|
||||
// AUTODESK PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS.
|
||||
// AUTODESK SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF
|
||||
// MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE. AUTODESK, INC.
|
||||
// DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE
|
||||
// UNINTERRUPTED OR ERROR FREE.
|
||||
//
|
||||
// Use, duplication, or disclosure by the U.S. Government is subject to
|
||||
// restrictions set forth in FAR 52.227-19 (Commercial Computer
|
||||
// Software - Restricted Rights) and DFAR 252.227-7013(c)(1)(ii)
|
||||
// (Rights in Technical Data and Computer Software), as applicable.
|
||||
//
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace Revit.SDK.Samples.ChangesMonitor.CS
|
||||
{
|
||||
/// <summary>
|
||||
/// The UI to show the change history logs. This class is not the main one just a assistant
|
||||
/// in this sample. If you just want to learn how to use DocumentChanges event,
|
||||
/// please pay more attention to ExternalApplication class.
|
||||
/// </summary>
|
||||
public partial class ChangesInformationForm : Form
|
||||
{
|
||||
/// <summary>
|
||||
/// Default constructor.
|
||||
/// </summary>
|
||||
public ChangesInformationForm()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Constructor with one argument
|
||||
/// </summary>
|
||||
/// <param name="dataBuffer">prepare the informations which is shown in this UI</param>
|
||||
public ChangesInformationForm(DataTable dataBuffer)
|
||||
: this()
|
||||
{
|
||||
changesdataGridView.DataSource = dataBuffer;
|
||||
changesdataGridView.AutoGenerateColumns = false;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// windows shown event handler
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void ChangesInfoForm_Shown(object sender, EventArgs e)
|
||||
{
|
||||
// set window's display location
|
||||
int left = Screen.PrimaryScreen.WorkingArea.Right - this.Width - 5;
|
||||
int top = Screen.PrimaryScreen.WorkingArea.Bottom - this.Height;
|
||||
Point windowLocation = new Point(left, top);
|
||||
this.Location = windowLocation;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Scroll to last line when add new log lines
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void changesdataGridView_RowsAdded(object sender, DataGridViewRowsAddedEventArgs e)
|
||||
{
|
||||
changesdataGridView.CurrentCell = changesdataGridView.Rows[changesdataGridView.Rows.Count - 1].Cells[0];
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -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,21 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RevitAddIns>
|
||||
<AddIn Type="Application">
|
||||
<Name>External Tool</Name>
|
||||
<Assembly>ChangesMonitor.dll</Assembly>
|
||||
<ClientId>ebae9def-6cd3-456f-98a4-cfe06c362af5</ClientId>
|
||||
<FullClassName>Revit.SDK.Samples.ChangesMonitor.CS.ExternalApplication</FullClassName>
|
||||
<VendorId>ADSK</VendorId>
|
||||
<VendorDescription>Autodesk, www.autodesk.com</VendorDescription>
|
||||
</AddIn>
|
||||
<AddIn Type="Command">
|
||||
<Assembly>ChangesMonitor.dll</Assembly>
|
||||
<ClientId>152051df-aa75-463f-a722-b8b1bca5d88c</ClientId>
|
||||
<FullClassName>Revit.SDK.Samples.ChangesMonitor.CS.Command</FullClassName>
|
||||
<Text>ShowChangesInfoForm</Text>
|
||||
<Description>""</Description>
|
||||
<VisibilityMode>AlwaysVisible</VisibilityMode>
|
||||
<VendorId>ADSK</VendorId>
|
||||
<VendorDescription>Autodesk, www.autodesk.com</VendorDescription>
|
||||
</AddIn>
|
||||
</RevitAddIns>
|
||||
@@ -0,0 +1,282 @@
|
||||
//
|
||||
// (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.IO;
|
||||
using System.Data;
|
||||
using System.Text;
|
||||
using System.Reflection;
|
||||
using System.Diagnostics;
|
||||
using System.Collections.Generic;
|
||||
|
||||
using Autodesk.Revit.UI;
|
||||
using Autodesk.Revit.DB;
|
||||
using Autodesk.Revit.ApplicationServices;
|
||||
|
||||
namespace Revit.SDK.Samples.ChangesMonitor.CS
|
||||
{
|
||||
/// <summary>
|
||||
/// A class inherits IExternalApplication interface and provide an entry of the sample.
|
||||
/// It create a modeless dialog to track the changes.
|
||||
/// </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 ExternalApplication : IExternalApplication
|
||||
{
|
||||
#region Class Member Variables
|
||||
/// <summary>
|
||||
/// A controlled application used to register the DocumentChanged event. Because all trigger points
|
||||
/// in this sample come from UI, the event must be registered to ControlledApplication.
|
||||
/// If the trigger point is from API, user can register it to application
|
||||
/// which can retrieve from ExternalCommand.
|
||||
/// </summary>
|
||||
private static ControlledApplication m_CtrlApp;
|
||||
|
||||
/// <summary>
|
||||
/// data table for information windows.
|
||||
/// </summary>
|
||||
private static DataTable m_ChangesInfoTable;
|
||||
|
||||
/// <summary>
|
||||
/// The window is used to show changes' information.
|
||||
/// </summary>
|
||||
private static ChangesInformationForm m_InfoForm;
|
||||
#endregion
|
||||
|
||||
#region Class Static Property
|
||||
/// <summary>
|
||||
/// Property to get and set private member variables of changes log information.
|
||||
/// </summary>
|
||||
public static DataTable ChangesInfoTable
|
||||
{
|
||||
get { return m_ChangesInfoTable; }
|
||||
set { m_ChangesInfoTable = value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Property to get and set private member variables of info form.
|
||||
/// </summary>
|
||||
public static ChangesInformationForm InfoForm
|
||||
{
|
||||
get { return ExternalApplication.m_InfoForm; }
|
||||
set { ExternalApplication.m_InfoForm = value; }
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region IExternalApplication Members
|
||||
/// <summary>
|
||||
/// Implement this method to implement the external application which should be called when
|
||||
/// Revit starts before a file or default template is actually loaded.
|
||||
/// </summary>
|
||||
/// <param name="application">An object that is passed to the external application
|
||||
/// which contains the controlled application.</param>
|
||||
/// <returns>Return the status of the external application.
|
||||
/// A result of Succeeded means that the external application successfully started.
|
||||
/// Cancelled can be used to signify that the user cancelled the external operation at
|
||||
/// some point.
|
||||
/// If false is returned then Revit should inform the user that the external application
|
||||
/// failed to load and the release the internal reference.</returns>
|
||||
public Result OnStartup(UIControlledApplication application)
|
||||
{
|
||||
// initialize member variables.
|
||||
m_CtrlApp = application.ControlledApplication;
|
||||
m_ChangesInfoTable = CreateChangeInfoTable();
|
||||
m_InfoForm = new ChangesInformationForm(ChangesInfoTable);
|
||||
|
||||
// register the DocumentChanged event
|
||||
m_CtrlApp.DocumentChanged += new EventHandler<Autodesk.Revit.DB.Events.DocumentChangedEventArgs>(CtrlApp_DocumentChanged);
|
||||
|
||||
// show dialog
|
||||
m_InfoForm.Show();
|
||||
|
||||
return Result.Succeeded;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Implement this method to implement the external application which should be called when
|
||||
/// Revit is about to exit,Any documents must have been closed before this method is called.
|
||||
/// </summary>
|
||||
/// <param name="application">An object that is passed to the external application
|
||||
/// which contains the controlled application.</param>
|
||||
/// <returns>Return the status of the external application.
|
||||
/// A result of Succeeded means that the external application successfully shutdown.
|
||||
/// Cancelled can be used to signify that the user cancelled the external operation at
|
||||
/// some point.
|
||||
/// If false is returned then the Revit user should be warned of the failure of the external
|
||||
/// application to shut down correctly.</returns>
|
||||
public Result OnShutdown(UIControlledApplication application)
|
||||
{
|
||||
m_CtrlApp.DocumentChanged -= CtrlApp_DocumentChanged;
|
||||
m_InfoForm = null;
|
||||
m_ChangesInfoTable = null;
|
||||
return Result.Succeeded;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Event handler
|
||||
/// <summary>
|
||||
/// This method is the event handler, which will dump the change information to tracking dialog
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
void CtrlApp_DocumentChanged(object sender, Autodesk.Revit.DB.Events.DocumentChangedEventArgs e)
|
||||
{
|
||||
// get the current document.
|
||||
Document doc = e.GetDocument();
|
||||
|
||||
// dump the element information
|
||||
ICollection<ElementId> addedElem = e.GetAddedElementIds();
|
||||
foreach (ElementId id in addedElem)
|
||||
{
|
||||
AddChangeInfoRow(id, doc, "Added");
|
||||
}
|
||||
|
||||
ICollection<ElementId> deletedElem = e.GetDeletedElementIds();
|
||||
foreach (ElementId id in deletedElem)
|
||||
{
|
||||
AddChangeInfoRow(id, doc, "Deleted");
|
||||
}
|
||||
|
||||
ICollection<ElementId> modifiedElem = e.GetModifiedElementIds();
|
||||
foreach (ElementId id in modifiedElem)
|
||||
{
|
||||
AddChangeInfoRow(id, doc, "Modified");
|
||||
}
|
||||
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Class Methods
|
||||
/// <summary>
|
||||
/// This method is used to retrieve the changed element and add row to data table.
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <param name="doc"></param>
|
||||
/// <param name="changeType"></param>
|
||||
private void AddChangeInfoRow(ElementId id, Document doc, string changeType)
|
||||
{
|
||||
// retrieve the changed element
|
||||
Element elem = doc.GetElement(id);
|
||||
|
||||
DataRow newRow = m_ChangesInfoTable.NewRow();
|
||||
|
||||
// set the relative information of this event into the table.
|
||||
if (elem == null)
|
||||
{
|
||||
// this branch is for deleted element due to the deleted element cannot be retrieve from the document.
|
||||
newRow["ChangeType"] = changeType;
|
||||
newRow["Id"] = id.IntegerValue.ToString();
|
||||
newRow["Name"] = "";
|
||||
newRow["Category"] = "";
|
||||
newRow["Document"] = "";
|
||||
}
|
||||
else
|
||||
{
|
||||
newRow["ChangeType"] = changeType;
|
||||
newRow["Id"] = id.IntegerValue.ToString();
|
||||
newRow["Name"] = elem.Name;
|
||||
newRow["Category"] = elem.Category.Name;
|
||||
newRow["Document"] = doc.Title;
|
||||
}
|
||||
|
||||
m_ChangesInfoTable.Rows.Add(newRow);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Generate a data table with five columns for display in window
|
||||
/// </summary>
|
||||
/// <returns>The DataTable to be displayed in window</returns>
|
||||
private DataTable CreateChangeInfoTable()
|
||||
{
|
||||
// create a new dataTable
|
||||
DataTable changesInfoTable = new DataTable("ChangesInfoTable");
|
||||
|
||||
// Create a "ChangeType" column. It will be "Added", "Deleted" and "Modified".
|
||||
DataColumn styleColumn = new DataColumn("ChangeType", typeof(System.String));
|
||||
styleColumn.Caption = "ChangeType";
|
||||
changesInfoTable.Columns.Add(styleColumn);
|
||||
|
||||
// Create a "Id" column. It will be the Element ID
|
||||
DataColumn idColum = new DataColumn("Id", typeof(System.String));
|
||||
idColum.Caption = "Id";
|
||||
changesInfoTable.Columns.Add(idColum);
|
||||
|
||||
// Create a "Name" column. It will be the Element Name
|
||||
DataColumn nameColum = new DataColumn("Name", typeof(System.String));
|
||||
nameColum.Caption = "Name";
|
||||
changesInfoTable.Columns.Add(nameColum);
|
||||
|
||||
// Create a "Category" column. It will be the Category Name of the element.
|
||||
DataColumn categoryColum = new DataColumn("Category", typeof(System.String));
|
||||
categoryColum.Caption = "Category";
|
||||
changesInfoTable.Columns.Add(categoryColum);
|
||||
|
||||
// Create a "Document" column. It will be the document which own the changed element.
|
||||
DataColumn docColum = new DataColumn("Document", typeof(System.String));
|
||||
docColum.Caption = "Document";
|
||||
changesInfoTable.Columns.Add(docColum);
|
||||
|
||||
// return this data table
|
||||
return changesInfoTable;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This class inherits IExternalCommand interface and used to retrieve the dialog again.
|
||||
/// </summary>
|
||||
[Autodesk.Revit.Attributes.Transaction(Autodesk.Revit.Attributes.TransactionMode.Manual)]
|
||||
[Autodesk.Revit.Attributes.Regeneration(Autodesk.Revit.Attributes.RegenerationOption.Manual)]
|
||||
public class Command : IExternalCommand
|
||||
{
|
||||
#region IExternalCommand Members
|
||||
/// <summary>
|
||||
/// Implement this method as an external command for Revit.
|
||||
/// </summary>
|
||||
/// <param name="commandData">An object that is passed to the external application
|
||||
/// which contains data related to the command,
|
||||
/// such as the application object and active view.</param>
|
||||
/// <param name="message">A message that can be set by the external application
|
||||
/// which will be displayed if a failure or cancellation is returned by
|
||||
/// the external command.</param>
|
||||
/// <param name="elements">A set of elements to which the external application
|
||||
/// can add elements that are to be highlighted in case of failure or cancellation.</param>
|
||||
/// <returns>Return the status of the external command.
|
||||
/// A result of Succeeded means that the API external method functioned as expected.
|
||||
/// Cancelled can be used to signify that the user cancelled the external operation
|
||||
/// at some point. Failure should be returned if the application is unable to proceed with
|
||||
/// the operation.</returns>
|
||||
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
|
||||
{
|
||||
if (ExternalApplication.InfoForm == null)
|
||||
{
|
||||
ExternalApplication.InfoForm = new ChangesInformationForm(ExternalApplication.ChangesInfoTable);
|
||||
}
|
||||
ExternalApplication.InfoForm.Show();
|
||||
|
||||
return Result.Succeeded;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,103 @@
|
||||
<?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>{1C6B9634-D463-43C1-A8C5-B94AE7615384}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>ChangesMonitor</RootNamespace>
|
||||
<AssemblyName>ChangesMonitor</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<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.Drawing" />
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
<Reference Include="System.Xml.Linq">
|
||||
<RequiredTargetFramework>3.5</RequiredTargetFramework>
|
||||
</Reference>
|
||||
<Reference Include="System.Data.DataSetExtensions">
|
||||
<RequiredTargetFramework>3.5</RequiredTargetFramework>
|
||||
</Reference>
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="ChangesInfoForm.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="ChangesInfoForm.Designer.cs">
|
||||
<DependentUpon>ChangesInfoForm.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="ChangesMonitor.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="ChangesInfoForm.resx">
|
||||
<DependentUpon>ChangesInfoForm.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
<Import Project="$(SolutionDir)VSProps\SDKSamples.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
<PropertyGroup>
|
||||
<PostBuildEvent>set FILEFORSAMPLEREG="$(SolutionDir)..\..\..\..\Regression\API\SDKSamples\UpdateSampleDllForRegression.pl"
|
||||
if exist %25FILEFORSAMPLEREG%25 perl %25FILEFORSAMPLEREG%25 $(ProjectExt) "$(ProjectPath)" "$(TargetPath)" "$(SolutionDir)"</PostBuildEvent>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<ResolveAssemblyWarnOrErrorOnTargetArchitectureMismatch>None</ResolveAssemblyWarnOrErrorOnTargetArchitectureMismatch>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
@@ -0,0 +1,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("ChangesMonitor")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("Autodesk, Inc.")]
|
||||
[assembly: AssemblyProduct("ChangesMonitor")]
|
||||
[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("e1143c13-cca0-4cfa-bba5-70aacb7d4dde")]
|
||||
|
||||
// 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")]
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user