mirror of
https://github.com/jeremytammik/RevitSdkSamples.git
synced 2026-08-29 08:12:56 +00:00
added Revit 2022 SDK minus except *rvt and *rfa
This commit is contained in:
@@ -0,0 +1,183 @@
|
||||
//
|
||||
// (C) Copyright 2003-2019 by Autodesk, Inc.
|
||||
//
|
||||
// Permission to use, copy, modify, and distribute this software in
|
||||
// object code form for any purpose and without fee is hereby granted,
|
||||
// provided that the above copyright notice appears in all copies and
|
||||
// that both that copyright notice and the limited warranty and
|
||||
// restricted rights notice below appear in all supporting
|
||||
// documentation.
|
||||
//
|
||||
// AUTODESK PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS.
|
||||
// AUTODESK SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF
|
||||
// MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE. AUTODESK, INC.
|
||||
// DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE
|
||||
// UNINTERRUPTED OR ERROR FREE.
|
||||
//
|
||||
// Use, duplication, or disclosure by the U.S. Government is subject to
|
||||
// restrictions set forth in FAR 52.227-19 (Commercial Computer
|
||||
// Software - Restricted Rights) and DFAR 252.227-7013(c)(1)(ii)
|
||||
// (Rights in Technical Data and Computer Software), as applicable.
|
||||
//
|
||||
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
using Autodesk.Revit;
|
||||
using Autodesk.Revit.DB;
|
||||
using Autodesk.Revit.UI;
|
||||
|
||||
namespace Revit.SDK.Samples.LevelsProperty.CS
|
||||
{
|
||||
/// <summary>
|
||||
/// Implements the Revit add-in interface IExternalCommand
|
||||
/// </summary>
|
||||
[Autodesk.Revit.Attributes.Transaction(Autodesk.Revit.Attributes.TransactionMode.Manual)]
|
||||
[Autodesk.Revit.Attributes.Regeneration(Autodesk.Revit.Attributes.RegenerationOption.Manual)]
|
||||
[Autodesk.Revit.Attributes.Journaling(Autodesk.Revit.Attributes.JournalingMode.NoCommandData)]
|
||||
public class Command : IExternalCommand
|
||||
{
|
||||
#region GetDatum
|
||||
|
||||
/// <summary>
|
||||
/// Implement this method as an external command for Revit.
|
||||
/// </summary>
|
||||
/// <param name="revit">An object that is passed to the external application
|
||||
/// which contains data related to the command,
|
||||
/// such as the application object and active view.</param>
|
||||
/// <param name="message">A message that can be set by the external application
|
||||
/// which will be displayed if a failure or cancellation is returned by
|
||||
/// the external command.</param>
|
||||
/// <param name="elements">A set of elements to which the external application
|
||||
/// can add elements that are to be highlighted in case of failure or cancellation.</param>
|
||||
/// <returns>Return the status of the external command.
|
||||
/// A result of Succeeded means that the API external method functioned as expected.
|
||||
/// Cancelled can be used to signify that the user cancelled the external operation
|
||||
/// at some point. Failure should be returned if the application is unable to proceed with
|
||||
/// the operation.</returns>
|
||||
public Autodesk.Revit.UI.Result Execute(ExternalCommandData revit, ref String message, Autodesk.Revit.DB.ElementSet elements)
|
||||
{
|
||||
m_revit = revit;
|
||||
UnitTypeId = m_revit.Application.ActiveUIDocument.Document.GetUnits().GetFormatOptions(Autodesk.Revit.DB.SpecTypeId.Length).GetUnitTypeId();
|
||||
Transaction documentTransaction = new Transaction(revit.Application.ActiveUIDocument.Document, "Document");
|
||||
documentTransaction.Start();
|
||||
try
|
||||
{
|
||||
//Get every level by iterating through all elements
|
||||
systemLevelsDatum = new List<LevelsDataSource>();
|
||||
FilteredElementCollector collector = new FilteredElementCollector(m_revit.Application.ActiveUIDocument.Document);
|
||||
ICollection<Element> collection = collector.OfClass(typeof(Level)).ToElements();
|
||||
foreach (Element element in collection)
|
||||
{
|
||||
Level systemLevel = element as Level;
|
||||
LevelsDataSource levelsDataSourceRow = new LevelsDataSource();
|
||||
|
||||
levelsDataSourceRow.LevelIDValue = systemLevel.Id.IntegerValue;
|
||||
levelsDataSourceRow.Name = systemLevel.Name;
|
||||
|
||||
Parameter elevationPara = systemLevel.get_Parameter(BuiltInParameter.LEVEL_ELEV);
|
||||
|
||||
double temValue = Unit.CovertFromAPI(UnitTypeId, elevationPara.AsDouble());
|
||||
double temValue2 = double.Parse(temValue.ToString("#.0"));
|
||||
|
||||
levelsDataSourceRow.Elevation = temValue2;
|
||||
|
||||
systemLevelsDatum.Add(levelsDataSourceRow);
|
||||
}
|
||||
|
||||
using (LevelsForm displayForm = new LevelsForm(this))
|
||||
{
|
||||
displayForm.ShowDialog();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
message = ex.Message;
|
||||
documentTransaction.RollBack();
|
||||
return Autodesk.Revit.UI.Result.Failed;
|
||||
}
|
||||
documentTransaction.Commit();
|
||||
return Autodesk.Revit.UI.Result.Succeeded;
|
||||
}
|
||||
|
||||
ExternalCommandData m_revit;
|
||||
public Autodesk.Revit.DB.ForgeTypeId UnitTypeId;
|
||||
System.Collections.Generic.List<LevelsDataSource> systemLevelsDatum;
|
||||
/// <summary>
|
||||
/// Store all levels' datum in system
|
||||
/// </summary>
|
||||
public System.Collections.Generic.List<LevelsDataSource> SystemLevelsDatum
|
||||
{
|
||||
get
|
||||
{
|
||||
return systemLevelsDatum;
|
||||
}
|
||||
set
|
||||
{
|
||||
systemLevelsDatum = value;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region SetData
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Set Level
|
||||
/// </summary>
|
||||
/// <param name="levelIDValue">Pass a Level's ID value</param>
|
||||
/// <param name="levelName">Pass a Level's Name</param>
|
||||
/// <param name="levelElevation">Pass a Level's Elevation</param>
|
||||
/// <returns>True if succeed, else return false</returns>
|
||||
public bool SetLevel(int levelIDValue, String levelName, double levelElevation)
|
||||
{
|
||||
try
|
||||
{
|
||||
Autodesk.Revit.DB.ElementId levelID = new Autodesk.Revit.DB.ElementId(levelIDValue);
|
||||
Level systemLevel = m_revit.Application.ActiveUIDocument.Document.GetElement(levelID) as Level;
|
||||
|
||||
Parameter elevationPara = systemLevel.get_Parameter(BuiltInParameter.LEVEL_ELEV);
|
||||
elevationPara.SetValueString(levelElevation.ToString());
|
||||
systemLevel.Name = levelName;
|
||||
|
||||
return true;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region CreateLevel
|
||||
/// <summary>
|
||||
/// Create a level
|
||||
/// </summary>
|
||||
/// <param name="levelName">Pass a Level's Name</param>
|
||||
/// <param name="levelElevation">Pass a Level's Elevation</param>
|
||||
public void CreateLevel(String levelName, double levelElevation)
|
||||
{
|
||||
Level newLevel = Level.Create(m_revit.Application.ActiveUIDocument.Document, levelElevation);
|
||||
Parameter elevationPara = newLevel.get_Parameter(BuiltInParameter.LEVEL_ELEV);
|
||||
elevationPara.SetValueString(levelElevation.ToString());
|
||||
|
||||
newLevel.Name = levelName;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region DeleteLevel
|
||||
/// <summary>
|
||||
/// Delete a Level.
|
||||
/// </summary>
|
||||
/// <param name="IDValueOfLevel">A Level's ID value</param>
|
||||
public void DeleteLevel(int IDValueOfLevel)
|
||||
{
|
||||
Autodesk.Revit.DB.ElementId IDOfLevel = new ElementId(IDValueOfLevel);
|
||||
|
||||
m_revit.Application.ActiveUIDocument.Document.Delete(IDOfLevel);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -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.Text;
|
||||
|
||||
namespace Revit.SDK.Samples.LevelsProperty.CS
|
||||
{
|
||||
/// <summary>
|
||||
/// Data source used to store a Level
|
||||
/// </summary>
|
||||
public class LevelsDataSource
|
||||
{
|
||||
String m_levelName;
|
||||
double m_levelElevation;
|
||||
int m_levelIDValue;
|
||||
|
||||
/// <summary>
|
||||
/// First column used to store Level's Name
|
||||
/// </summary>
|
||||
public String Name
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_levelName;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_levelName = value;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Second column to store Level's Elevation
|
||||
/// </summary>
|
||||
public double Elevation
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_levelElevation;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_levelElevation = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Record Level's ID
|
||||
/// </summary>
|
||||
public int LevelIDValue
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_levelIDValue;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_levelIDValue = value;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
+165
@@ -0,0 +1,165 @@
|
||||
//
|
||||
// (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.LevelsProperty.CS
|
||||
{
|
||||
/// <summary>
|
||||
/// new level form
|
||||
/// </summary>
|
||||
partial class LevelsForm
|
||||
{
|
||||
/// <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.components = new System.ComponentModel.Container();
|
||||
this.levelsDataGridView = new System.Windows.Forms.DataGridView();
|
||||
this.okButton = new System.Windows.Forms.Button();
|
||||
this.cancelButton = new System.Windows.Forms.Button();
|
||||
this.deleteButton = new System.Windows.Forms.Button();
|
||||
this.addButton = new System.Windows.Forms.Button();
|
||||
this.bindingSource1 = new System.Windows.Forms.BindingSource(this.components);
|
||||
((System.ComponentModel.ISupportInitialize)(this.levelsDataGridView)).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.bindingSource1)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// levelsDataGridView
|
||||
//
|
||||
this.levelsDataGridView.AllowUserToAddRows = false;
|
||||
this.levelsDataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
this.levelsDataGridView.Location = new System.Drawing.Point(16, 15);
|
||||
this.levelsDataGridView.Margin = new System.Windows.Forms.Padding(4, 4, 4, 7);
|
||||
this.levelsDataGridView.Name = "levelsDataGridView";
|
||||
this.levelsDataGridView.RowTemplate.Height = 24;
|
||||
this.levelsDataGridView.Size = new System.Drawing.Size(550, 445);
|
||||
this.levelsDataGridView.TabIndex = 0;
|
||||
this.levelsDataGridView.CellValueChanged += new System.Windows.Forms.DataGridViewCellEventHandler(this.levelsDataGridView_CellValueChanged);
|
||||
this.levelsDataGridView.CellValidating += new System.Windows.Forms.DataGridViewCellValidatingEventHandler(this.levelsDataGridView_CellValidating);
|
||||
this.levelsDataGridView.DataError += new System.Windows.Forms.DataGridViewDataErrorEventHandler(this.levelsDataGridView_DataError);
|
||||
//
|
||||
// okButton
|
||||
//
|
||||
this.okButton.DialogResult = System.Windows.Forms.DialogResult.OK;
|
||||
this.okButton.Location = new System.Drawing.Point(382, 512);
|
||||
this.okButton.Margin = new System.Windows.Forms.Padding(4, 7, 4, 4);
|
||||
this.okButton.Name = "okButton";
|
||||
this.okButton.Size = new System.Drawing.Size(88, 28);
|
||||
this.okButton.TabIndex = 1;
|
||||
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(478, 512);
|
||||
this.cancelButton.Margin = new System.Windows.Forms.Padding(4, 4, 7, 4);
|
||||
this.cancelButton.Name = "cancelButton";
|
||||
this.cancelButton.Size = new System.Drawing.Size(88, 28);
|
||||
this.cancelButton.TabIndex = 2;
|
||||
this.cancelButton.Text = "&Cancel";
|
||||
this.cancelButton.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// deleteButton
|
||||
//
|
||||
this.deleteButton.Image = global::Revit.SDK.Samples.LevelsProperty.CS.Properties.Resources.delete;
|
||||
this.deleteButton.Location = new System.Drawing.Point(51, 473);
|
||||
this.deleteButton.Margin = new System.Windows.Forms.Padding(4, 6, 4, 4);
|
||||
this.deleteButton.Name = "deleteButton";
|
||||
this.deleteButton.Size = new System.Drawing.Size(30, 28);
|
||||
this.deleteButton.TabIndex = 4;
|
||||
this.deleteButton.UseVisualStyleBackColor = true;
|
||||
this.deleteButton.Click += new System.EventHandler(this.deleteButton_Click);
|
||||
//
|
||||
// addButton
|
||||
//
|
||||
this.addButton.Image = global::Revit.SDK.Samples.LevelsProperty.CS.Properties.Resources._new;
|
||||
this.addButton.Location = new System.Drawing.Point(13, 473);
|
||||
this.addButton.Margin = new System.Windows.Forms.Padding(4, 6, 4, 4);
|
||||
this.addButton.Name = "addButton";
|
||||
this.addButton.Size = new System.Drawing.Size(30, 28);
|
||||
this.addButton.TabIndex = 3;
|
||||
this.addButton.UseVisualStyleBackColor = true;
|
||||
this.addButton.Click += new System.EventHandler(this.addButton_Click);
|
||||
//
|
||||
// LevelsForm
|
||||
//
|
||||
this.AcceptButton = this.okButton;
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.CancelButton = this.cancelButton;
|
||||
this.ClientSize = new System.Drawing.Size(579, 553);
|
||||
this.Controls.Add(this.deleteButton);
|
||||
this.Controls.Add(this.addButton);
|
||||
this.Controls.Add(this.cancelButton);
|
||||
this.Controls.Add(this.okButton);
|
||||
this.Controls.Add(this.levelsDataGridView);
|
||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
|
||||
this.Margin = new System.Windows.Forms.Padding(4);
|
||||
this.MaximizeBox = false;
|
||||
this.MinimizeBox = false;
|
||||
this.Name = "LevelsForm";
|
||||
this.ShowInTaskbar = false;
|
||||
this.Text = "Levels Property";
|
||||
((System.ComponentModel.ISupportInitialize)(this.levelsDataGridView)).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.bindingSource1)).EndInit();
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.DataGridView levelsDataGridView;
|
||||
private System.Windows.Forms.BindingSource bindingSource1;
|
||||
private System.Windows.Forms.Button okButton;
|
||||
private System.Windows.Forms.Button cancelButton;
|
||||
private System.Windows.Forms.Button addButton;
|
||||
private System.Windows.Forms.Button deleteButton;
|
||||
|
||||
//The following code is added by programmer.
|
||||
private System.Windows.Forms.DataGridViewTextBoxColumn LevelName;
|
||||
private System.Windows.Forms.DataGridViewTextBoxColumn LevelElevation;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,323 @@
|
||||
//
|
||||
// (C) Copyright 2003-2019 by Autodesk, Inc.
|
||||
//
|
||||
// Permission to use, copy, modify, and distribute this software in
|
||||
// object code form for any purpose and without fee is hereby granted,
|
||||
// provided that the above copyright notice appears in all copies and
|
||||
// that both that copyright notice and the limited warranty and
|
||||
// restricted rights notice below appear in all supporting
|
||||
// documentation.
|
||||
//
|
||||
// AUTODESK PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS.
|
||||
// AUTODESK SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF
|
||||
// MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE. AUTODESK, INC.
|
||||
// DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE
|
||||
// UNINTERRUPTED OR ERROR FREE.
|
||||
//
|
||||
// Use, duplication, or disclosure by the U.S. Government is subject to
|
||||
// restrictions set forth in FAR 52.227-19 (Commercial Computer
|
||||
// Software - Restricted Rights) and DFAR 252.227-7013(c)(1)(ii)
|
||||
// (Rights in Technical Data and Computer Software), as applicable.
|
||||
//
|
||||
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
|
||||
using Autodesk.Revit.UI;
|
||||
|
||||
namespace Revit.SDK.Samples.LevelsProperty.CS
|
||||
{
|
||||
/// <summary>
|
||||
/// form for new levels
|
||||
/// </summary>
|
||||
public partial class LevelsForm : System.Windows.Forms.Form
|
||||
{
|
||||
/// <summary>
|
||||
/// form for new levels
|
||||
/// </summary>
|
||||
public LevelsForm()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
#region Constructor
|
||||
/// <summary>
|
||||
/// The constructor is used to initialize some object.
|
||||
/// </summary>
|
||||
/// <param name="opt">Used to get the Command class's object.</param>
|
||||
public LevelsForm(Command opt)
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
m_objectReference = opt;
|
||||
|
||||
//Set control on UI
|
||||
LevelName = new DataGridViewTextBoxColumn();
|
||||
LevelName.HeaderText = "Name";
|
||||
LevelName.Width = 142;
|
||||
|
||||
LevelElevation = new DataGridViewTextBoxColumn();
|
||||
LevelElevation.HeaderText = "Elevation";
|
||||
LevelElevation.Width = 142;
|
||||
|
||||
levelsDataGridView.Columns.AddRange(new DataGridViewColumn[] { LevelName, LevelElevation });
|
||||
|
||||
bindingSource1.DataSource = typeof(Revit.SDK.Samples.LevelsProperty.CS.LevelsDataSource);
|
||||
//Must place below code on the code "dataGridView1.DataSource = bindingSource1"
|
||||
levelsDataGridView.AutoGenerateColumns = false;
|
||||
levelsDataGridView.DataSource = bindingSource1;
|
||||
LevelName.DataPropertyName = "Name";
|
||||
LevelElevation.DataPropertyName = "Elevation";
|
||||
|
||||
//pass datum to BindingSource
|
||||
bindingSource1.DataSource = m_objectReference.SystemLevelsDatum;
|
||||
|
||||
//Record system levels' total
|
||||
m_systemLevelsTotal = m_objectReference.SystemLevelsDatum.Count;
|
||||
|
||||
//Record changed items
|
||||
m_changedItemsFlag = new int[m_systemLevelsTotal];
|
||||
|
||||
//Record deleted items
|
||||
m_deleteExistLevelIDValue = new int[m_systemLevelsTotal];
|
||||
m_deleteExistLevelTotal = 0;
|
||||
}
|
||||
|
||||
//Class Command's object reference
|
||||
Command m_objectReference;
|
||||
#endregion
|
||||
|
||||
#region AddItem
|
||||
/// <summary>
|
||||
/// Used to a new item in the dataGridView control.
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void addButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
System.String newLevelName;
|
||||
double newLevelElevation;
|
||||
|
||||
//If it exists some Levels on Revit,
|
||||
//the added item's Name and Elevation uses last a Level's Name and Elevation.
|
||||
//Otherwise it uses a default data.
|
||||
if (bindingSource1.Count > 0)
|
||||
{
|
||||
bindingSource1.MoveLast();
|
||||
LevelsDataSource lastItem = bindingSource1.Current as LevelsDataSource;
|
||||
|
||||
System.String lastLevelName = lastItem.Name;
|
||||
double lastLevelElevation = lastItem.Elevation;
|
||||
newLevelName = lastLevelName + "'";
|
||||
newLevelElevation = lastLevelElevation + Unit.CovertFromAPI(m_objectReference.UnitTypeId, 10);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
newLevelName = "Level" + " " + "1";
|
||||
newLevelElevation = 0;
|
||||
}
|
||||
|
||||
|
||||
LevelsDataSource newLevel = new LevelsDataSource();
|
||||
newLevel.Name = newLevelName;
|
||||
newLevel.Elevation = newLevelElevation;
|
||||
|
||||
bindingSource1.Add(newLevel);
|
||||
}
|
||||
|
||||
//Record system levels' total
|
||||
int m_systemLevelsTotal;
|
||||
#endregion
|
||||
|
||||
#region RemoveItem
|
||||
/// <summary>
|
||||
/// Used to delete a item.
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void deleteButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (1 == levelsDataGridView.RowCount)
|
||||
{
|
||||
TaskDialog.Show("Revit", "Deleting the only open view in the project is not allowed.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (bindingSource1.Position > m_systemLevelsTotal - 1)
|
||||
{
|
||||
bindingSource1.RemoveCurrent();
|
||||
return;
|
||||
}
|
||||
|
||||
if (bindingSource1.Position <= m_systemLevelsTotal - 1 && bindingSource1.Position >= 0)
|
||||
{
|
||||
LevelsDataSource aRow = bindingSource1.Current as LevelsDataSource;
|
||||
m_deleteExistLevelIDValue[m_deleteExistLevelTotal] = aRow.LevelIDValue;
|
||||
m_deleteExistLevelTotal++;
|
||||
|
||||
bindingSource1.RemoveCurrent();
|
||||
|
||||
m_systemLevelsTotal = m_systemLevelsTotal - 1;
|
||||
|
||||
int[] temChangedItemsFlag = new int[m_systemLevelsTotal];
|
||||
for (int i = 0, j = 0; i < m_systemLevelsTotal; i++, j++)
|
||||
{
|
||||
if (bindingSource1.Position == i)
|
||||
{
|
||||
j++;
|
||||
}
|
||||
temChangedItemsFlag[i] = m_changedItemsFlag[j];
|
||||
}
|
||||
m_changedItemsFlag = temChangedItemsFlag;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (bindingSource1.Position < 0)
|
||||
{
|
||||
Autodesk.Revit.UI.TaskDialog.Show("Revit", "No have Level.");
|
||||
}
|
||||
}
|
||||
|
||||
int[] m_deleteExistLevelIDValue;
|
||||
int m_deleteExistLevelTotal;
|
||||
#endregion
|
||||
|
||||
#region CheckAndRecord
|
||||
/// <summary>
|
||||
/// Judge if the inputted Name is unique.
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void levelsDataGridView_CellValidating(object sender, DataGridViewCellValidatingEventArgs e)
|
||||
{
|
||||
if (0 == levelsDataGridView.CurrentCell.ColumnIndex)
|
||||
{
|
||||
System.String newName = e.FormattedValue as System.String;
|
||||
|
||||
char[] newNameArray = new char[newName.Length];
|
||||
newNameArray = newName.ToCharArray();
|
||||
for (int i = 0; i < newName.Length; ++i)
|
||||
{
|
||||
if ('\\' == newNameArray[i] || ':' == newNameArray[i] || '{' == newNameArray[i] ||
|
||||
'}' == newNameArray[i] || '[' == newNameArray[i] || ']' == newNameArray[i] ||
|
||||
'|' == newNameArray[i] || ';' == newNameArray[i] || '<' == newNameArray[i] ||
|
||||
'>' == newNameArray[i] || '?' == newNameArray[i] || '`' == newNameArray[i] ||
|
||||
'~' == newNameArray[i])
|
||||
{
|
||||
TaskDialog.Show("Revit", "Name cannot contain any of the following characters:\r\n\\ "
|
||||
+ ": { } [ ] | ; < > ? ` ~ \r\nor any of the non-printable characters.");
|
||||
|
||||
e.Cancel = true;
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
System.String oldName = levelsDataGridView.CurrentCell.FormattedValue as System.String;
|
||||
if (newName != oldName)
|
||||
{
|
||||
for (int i = 0; i < m_objectReference.SystemLevelsDatum.Count; i++)
|
||||
{
|
||||
if (m_objectReference.SystemLevelsDatum[i].Name == newName)
|
||||
{
|
||||
TaskDialog.Show("Revit", "The name entered is already in use. Enter a unique name.");
|
||||
e.Cancel = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Judge if the inputted Elevation is valid.
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void levelsDataGridView_DataError(object sender, DataGridViewDataErrorEventArgs e)
|
||||
{
|
||||
Autodesk.Revit.UI.TaskDialog.Show("Revit", e.Exception.Message);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Record the changed Item.
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void levelsDataGridView_CellValueChanged(object sender, DataGridViewCellEventArgs e)
|
||||
{
|
||||
if (bindingSource1.Position < m_systemLevelsTotal)
|
||||
{
|
||||
m_systemLevelChangedFlag = 1;
|
||||
m_changedItemsFlag[bindingSource1.Position] = 1;
|
||||
}
|
||||
}
|
||||
|
||||
//Record changed item
|
||||
int[] m_changedItemsFlag;
|
||||
int m_systemLevelChangedFlag = 0;
|
||||
#endregion
|
||||
|
||||
#region okButton
|
||||
/// <summary>
|
||||
/// Used to make setting apply to the model.
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void okButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
//Delete existed Levels
|
||||
for (int i = 0; i < m_deleteExistLevelTotal; i++)
|
||||
{
|
||||
m_objectReference.DeleteLevel(m_deleteExistLevelIDValue[i]);
|
||||
}
|
||||
|
||||
List<LevelsDataSource> tempLevels = new List<LevelsDataSource>();
|
||||
|
||||
//Set all changed Levels' name and elevation
|
||||
if (1 == m_systemLevelChangedFlag)
|
||||
{
|
||||
for (int i = 0; i < m_changedItemsFlag.LongLength; i++)
|
||||
{
|
||||
if (1 == m_changedItemsFlag[i])
|
||||
{
|
||||
bindingSource1.Position = i;
|
||||
LevelsDataSource changeItem = bindingSource1.Current as LevelsDataSource;
|
||||
|
||||
if (false == m_objectReference.SetLevel(changeItem.LevelIDValue, changeItem.Name, changeItem.Elevation))
|
||||
{
|
||||
changeItem.Name = "TempName" + changeItem.Name;
|
||||
tempLevels.Add(changeItem);
|
||||
m_objectReference.SetLevel(changeItem.LevelIDValue, changeItem.Name, changeItem.Elevation);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach (LevelsDataSource item in tempLevels)
|
||||
{
|
||||
item.Name = item.Name.Remove(0, 8); // Remove the "TempName" string
|
||||
m_objectReference.SetLevel(item.LevelIDValue, item.Name, item.Elevation);
|
||||
}
|
||||
|
||||
//Create new Levels
|
||||
for (int i = m_systemLevelsTotal; i < bindingSource1.Count; i++)
|
||||
{
|
||||
bindingSource1.Position = i;
|
||||
LevelsDataSource newItem = bindingSource1.Current as LevelsDataSource;
|
||||
m_objectReference.CreateLevel(newItem.Name, newItem.Elevation);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,123 @@
|
||||
<?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>
|
||||
<metadata name="bindingSource1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>17, 17</value>
|
||||
</metadata>
|
||||
</root>
|
||||
@@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RevitAddIns>
|
||||
<AddIn Type="Command">
|
||||
<Assembly>LevelsProperty.dll</Assembly>
|
||||
<ClientId>06f0a233-f472-4ca4-a271-d77b55fefe58</ClientId>
|
||||
<FullClassName>Revit.SDK.Samples.LevelsProperty.CS.Command</FullClassName>
|
||||
<Text>Create levels</Text>
|
||||
<Description>Show how to get all the levels in a document and how to create and delete a level and set its properties.</Description>
|
||||
<VisibilityMode>AlwaysVisible</VisibilityMode>
|
||||
<VendorId>ADSK</VendorId>
|
||||
<VendorDescription>Autodesk, www.autodesk.com</VendorDescription>
|
||||
</AddIn>
|
||||
</RevitAddIns>
|
||||
@@ -0,0 +1,128 @@
|
||||
<?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>{3BDA192E-06F3-43B2-8ADD-A1D8766935A0}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>Revit.SDK.Samples.LevelsProperty.CS</RootNamespace>
|
||||
<AssemblyName>LevelsProperty</AssemblyName>
|
||||
<SccProjectName>
|
||||
</SccProjectName>
|
||||
<SccLocalPath>
|
||||
</SccLocalPath>
|
||||
<SccAuxPath>
|
||||
</SccAuxPath>
|
||||
<SccProvider>
|
||||
</SccProvider>
|
||||
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
|
||||
<TargetFrameworkProfile />
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</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.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="LevelsDataSource.cs" />
|
||||
<Compile Include="LevelsForm.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="LevelsForm.Designer.cs">
|
||||
<DependentUpon>LevelsForm.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Properties\Resources.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DesignTime>True</DesignTime>
|
||||
<DependentUpon>Resources.resx</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Unit.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="LevelsForm.resx">
|
||||
<SubType>Designer</SubType>
|
||||
<DependentUpon>LevelsForm.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Properties\Resources.resx">
|
||||
<Generator>ResXFileCodeGenerator</Generator>
|
||||
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
||||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="Resources\add.ico" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="Resources\subtract.ico" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="Resources\delete.ico" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="Resources\new.ico" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(SolutionDir)VSProps\SDKSamples.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
<PropertyGroup>
|
||||
<PostBuildEvent>set FILEFORSAMPLEREG="$(SolutionDir)..\..\..\..\Regression\API\SDKSamples\UpdateSampleDllForRegression.pl"
|
||||
if exist %25FILEFORSAMPLEREG%25 perl %25FILEFORSAMPLEREG%25 $(ProjectExt) "$(ProjectPath)" "$(TargetPath)" "$(SolutionDir)"</PostBuildEvent>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<ResolveAssemblyWarnOrErrorOnTargetArchitectureMismatch>None</ResolveAssemblyWarnOrErrorOnTargetArchitectureMismatch>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
@@ -0,0 +1,58 @@
|
||||
//
|
||||
// (C) Copyright 2003-2019 by Autodesk, Inc.
|
||||
//
|
||||
// Permission to use, copy, modify, and distribute this software in
|
||||
// object code form for any purpose and without fee is hereby granted,
|
||||
// provided that the above copyright notice appears in all copies and
|
||||
// that both that copyright notice and the limited warranty and
|
||||
// restricted rights notice below appear in all supporting
|
||||
// documentation.
|
||||
//
|
||||
// AUTODESK PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS.
|
||||
// AUTODESK SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF
|
||||
// MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE. AUTODESK, INC.
|
||||
// DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE
|
||||
// UNINTERRUPTED OR ERROR FREE.
|
||||
//
|
||||
// Use, duplication, or disclosure by the U.S. Government is subject to
|
||||
// restrictions set forth in FAR 52.227-19 (Commercial Computer
|
||||
// Software - Restricted Rights) and DFAR 252.227-7013(c)(1)(ii)
|
||||
// (Rights in Technical Data and Computer Software), as applicable.
|
||||
//
|
||||
|
||||
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("LevelsProperty")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("LevelsProperty")]
|
||||
[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("0447196f-4030-40f3-bceb-1fe73d0ecc06")]
|
||||
|
||||
// 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")]
|
||||
@@ -0,0 +1,103 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:4.0.30319.42000
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace Revit.SDK.Samples.LevelsProperty.CS.Properties {
|
||||
using System;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// A strongly-typed resource class, for looking up localized strings, etc.
|
||||
/// </summary>
|
||||
// This class was auto-generated by the StronglyTypedResourceBuilder
|
||||
// class via a tool like ResGen or Visual Studio.
|
||||
// To add or remove a member, edit your .ResX file then rerun ResGen
|
||||
// with the /str option, or rebuild your VS project.
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
internal class Resources {
|
||||
|
||||
private static global::System.Resources.ResourceManager resourceMan;
|
||||
|
||||
private static global::System.Globalization.CultureInfo resourceCulture;
|
||||
|
||||
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
|
||||
internal Resources() {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the cached ResourceManager instance used by this class.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Resources.ResourceManager ResourceManager {
|
||||
get {
|
||||
if (object.ReferenceEquals(resourceMan, null)) {
|
||||
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Revit.SDK.Samples.LevelsProperty.CS.Properties.Resources", typeof(Resources).Assembly);
|
||||
resourceMan = temp;
|
||||
}
|
||||
return resourceMan;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Overrides the current thread's CurrentUICulture property for all
|
||||
/// resource lookups using this strongly typed resource class.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Globalization.CultureInfo Culture {
|
||||
get {
|
||||
return resourceCulture;
|
||||
}
|
||||
set {
|
||||
resourceCulture = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap _new {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("new", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap add {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("add", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap delete {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("delete", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap subtract {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("subtract", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,133 @@
|
||||
<?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>
|
||||
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
|
||||
<data name="add" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\add.ico;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="subtract" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\subtract.ico;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="delete" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\delete.ico;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="new" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\new.ico;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
</root>
|
||||
Binary file not shown.
Binary file not shown.
|
After Width: | Height: | Size: 1.1 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 1.1 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 1.1 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 1.1 KiB |
@@ -0,0 +1,61 @@
|
||||
//
|
||||
// (C) Copyright 2003-2019 by Autodesk, Inc.
|
||||
//
|
||||
// Permission to use, copy, modify, and distribute this software in
|
||||
// object code form for any purpose and without fee is hereby granted,
|
||||
// provided that the above copyright notice appears in all copies and
|
||||
// that both that copyright notice and the limited warranty and
|
||||
// restricted rights notice below appear in all supporting
|
||||
// documentation.
|
||||
//
|
||||
// AUTODESK PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS.
|
||||
// AUTODESK SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF
|
||||
// MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE. AUTODESK, INC.
|
||||
// DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE
|
||||
// UNINTERRUPTED OR ERROR FREE.
|
||||
//
|
||||
// Use, duplication, or disclosure by the U.S. Government is subject to
|
||||
// restrictions set forth in FAR 52.227-19 (Commercial Computer
|
||||
// Software - Restricted Rights) and DFAR 252.227-7013(c)(1)(ii)
|
||||
// (Rights in Technical Data and Computer Software), as applicable.
|
||||
//
|
||||
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using Autodesk.Revit;
|
||||
using Autodesk.Revit.DB;
|
||||
|
||||
namespace Revit.SDK.Samples.LevelsProperty.CS
|
||||
{
|
||||
/// <summary>
|
||||
/// Provides static functions to convert unit
|
||||
/// </summary>
|
||||
static class Unit
|
||||
{
|
||||
#region Methods
|
||||
/// <summary>
|
||||
/// Convert the value get from RevitAPI to the value indicated by ForgeTypeId
|
||||
/// </summary>
|
||||
/// <param name="to">ForgeTypeId indicates unit of target value</param>
|
||||
/// <param name="value">value get from RevitAPI</param>
|
||||
/// <returns>Target value</returns>
|
||||
public static double CovertFromAPI(ForgeTypeId to, double value)
|
||||
{
|
||||
return UnitUtils.ConvertFromInternalUnits(value, to);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Convert a value indicated by ForgeTypeId to the value used by RevitAPI
|
||||
/// </summary>
|
||||
/// <param name="value">Value to be converted</param>
|
||||
/// <param name="from">ForgeTypeId indicates the unit of the value to be converted</param>
|
||||
/// <returns>Target value</returns>
|
||||
public static double CovertToAPI(double value, ForgeTypeId from)
|
||||
{
|
||||
return UnitUtils.ConvertToInternalUnits(value, from);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user