added Revit 2022 SDK minus except *rvt and *rfa

This commit is contained in:
Jeremy Tammik
2021-04-20 11:36:21 +02:00
parent 1133a82dc5
commit 7e327986e8
3034 changed files with 1245318 additions and 0 deletions
+306
View File
@@ -0,0 +1,306 @@
//
// (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 System.Windows.Forms;
using Autodesk;
using Autodesk.Revit;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;
using Autodesk.Revit.DB.Structure;
namespace Revit.SDK.Samples.Loads.CS
{
/// <summary>
/// Deal the LoadCase class which give methods to connect Revit and the user operation on the form
/// </summary>
public class LoadCaseDeal
{
// Private Members
Autodesk.Revit.ApplicationServices.Application m_revit; // Store the reference of revit application
Loads m_dataBuffer;
List<string> m_newLoadNaturesName; //store all the new nature's name that should be added
// Methods
/// <summary>
/// Default constructor of LoadCaseDeal
/// </summary>
public LoadCaseDeal(Loads dataBuffer)
{
m_dataBuffer = dataBuffer;
m_revit = dataBuffer.RevitApplication;
m_newLoadNaturesName = new List<string>();
m_newLoadNaturesName.Add("EQ1");
m_newLoadNaturesName.Add("EQ2");
m_newLoadNaturesName.Add("W1");
m_newLoadNaturesName.Add("W2");
m_newLoadNaturesName.Add("W3");
m_newLoadNaturesName.Add("W4");
m_newLoadNaturesName.Add("Other");
}
/// <summary>
/// prepare data for the dialog
/// </summary>
public void PrepareData()
{
//Create seven Load Natures first
CreateLoadNatures();
//get all the categories of load cases
UIApplication uiapplication = new UIApplication(m_revit);
Categories categories = uiapplication.ActiveUIDocument.Document.Settings.Categories;
Category category = categories.get_Item(BuiltInCategory.OST_LoadCases);
CategoryNameMap categoryNameMap = category.SubCategories;
System.Collections.IEnumerator iter = categoryNameMap.GetEnumerator();
iter.Reset();
while (iter.MoveNext())
{
Category temp = iter.Current as Category;
if (null == temp)
continue;
m_dataBuffer.LoadCaseCategories.Add(temp);
}
//get all the loadnatures name
IList<Element> elements = new FilteredElementCollector(uiapplication.ActiveUIDocument.Document).OfClass(typeof(LoadNature)).ToElements();
foreach (Element e in elements)
{
LoadNature nature = e as LoadNature;
if (null != nature)
{
m_dataBuffer.LoadNatures.Add(nature);
LoadNaturesMap newLoadNaturesMap = new LoadNaturesMap(nature);
m_dataBuffer.LoadNaturesMap.Add(newLoadNaturesMap);
}
}
elements = new FilteredElementCollector(uiapplication.ActiveUIDocument.Document).OfClass(typeof(LoadCase)).ToElements();
foreach (Element e in elements)
{
//get all the loadcases
LoadCase loadCase = e as LoadCase;
if (null != loadCase)
{
m_dataBuffer.LoadCases.Add(loadCase);
LoadCasesMap newLoadCaseMap = new LoadCasesMap(loadCase);
m_dataBuffer.LoadCasesMap.Add(newLoadCaseMap);
}
}
}
/// <summary>
/// create some load case natures named EQ1, EQ2, W1, W2, W3, W4, Other
/// </summary>
/// <returns></returns>
private bool CreateLoadNatures()
{
//try to add some new load natures
try
{
UIApplication uiapplication = new UIApplication(m_revit);
foreach (string name in m_newLoadNaturesName)
{
LoadNature.Create(uiapplication.ActiveUIDocument.Document, name);
}
}
catch (Exception e)
{
m_dataBuffer.ErrorInformation += e.ToString();
return false;
}
return true;
}
/// <summary>
/// add a new load nature
/// </summary>
/// <param name="index">the selected nature's index in the nature map</param>
/// <returns></returns>
public bool AddLoadNature(int index)
{
string natureName = null; //the load nature's name to be added
bool isUnique = false; // check if the name is unique
LoadNaturesMap myLoadNature = null;
//try to get out the loadnature from the map
try
{
myLoadNature = m_dataBuffer.LoadNaturesMap[index];
}
catch (Exception e)
{
m_dataBuffer.ErrorInformation += e.ToString();
return false;
}
//Can not get the load nature
if (null == myLoadNature)
{
m_dataBuffer.ErrorInformation += "Can't find the nature";
return false;
}
//check if the name is unique
natureName = myLoadNature.LoadNaturesName;
while (!isUnique)
{
natureName += "(1)";
isUnique = IsNatureNameUnique(natureName);
}
//try to create a load nature
try
{
UIApplication uiapplication = new UIApplication(m_revit);
LoadNature newLoadNature = LoadNature.Create(uiapplication.ActiveUIDocument.Document, natureName);
if (null == newLoadNature)
{
m_dataBuffer.ErrorInformation += "Create Failed";
return false;
}
//add the load nature into the list and maps
m_dataBuffer.LoadNatures.Add(newLoadNature);
LoadNaturesMap newMap = new LoadNaturesMap(newLoadNature);
m_dataBuffer.LoadNaturesMap.Add(newMap);
}
catch (Exception e)
{
m_dataBuffer.ErrorInformation += e.ToString();
return false;
}
return true;
}
/// <summary>
/// Duplicate a new load case
/// </summary>
/// <param name="index"></param>
/// <returns></returns>
public bool DuplicateLoadCase(int index)
{
LoadCasesMap myLoadCase = null;
bool isUnique = false;
string caseName = null;
//try to get the load case from the map
try
{
myLoadCase = m_dataBuffer.LoadCasesMap[index];
}
catch (Exception e)
{
m_dataBuffer.ErrorInformation += e.ToString();
return false;
}
//get nothing
if (null == myLoadCase)
{
m_dataBuffer.ErrorInformation += "Can not find the load case";
return false;
}
//check the name
caseName = myLoadCase.LoadCasesName;
while (!isUnique)
{
caseName += "(1)";
isUnique = IsCaseNameUnique(caseName);
}
//get the selected case's nature
Autodesk.Revit.DB.ElementId categoryId = myLoadCase.LoadCasesSubCategoryId;
Autodesk.Revit.DB.ElementId natureId = myLoadCase.LoadCasesNatureId;
UIApplication uiapplication = new UIApplication(m_revit);
//try to create a load case
try
{
LoadCase newLoadCase = LoadCase.Create(uiapplication.ActiveUIDocument.Document, caseName, natureId, categoryId);
if (null == newLoadCase)
{
m_dataBuffer.ErrorInformation += "Create Load Case Failed";
return false;
}
//add the new case into list and map
m_dataBuffer.LoadCases.Add(newLoadCase);
LoadCasesMap newLoadCaseMap = new LoadCasesMap(newLoadCase);
m_dataBuffer.LoadCasesMap.Add(newLoadCaseMap);
}
catch (Exception e)
{
m_dataBuffer.ErrorInformation += e.ToString();
return false;
}
return true;
}
/// <summary>
/// check if the case's name is unique
/// </summary>
/// <param name="name">the name to be checked</param>
/// <returns>true will be returned if the name is unique</returns>
public bool IsCaseNameUnique(string name)
{
//compare the name with the name of each case in the map
for (int i = 0; i < m_dataBuffer.LoadCasesMap.Count; i++)
{
string nameTemp = m_dataBuffer.LoadCasesMap[i].LoadCasesName;
if (name == nameTemp)
{
return false;
}
}
return true;
}
/// <summary>
/// check if the nature's name is unique
/// </summary>
/// <param name="name">the name to be checked</param>
/// <returns>true will be returned if the name is unique</returns>
public bool IsNatureNameUnique(string name)
{
//compare the name with the name of each nature in the map
for (int i = 0; i < m_dataBuffer.LoadNatures.Count; i++)
{
string nameTemp = m_dataBuffer.LoadNaturesMap[i].LoadNaturesName;
if (name == nameTemp)
{
return false;
}
}
return true;
}
}
}
+154
View File
@@ -0,0 +1,154 @@
//
// (C) Copyright 2003-2019 by Autodesk, Inc.
//
// Permission to use, copy, modify, and distribute this software in
// object code form for any purpose and without fee is hereby granted,
// provided that the above copyright notice appears in all copies and
// that both that copyright notice and the limited warranty and
// restricted rights notice below appear in all supporting
// documentation.
//
// AUTODESK PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS.
// AUTODESK SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF
// MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE. AUTODESK, INC.
// DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE
// UNINTERRUPTED OR ERROR FREE.
//
// Use, duplication, or disclosure by the U.S. Government is subject to
// restrictions set forth in FAR 52.227-19 (Commercial Computer
// Software - Restricted Rights) and DFAR 252.227-7013(c)(1)(ii)
// (Rights in Technical Data and Computer Software), as applicable.
//
using System;
using System.Windows.Forms;
using System.Collections.Generic;
using System.Text;
using Autodesk;
using Autodesk.Revit;
using Autodesk.Revit.DB;
using Autodesk.Revit.DB.Structure;
namespace Revit.SDK.Samples.Loads.CS
{
/// <summary>
/// A class to store Load Case and it's properties.
/// </summary>
public class LoadCasesMap
{
LoadCase m_loadCase;
string m_loadCasesName; //Store the load case's name
string m_loadCasesNumber; //Store the load cases number
Autodesk.Revit.DB.ElementId m_loadCasesNatureId; //Store the Id of the load case's nature
Autodesk.Revit.DB.ElementId m_loadCasesSubcategoryId;//Store the Id of the load case's category
/// <summary>
/// LoadCasesName
/// </summary>
public string LoadCasesName
{
get
{
return m_loadCasesName;
}
set
{
m_loadCasesName = value;
m_loadCase.Name = m_loadCasesName;
}
}
/// <summary>
/// LoadCasesNumber property.
/// </summary>
public string LoadCasesNumber
{
get
{
return m_loadCase.Number.ToString();
}
}
/// <summary>
/// LoadCasesNatureId property.
/// </summary>
public Autodesk.Revit.DB.ElementId LoadCasesNatureId
{
get
{
return m_loadCasesNatureId;
}
set
{
m_loadCasesNatureId = value;
m_loadCase.NatureId = m_loadCasesNatureId;
}
}
/// <summary>
/// LoadCasesCategoryId property.
/// </summary>
public Autodesk.Revit.DB.ElementId LoadCasesSubCategoryId
{
get
{
return m_loadCasesSubcategoryId;
}
set
{
m_loadCasesSubcategoryId = value;
m_loadCase.SubcategoryId = m_loadCasesSubcategoryId;
}
}
/// <summary>
/// Overload the constructor
/// </summary>
/// <param name="loadCase">Load Case</param>
public LoadCasesMap(LoadCase loadCase)
{
m_loadCase = loadCase;
m_loadCasesName = m_loadCase.Name;
m_loadCasesNumber = m_loadCase.Number.ToString();
m_loadCasesNatureId = m_loadCase.NatureId;
m_loadCasesSubcategoryId = m_loadCase.SubcategoryId;
}
}
/// <summary>
/// A class to store Load Nature name
/// </summary>
public class LoadNaturesMap
{
LoadNature m_loadNature = null;
string m_loadNaturesName = null;
/// <summary>
/// Get or set a load nature name.
/// </summary>
public string LoadNaturesName
{
get
{
return m_loadNaturesName;
}
set
{
m_loadNaturesName = value;
m_loadNature.Name = m_loadNaturesName;
}
}
/// <summary>
/// constructor of LoadNaturesMap class
/// </summary>
/// <param name="loadNature"></param>
public LoadNaturesMap(LoadNature loadNature)
{
m_loadNature = loadNature;
m_loadNaturesName = loadNature.Name;
}
}
}
+346
View File
@@ -0,0 +1,346 @@
//
// (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.Loads.CS
{
/// <summary>
/// mainly deal with the operation on load case page on the form
/// </summary>
public partial class LoadsForm
{
int m_loadCaseDataGridViewSelectedIndex;
int m_loadNatureDataGridViewSelectedIndex;
System.Windows.Forms.DataGridViewTextBoxColumn LoadCasesName;
System.Windows.Forms.DataGridViewTextBoxColumn LoadCasesNumber;
System.Windows.Forms.DataGridViewComboBoxColumn LoadCasesNature;
System.Windows.Forms.DataGridViewComboBoxColumn LoadCasesCategory;
System.Windows.Forms.DataGridViewTextBoxColumn LoadNatureName;
// Methods
/// <summary>
/// Initialize the data on this page.
/// </summary>
void InitializeLoadCasePage()
{
InitializeLoadCasesDataGridView();
InitializeLoadNaturesDataGridView();
if (0 == m_dataBuffer.LoadCases.Count)
{
this.duplicateLoadCasesButton.Enabled = false;
}
if (0 == m_dataBuffer.LoadNatures.Count)
{
this.addLoadNaturesButton.Enabled = false;
}
this.addLoadNaturesButton.Enabled = false;
}
/// <summary>
/// Initialize the loadCasesDataGridView
/// </summary>
private void InitializeLoadCasesDataGridView()
{
this.LoadCasesName = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.LoadCasesNumber = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.LoadCasesNature = new System.Windows.Forms.DataGridViewComboBoxColumn();
this.LoadCasesCategory = new System.Windows.Forms.DataGridViewComboBoxColumn();
loadCasesDataGridView.AutoGenerateColumns = false;
this.loadCasesDataGridView.Columns.AddRange(new DataGridViewColumn[] { this.LoadCasesName, this.LoadCasesNumber, this.LoadCasesNature, this.LoadCasesCategory });
loadCasesDataGridView.DataSource = m_dataBuffer.LoadCasesMap;
this.LoadCasesName.DataPropertyName = "LoadCasesName";
this.LoadCasesName.HeaderText = "Name";
this.LoadCasesName.Name = "LoadCasesName";
this.LoadCasesName.ReadOnly = false;
this.LoadCasesName.Width = loadCasesDataGridView.Width / 6;
this.LoadCasesNumber.DataPropertyName = "LoadCasesNumber";
this.LoadCasesNumber.HeaderText = "Case Number";
this.LoadCasesNumber.Name = "LoadCasesNumber";
this.LoadCasesNumber.ReadOnly = true;
this.LoadCasesNumber.Width = loadCasesDataGridView.Width / 4;
this.LoadCasesNature.DataPropertyName = "LoadCasesNatureId";
this.LoadCasesNature.DisplayStyle = System.Windows.Forms.DataGridViewComboBoxDisplayStyle.Nothing;
this.LoadCasesNature.HeaderText = "Nature";
this.LoadCasesNature.Name = "LoadCasesNature";
this.LoadCasesNature.Resizable = System.Windows.Forms.DataGridViewTriState.True;
this.LoadCasesNature.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
this.LoadCasesNature.Width = loadCasesDataGridView.Width / 4;
LoadCasesNature.DataSource = m_dataBuffer.LoadNatures;
LoadCasesNature.DisplayMember = "Name";
LoadCasesNature.ValueMember = "Id";
this.LoadCasesCategory.DataPropertyName = "LoadCasesCategoryId";
this.LoadCasesCategory.DisplayStyle = System.Windows.Forms.DataGridViewComboBoxDisplayStyle.Nothing;
this.LoadCasesCategory.HeaderText = "Category";
this.LoadCasesCategory.Name = "LoadCasesCategory";
this.LoadCasesCategory.Resizable = System.Windows.Forms.DataGridViewTriState.True;
this.LoadCasesCategory.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
this.LoadCasesCategory.Width = loadCasesDataGridView.Width / 4;
LoadCasesCategory.DataSource = m_dataBuffer.LoadCaseCategories;
LoadCasesCategory.DisplayMember = "Name";
LoadCasesCategory.ValueMember = "Id";
this.loadCasesDataGridView.MultiSelect = false;
this.loadCasesDataGridView.SelectionMode = DataGridViewSelectionMode.CellSelect;
}
/// <summary>
/// Initialize the loadNaturesDataGridView
/// </summary>
private void InitializeLoadNaturesDataGridView()
{
this.LoadNatureName = new System.Windows.Forms.DataGridViewTextBoxColumn();
loadNaturesDataGridView.AutoGenerateColumns = false;
this.loadNaturesDataGridView.Columns.AddRange(new DataGridViewColumn[] { this.LoadNatureName });
loadNaturesDataGridView.DataSource = m_dataBuffer.LoadNaturesMap;
this.LoadNatureName.DataPropertyName = "LoadNaturesName";
this.LoadNatureName.HeaderText = "Name";
this.LoadNatureName.Name = "LoadNaturesName";
this.LoadNatureName.ReadOnly = false;
this.LoadNatureName.Width = loadCasesDataGridView.Width - 100;
this.loadNaturesDataGridView.MultiSelect = false;
this.loadNaturesDataGridView.SelectionMode = DataGridViewSelectionMode.CellSelect;
}
/// <summary>
/// Respond the loadCasesDataGridView_CellClick event.
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void loadCasesDataGridView_CellClick(object sender, DataGridViewCellEventArgs e)
{
Initilize();
m_loadCaseDataGridViewSelectedIndex = e.RowIndex;
}
/// <summary>
/// Respond the loadNaturesDataGridView_CellClick event.
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void loadNaturesDataGridView_CellClick(object sender, DataGridViewCellEventArgs e)
{
Initilize();
m_loadNatureDataGridViewSelectedIndex = e.RowIndex;
}
/// <summary>
/// Respond the loadCasesDataGridView_ColumnHeaderMouseClick event.
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void loadCasesDataGridView_ColumnHeaderMouseClick(object sender, DataGridViewCellMouseEventArgs e)
{
m_loadCaseDataGridViewSelectedIndex = e.RowIndex;
}
/// <summary>
/// Respond the loadNaturesDataGridView_RowHeaderMouseClick event.
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void loadNaturesDataGridView_RowHeaderMouseClick(object sender, DataGridViewCellMouseEventArgs e)
{
m_loadNatureDataGridViewSelectedIndex = e.RowIndex;
}
/// <summary>
/// Respond the DataGridView cell validating event,
/// check the user's input whether it is correct.
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void loadNaturesDataGridView_CellValidating(object sender, DataGridViewCellValidatingEventArgs e)
{
object objectTemp = this.loadNaturesDataGridView.CurrentCell.Value;
string nameTemp = objectTemp as string;
object changeValue = e.FormattedValue;
string changeValueTemp = changeValue as string;
if (nameTemp == changeValueTemp)
{
return;
}
if (null == changeValueTemp)
{
TaskDialog.Show("Revit", "Name can not be null");
e.Cancel = true;
return;
}
if ("" == changeValueTemp)
{
TaskDialog.Show("Revit", "Name can not be null");
e.Cancel = true;
return;
}
if (!m_dataBuffer.LoadCasesDeal.IsNatureNameUnique(changeValueTemp))
{
TaskDialog.Show("Revit", "Name can not be same");
e.Cancel = true;
return;
}
}
/// <summary>
/// Respond the DataGridView cell validating event,
/// check the user's input whether it is correct.
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void loadCasesDataGridView_CellValidating(object sender, DataGridViewCellValidatingEventArgs e)
{
if (e.ColumnIndex != 0)
{
return;
}
DataGridViewCell cellTemp = this.loadCasesDataGridView.CurrentCell;
if (null == cellTemp)
{
return;
}
string nameTemp = cellTemp.Value as string;
if (null == nameTemp)
{
e.Cancel = false;
return;
}
object changeValue = e.FormattedValue;
string changeValueTemp = changeValue as string;
if (nameTemp == changeValueTemp)
{
return;
}
if (null == changeValueTemp)
{
TaskDialog.Show("Revit", "Name can not be null");
e.Cancel = true;
return;
}
if ("" == changeValueTemp)
{
TaskDialog.Show("Revit", "Name can not be null");
e.Cancel = true;
return;
}
if (!m_dataBuffer.LoadCasesDeal.IsCaseNameUnique(changeValueTemp))
{
TaskDialog.Show("Revit", "Name can not be same");
e.Cancel = true;
return;
}
}
/// <summary>
/// When duplicateLoadCasesButton clicked, duplicate a load case.
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void duplicateLoadCasesButton_Click(object sender, EventArgs e)
{
m_loadCaseDataGridViewSelectedIndex = this.loadCasesDataGridView.CurrentCell.RowIndex;
if (!m_dataBuffer.LoadCasesDeal.DuplicateLoadCase(m_loadCaseDataGridViewSelectedIndex))
{
TaskDialog.Show("Revit", "Duplicate failed");
return;
}
this.ReLoad();
}
/// <summary>
/// When addLoadNaturesButton clicked, add a new load nature.
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void addLoadNaturesButton_Click(object sender, EventArgs e)
{
if (!m_dataBuffer.LoadCasesDeal.AddLoadNature(m_loadNatureDataGridViewSelectedIndex))
{
TaskDialog.Show("Revit", "Add Nature Failed");
return;
}
this.ReLoad();
}
/// <summary>
/// Reload the data of the cases and natures
/// </summary>
private void ReLoad()
{
this.loadNaturesDataGridView.DataSource = null;
this.loadCasesDataGridView.DataSource = null;
this.LoadCasesNature.SortMode = DataGridViewColumnSortMode.Automatic;
this.loadNaturesDataGridView.DataSource = m_dataBuffer.LoadNaturesMap;
this.loadCasesDataGridView.DataSource = m_dataBuffer.LoadCasesMap;
this.Refresh();
return;
}
/// <summary>
/// enable button
/// </summary>
private void Initilize()
{
if (this.loadCasesDataGridView.Focused)
{
this.addLoadNaturesButton.Enabled = false;
this.duplicateLoadCasesButton.Enabled = true;
}
else if (this.loadNaturesDataGridView.Focused)
{
this.addLoadNaturesButton.Enabled = true;
this.duplicateLoadCasesButton.Enabled = false;
}
this.Refresh();
return;
}
}
}
+417
View File
@@ -0,0 +1,417 @@
//
// (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 System.Windows.Forms;
using Autodesk;
using Autodesk.Revit;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;
using Autodesk.Revit.DB.Structure;
namespace Revit.SDK.Samples.Loads.CS
{
/// <summary>
/// mainly deal class which give methods to connect Revit and the user operation on the form
/// </summary>
public class LoadCombinationDeal
{
// Private Members
Loads m_dataBuffer; // Store the reference of Loads
Autodesk.Revit.ApplicationServices.Application m_revit; // Store the reference of revit
Autodesk.Revit.DB.Document m_document; // Store the reference of document
// Methods
/// <summary>
/// Default constructor of LoadCombinationDeal
/// </summary>
public LoadCombinationDeal(Loads dataBuffer)
{
m_dataBuffer = dataBuffer;
m_revit = dataBuffer.RevitApplication;
UIApplication uiapplication = new UIApplication(m_revit);
m_document = uiapplication.ActiveUIDocument.Document;
}
/// <summary>
/// Find out all Load Combination and Usage in the existing document.
/// As specification require, prepare some Load Combination Usages if they are not in document
/// </summary>
public void PrepareData()
{
// Find out all Load Combination and Usage in the existing document.
IList<Element> elements = (new FilteredElementCollector(m_document)).OfClass(typeof(LoadCombination)).ToElements();
foreach (Element elem in elements)
{
LoadCombination combination = elem as LoadCombination;
if (null != combination)
{
// Add the Load Combination name.
m_dataBuffer.LoadCombinationNames.Add(combination.Name);
// Create LoadCombinationMap object.
LoadCombinationMap combinationMap = new LoadCombinationMap(combination);
// Add the LoadCombinationMap object to the array list.
m_dataBuffer.LoadCombinationMap.Add(combinationMap);
}
}
elements = (new FilteredElementCollector(m_document)).OfClass(typeof(LoadUsage)).ToElements();
foreach (Element elem in elements)
{
// Add Load Combination Usage information
LoadUsage usage = elem as LoadUsage;
if (null != usage)
{
// Add the Load Usage name
m_dataBuffer.LoadUsageNames.Add(usage.Name);
// Add the Load Usage object to a LoadUsageArray
m_dataBuffer.LoadUsages.Add(usage);
// Add the Load Usage information to UsageMap.
UsageMap usageMap = new UsageMap(m_dataBuffer, usage.Name);
m_dataBuffer.UsageMap.Add(usageMap);
}
}
// As specification require, some Load Combination Usages if they are not in document
String[] initUsageArray = { "Gravity", "Lateral", "Steel", "Composite", "Concrete" };
foreach (String s in initUsageArray)
{
NewLoadUsage(s);
}
}
/// <summary>
/// Create new Load Combination
/// </summary>
/// <param name="name">The new Load Combination name</param>
/// <param name="typeIndex">The index of new Load Combination Type</param>
/// <param name="stateIndex">The index of new Load Combination State</param>
/// <returns>true if the creation was successful; otherwise, false</returns>
public Boolean NewLoadCombination(String name, int typeIndex, int stateIndex)
{
// Define some data for creation.
List<ElementId> usageIds = new List<ElementId>();
List<LoadComponent> components = new List<LoadComponent>();
double[] factorArray = new double[m_dataBuffer.FormulaMap.Count];
// First check whether the name has been used
foreach (String s in m_dataBuffer.LoadCombinationNames)
{
if (s == name || null == name)
{
m_dataBuffer.ErrorInformation = "the combination name has been used.";
return false;
}
}
// Get the usage information.
foreach (UsageMap usageMap in m_dataBuffer.UsageMap)
{
if (true == usageMap.Set)
{
LoadUsage usage = FindUsageByName(usageMap.Name);
if (null != usage)
{
usageIds.Add(usage.Id);
}
}
}
// Get the formula information
for (int i = 0; i < m_dataBuffer.FormulaMap.Count; i++)
{
FormulaMap formulaMap = m_dataBuffer.FormulaMap[i];
factorArray[i] = formulaMap.Factor;
LoadCase loadCase = FindLoadCaseByName(formulaMap.Case);
if (null != loadCase)
{
LoadComponent component = new LoadComponent(loadCase.Id, formulaMap.Factor);
components.Add(component);
}
}
// Begin to new a load combination
try
{
LoadCombination loadCombination = LoadCombination.Create(m_document, name, (LoadCombinationType)typeIndex, (LoadCombinationState)stateIndex);
if (null == loadCombination)
{
m_dataBuffer.ErrorInformation = "Get null reference after usage creation.";
return false;
}
loadCombination.SetComponents(components);
loadCombination.SetUsageIds(usageIds);
// Store this load combination information for further use
m_dataBuffer.LoadCombinationNames.Add(loadCombination.Name);
LoadCombinationMap combinationMap = new LoadCombinationMap(loadCombination);
m_dataBuffer.LoadCombinationMap.Add(combinationMap);
}
catch (Exception e)
{
m_dataBuffer.ErrorInformation = e.Message;
return false;
}
// If create combination successful, reset the usage check state and clear the formula
foreach (UsageMap usageMap in m_dataBuffer.UsageMap)
{
usageMap.Set = false;
}
m_dataBuffer.FormulaMap.Clear();
return true;
}
/// <summary>
/// Delete the selected Load Combination
/// </summary>
/// <param name="index">The selected index in the DataGridView</param>
/// <returns>true if the delete operation was successful; otherwise, false</returns>
public Boolean DeleteCombination(int index)
{
// Get the name of the delete combination
String combinationName = m_dataBuffer.LoadCombinationNames[index];
// Find the combination by the name and delete the combination
LoadCombination combination;
IList<Element> elements = (new FilteredElementCollector(m_document)).OfClass(typeof(LoadCombination)).ToElements();
foreach (Element elem in elements)
{
combination = elem as LoadCombination;
if (combinationName == combination.Name)
{
// Begin to delete the combination
try
{
m_document.Delete(combination.Id);
}
catch (Exception e)
{
m_dataBuffer.ErrorInformation = e.ToString();
return false;
}
break;
}
}
// If delete is successful, Change the map and the string List
m_dataBuffer.LoadCombinationMap.RemoveAt(index);
m_dataBuffer.LoadCombinationNames.RemoveAt(index);
return true;
}
/// <summary>
/// Create a new load combination usage
/// </summary>
/// <param name="usageName">The new Load Usage name</param>
/// <returns>true if the process is successful; otherwise, false</returns>
public Boolean NewLoadUsage(String usageName)
{
// First check whether the name has been used
foreach (String s in m_dataBuffer.LoadUsageNames)
{
if (usageName == s)
{
m_dataBuffer.ErrorInformation = "the usage name has been used.";
return false;
}
}
// Begin to new a load combination usage
try
{
LoadUsage loadUsage = LoadUsage.Create(m_document, usageName);
if (null == loadUsage)
{
m_dataBuffer.ErrorInformation = "Get null reference after usage creation.";
return false;
}
// Store this load usage information for further use.
m_dataBuffer.LoadUsageNames.Add(loadUsage.Name);
m_dataBuffer.LoadUsages.Add(loadUsage);
// Add the Load Usage information to UsageMap.
UsageMap usageMap = new UsageMap(m_dataBuffer, loadUsage.Name);
m_dataBuffer.UsageMap.Add(usageMap);
}
catch (Exception e)
{
m_dataBuffer.ErrorInformation = e.Message;
return false;
}
return true;
}
/// <summary>
/// Delete the selected Load Usage
/// </summary>
/// <param name="index">The selected index in the DataGridView</param>
/// <returns>true if the delete operation was successful; otherwise, false</returns>
public Boolean DeleteUsage(int index)
{
// Get the delete usage
LoadUsage deleteUsage = m_dataBuffer.LoadUsages[index];
String usageName = deleteUsage.Name;
// Begin to delete the combination
try
{
m_document.Delete(deleteUsage.Id);
}
catch (Exception e)
{
m_dataBuffer.ErrorInformation = e.ToString();
return false;
}
// Modify the data to show the delete operation
m_dataBuffer.LoadUsages.RemoveAt(index);
m_dataBuffer.LoadUsageNames.RemoveAt(index);
m_dataBuffer.UsageMap.RemoveAt(index);
// Need to delete corresponding in Combination
foreach (LoadCombinationMap map in m_dataBuffer.LoadCombinationMap)
{
String oldUsage = map.Usage;
int location = oldUsage.IndexOf(usageName);
if (-1 == location)
{
continue;
}
if (oldUsage.Length == usageName.Length)
{
map.Usage = oldUsage.Remove(0);
continue;
}
if (0 == location)
{
map.Usage = oldUsage.Remove(location, usageName.Length + 1);
}
else
{
map.Usage = oldUsage.Remove(location - 1, usageName.Length + 1);
}
}
return true;
}
/// <summary>
/// Change usage name when the user modify it on the form
/// </summary>
/// <param name="oldName">The name before modification</param>
/// <param name="newName">The name after modification</param>
/// <returns>true if the modification was successful; otherwise, false</returns>
public Boolean ModifyUsageName(String oldName, String newName)
{
// If the name is no change, just return true.
if (oldName == newName)
{
return true;
}
// Check whether the name has been used
foreach (String s in m_dataBuffer.LoadUsageNames)
{
if (s == newName)
{
TaskDialog.Show("Revit", "There is a same named usage already.");
return false;
}
}
// Begin to modify the name of the usage
foreach (LoadUsage usage in m_dataBuffer.LoadUsages)
{
if (oldName == usage.Name)
{
usage.get_Parameter(BuiltInParameter.LOAD_USAGE_NAME).Set(newName);
}
}
return true;
}
/// <summary>
/// Add a formula with the load case name
/// </summary>
/// <param name="caseName">The name of the load case</param>
/// <returns>true if the creation is successful; otherwise, false</returns>
public Boolean AddFormula(String caseName)
{
// New a FormulaMap, and add it to m_dataBuffer.FormulaMap
// Note: the factor of the formula is always set 1
FormulaMap map = new FormulaMap(caseName);
m_dataBuffer.FormulaMap.Add(map);
return true;
}
/// <summary>
/// Find a load usage by the load usage name
/// </summary>
/// <param name="name">The name of load usage</param>
/// <returns>The reference of the LoadUsage</returns>
private LoadUsage FindUsageByName(String name)
{
LoadUsage usage = null;
foreach (LoadUsage l in m_dataBuffer.LoadUsages)
{
if (name == l.Name)
{
usage = l;
break;
}
}
return usage;
}
/// <summary>
/// Find a load case by the load case name
/// </summary>
/// <param name="name">The name of load case</param>
/// <returns>The reference of the LoadCase</returns>
private LoadCase FindLoadCaseByName(String name)
{
LoadCase loadCase = null;
foreach (LoadCase l in m_dataBuffer.LoadCases)
{
if (name == l.Name)
{
loadCase = l;
break;
}
}
return loadCase;
}
}
}
@@ -0,0 +1,99 @@
//
// (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.Loads.CS
{
/// <summary>
/// The map class which store the data and display in formulaDataGridView
/// </summary>
public class FormulaMap
{
// Private Members
Double m_factor; // Indicate the factor column of Formula DataGridView control
String m_caseName; // Indicate case column of Formula DataGridView control
/// <summary>
/// Factor
/// </summary>
public Double Factor
{
get
{
return m_factor;
}
set
{
m_factor = value;
}
}
/// <summary>
/// Load Case
/// </summary>
public String Case
{
get
{
return m_caseName;
}
set
{
m_caseName = value;
}
}
// Methods
/// <summary>
/// Default constructor of FormulaMap
/// </summary>
public FormulaMap()
{
m_factor = 0;
}
/// <summary>
/// constructor with the case name
/// </summary>
/// <param name="caseName">The value set to Case Property</param>
public FormulaMap(String caseName)
{
m_factor = 1;
m_caseName = caseName;
}
/// <summary>
/// Constructor with the factor and case name
/// </summary>
/// <param name="factor">The value set to Factor Property</param>
/// <param name="caseName">The value set to Case Property</param>
public FormulaMap(double factor, String caseName)
{
m_factor = factor;
m_caseName = caseName;
}
}
}
+151
View File
@@ -0,0 +1,151 @@
//
// (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;
using Autodesk.Revit;
using Autodesk.Revit.DB;
using Autodesk.Revit.DB.Structure;
namespace Revit.SDK.Samples.Loads.CS
{
/// <summary>
/// A class to store Load Combination and it's properties.
/// </summary>
public class LoadCombinationMap
{
// Private Members
String m_name; // Indicate name column of LoadCombination DataGridView control
String m_formula; // Indicate formula column of LoadCombination DataGridView control
String m_type; // Indicate type column of LoadCombination DataGridView control
String m_state; // Indicate state column of LoadCombination DataGridView control
String m_usage; // Indicate usage column of LoadCombination DataGridView control
/// <summary>
/// Name property of LoadCombinationMap
/// </summary>
public String Name
{
get
{
return m_name;
}
}
/// <summary>
/// Formula property of LoadCombinationMap
/// </summary>
public String Formula
{
get
{
return m_formula;
}
}
/// <summary>
/// Type property of LoadCombinationMap
/// </summary>
public String Type
{
get
{
return m_type;
}
}
/// <summary>
/// State property of LoadCombinationMap
/// </summary>
public String State
{
get
{
return m_state;
}
}
/// <summary>
/// Usage property of LoadCombinationMap
/// </summary>
public String Usage
{
get
{
return m_usage;
}
set
{
m_usage = value;
}
}
/// <summary>
/// Default constructor of LoadCombinationMap
/// </summary>
/// <param name="combination">the reference of LoadCombination</param>
public LoadCombinationMap(LoadCombination combination)
{
m_name = combination.Name;
m_type = combination.Type.ToString();
m_state = combination.State.ToString();
Autodesk.Revit.DB.Document m_document = combination.Document;
// Generate the formula field.
StringBuilder formulaString = new StringBuilder();
IList<LoadComponent> components = combination.GetComponents();
foreach (LoadComponent component in components)
{
formulaString.Append(component.Factor);
formulaString.Append("*");
formulaString.Append(m_document.GetElement(component.LoadCaseOrCombinationId).Name);
if (components.IndexOf(component) < components.Count - 1)
{
formulaString.Append(" + ");
}
}
m_formula = formulaString.ToString();
// Generate the usage field.
StringBuilder usageString = new StringBuilder();
IList<ElementId> usageIds = combination.GetUsageIds();
foreach (ElementId id in usageIds)
{
Element element = m_document.GetElement(id);
usageString.Append(m_document.GetElement(id).Name);
if (usageIds.IndexOf(id) < usageIds.Count - 1)
{
usageString.Append(";");
}
}
m_usage = usageString.ToString();
}
}
}
@@ -0,0 +1,122 @@
//
// (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 System.Windows.Forms;
using Autodesk.Revit.UI;
namespace Revit.SDK.Samples.Loads.CS
{
/// <summary>
/// The map class which store the data and display in usageDataGridView
/// </summary>
public class UsageMap
{
// Private Members
Loads m_dataBuffer; // A reference of Loads
Boolean m_set; // Indicate the set column of Usage DataGridView control
String m_name; // Indicate the name column of Usage DataGridView control
/// <summary>
/// is selected in Usage DataGridView control
/// </summary>
public Boolean Set
{
get
{
return m_set;
}
set
{
m_set = value;
}
}
/// <summary>
/// usage name
/// </summary>
public String Name
{
get
{
return m_name;
}
set
{
if (null == value)
{
TaskDialog.Show("Revit", "The usage name should not be null.");
return;
}
if (null == m_name)
{
m_name = value;
return;
}
Boolean canModify = m_dataBuffer.ModifyUsageName(m_name, value);
if (canModify)
{
m_name = value;
}
}
}
/// <summary>
/// Constructor with Set = false, Name="",
/// This should not be called.
/// </summary>
/// <param name="dataBuffer">The reference of Loads</param>
public UsageMap(Loads dataBuffer)
{
m_dataBuffer = dataBuffer;
}
/// <summary>
/// constructor with Set = false
/// </summary>
/// <param name="dataBuffer">The reference of Loads</param>
/// <param name="name">The value set to Name property</param>
public UsageMap(Loads dataBuffer, String name)
{
m_dataBuffer = dataBuffer;
m_set = false;
m_name = name;
}
/// <summary>
/// constructor
/// </summary>
/// <param name="dataBuffer">The reference of Loads</param>
/// <param name="set">The value set to Set property</param>
/// <param name="name">The value set to Name property</param>
public UsageMap(Loads dataBuffer, Boolean set, String name)
{
m_dataBuffer = dataBuffer;
m_set = set;
m_name = name;
}
}
}
@@ -0,0 +1,584 @@
//
// (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.Loads.CS
{
/// <summary>
/// mainly deal with the operation on load combination page on the form
/// </summary>
public partial class LoadsForm
{
// Private Members
// Define the columns in LoadCombination DataGridView control
DataGridViewTextBoxColumn combinationNameColumn;
DataGridViewTextBoxColumn combinationFormulaColumn;
DataGridViewTextBoxColumn combinationTypeColumn;
DataGridViewTextBoxColumn combinationStateColumn;
DataGridViewTextBoxColumn combinationUsageColumn;
// Define the columns in Usage DataGridView control
DataGridViewCheckBoxColumn usageSetColumn;
DataGridViewTextBoxColumn usageNameColumn;
// Define the columns in Formula DataGridView control
DataGridViewTextBoxColumn formulaFactorColumn;
DataGridViewComboBoxColumn formulaCaseColumn;
// Methods
/// <summary>
/// Initialize the data on this page.
/// </summary>
void InitializeLoadCombinationPage()
{
// Add the Items in combinationType and combinationState comboBox
this.combinationTypeComboBox.Items.AddRange(new object[] { "Combination", "Envelope" });
this.combinationStateComboBox.Items.AddRange(new object[] { "Serviceability", "Ultimate" });
// Initialize the loadCombination DataGridView control
InitializeCombinationGrid();
// Initialize the load combination usage DataGridView control
InitializeUsageGrid();
// Initialize the load combination formula DataGridView control
InitializeFormulaGrid();
// Other initialization
combinationNameTextBox.Text = null;
combinationTypeComboBox.SelectedIndex = 0;
combinationStateComboBox.SelectedIndex = 0;
// Set the state of the button on this page.
CombinationsTabPageButtonEnable();
}
/// <summary>
/// Initialize the loadCombination DataGridView control
/// </summary>
private void InitializeCombinationGrid()
{
// Initialize the column data members.
combinationNameColumn = new DataGridViewTextBoxColumn();
combinationFormulaColumn = new DataGridViewTextBoxColumn();
combinationTypeColumn = new DataGridViewTextBoxColumn();
combinationStateColumn = new DataGridViewTextBoxColumn();
combinationUsageColumn = new DataGridViewTextBoxColumn();
// Binging the columns to the DataGridView
combinationDataGridView.AutoGenerateColumns = false;
combinationDataGridView.Columns.AddRange(new DataGridViewColumn[]
{combinationNameColumn, combinationFormulaColumn, combinationTypeColumn,
combinationStateColumn, combinationUsageColumn});
// Binging the data source and set this grid to readonly.
combinationDataGridView.DataSource = m_dataBuffer.LoadCombinationMap;
combinationDataGridView.ReadOnly = true;
// Initialize each column
combinationNameColumn.DataPropertyName = "Name";
combinationNameColumn.HeaderText = "Name";
combinationNameColumn.Name = "combinationNameColumn";
combinationNameColumn.Width = combinationDataGridView.Width / 7;
combinationFormulaColumn.DataPropertyName = "Formula";
combinationFormulaColumn.HeaderText = "Formula";
combinationFormulaColumn.Name = "combinationFormulaColumn";
combinationFormulaColumn.Width = combinationDataGridView.Width / 4;
combinationTypeColumn.DataPropertyName = "Type";
combinationTypeColumn.HeaderText = "Type";
combinationTypeColumn.Name = "combinationTypeColumn";
combinationTypeColumn.Width = combinationDataGridView.Width / 7;
combinationStateColumn.DataPropertyName = "State";
combinationStateColumn.HeaderText = "State";
combinationStateColumn.Name = "combinationStateColumn";
combinationStateColumn.Width = combinationDataGridView.Width / 7;
combinationUsageColumn.DataPropertyName = "Usage";
combinationUsageColumn.HeaderText = "Usage";
combinationUsageColumn.Name = "combinationUsageColumn";
combinationUsageColumn.Width = combinationDataGridView.Width / 3;
}
/// <summary>
/// Initialize the load combination usage DataGridView control
/// </summary>
private void InitializeUsageGrid()
{
// Initialize the column data members.
usageSetColumn = new DataGridViewCheckBoxColumn();
usageNameColumn = new DataGridViewTextBoxColumn();
// Binging the columns to the DataGridView
usageDataGridView.AutoGenerateColumns = false;
usageDataGridView.Columns.AddRange(new DataGridViewColumn[] { usageSetColumn, usageNameColumn });
// Binding the data source.
usageDataGridView.DataSource = m_dataBuffer.UsageMap;
// Binding event
usageDataGridView.CellValidating += new DataGridViewCellValidatingEventHandler(usageDataGridView_CellValidating);
// Initialize each column.
usageSetColumn.HeaderText = "Set";
usageSetColumn.DataPropertyName = "Set";
usageSetColumn.Name = "usageSetColumn";
usageSetColumn.Width = usageDataGridView.Width / 4;
usageNameColumn.DataPropertyName = "Name";
usageNameColumn.HeaderText = "Case";
usageNameColumn.Name = "usageNameColumn";
usageNameColumn.Width = usageDataGridView.Width / 2;
}
/// <summary>
/// Initialize the load combination formula DataGridView control
/// </summary>
private void InitializeFormulaGrid()
{
// Initialize the column data members.
formulaFactorColumn = new DataGridViewTextBoxColumn();
formulaCaseColumn = new DataGridViewComboBoxColumn();
// Binging the columns to the DataGridView
formulaDataGridView.AutoGenerateColumns = false;
formulaDataGridView.Columns.AddRange(new DataGridViewColumn[] { formulaFactorColumn, formulaCaseColumn });
// Binging the data source.
formulaDataGridView.DataSource = m_dataBuffer.FormulaMap;
// Initialize each column.
formulaFactorColumn.DataPropertyName = "Factor";
formulaFactorColumn.HeaderText = "Factor";
formulaFactorColumn.Name = "formulaFactorColumn";
formulaFactorColumn.Width = formulaDataGridView.Width / 4;
formulaCaseColumn.DataPropertyName = "Case";
formulaCaseColumn.HeaderText = "Case";
formulaCaseColumn.Name = "formulaCaseColumn";
formulaCaseColumn.DisplayStyle = DataGridViewComboBoxDisplayStyle.Nothing;
formulaCaseColumn.Width = formulaDataGridView.Width / 2;
formulaCaseColumn.DataSource = m_dataBuffer.LoadCases;
formulaCaseColumn.DisplayMember = "Name";
formulaCaseColumn.ValueMember = "Name";
}
// The Button Event method.
/// <summary>
/// Check All Button
/// </summary>
private void usageCheckAllButton_Click(object sender, EventArgs e)
{
foreach (UsageMap map in m_dataBuffer.UsageMap)
{
map.Set = true;
}
// Disable the CheckAll button, enable CheckNone button and refresh.
usageCheckAllButton.Enabled = false;
usageCheckNoneButton.Enabled = true;
this.usageDataGridView.Refresh();
}
/// <summary>
/// Check None Button
/// </summary>
private void usageCheckNoneButton_Click(object sender, EventArgs e)
{
foreach (UsageMap map in m_dataBuffer.UsageMap)
{
map.Set = false;
}
// Disable the CheckNone button, enable CheckAll button and refresh.
usageCheckAllButton.Enabled = true;
usageCheckNoneButton.Enabled = false;
this.usageDataGridView.Refresh();
}
/// <summary>
/// Usage Add Button
/// </summary>
private void usageAddButton_Click(object sender, EventArgs e)
{
StringBuilder usageString = new StringBuilder("Usage");
int i = 1;
bool needFind = true; // need to find another name which is not used
// First, need to find a name which is not the same as the other usages.
while (needFind)
{
bool isEqual = false;
usageString.Append(i);
foreach (String s in m_dataBuffer.LoadUsageNames)
{
if (s == usageString.ToString())
{
isEqual = true;
break;
}
}
if (isEqual)
{
usageString.Remove(0, usageString.Length);
usageString.Append("Usage");
i++;
}
else
{
needFind = false;
}
}
// Begin to add new Load Combination Usage
String usageName = usageString.ToString();
if (!m_dataBuffer.NewLoadUsage(usageName))
{
TaskDialog.Show("Revit", m_dataBuffer.ErrorInformation);
return;
}
// Refresh the Load Combination Usage DataGridView control
usageDataGridView.DataSource = null;
usageDataGridView.DataSource = m_dataBuffer.UsageMap;
// Change the state of the buttons and refresh.
CombinationsTabPageButtonEnable();
this.usageDataGridView.Refresh();
}
/// <summary>
/// Usage Delete Button
/// </summary>
private void usageDeleteButton_Click(object sender, EventArgs e)
{
// // Get selected index in usage DataGridView
int index = usageDataGridView.CurrentRow.Index;
if (0 > index)
{
TaskDialog.Show("Revit", "The program should go here.");
return;
}
// Begin to delete the Usage
if (!m_dataBuffer.DeleteUsage(index))
{
TaskDialog.Show("Revit", m_dataBuffer.ErrorInformation);
return;
}
// After deleting usage, refresh usage DataGridView
usageDataGridView.DataSource = null;
usageDataGridView.DataSource = m_dataBuffer.UsageMap;
// Set the state of the button on this page and refresh.
CombinationsTabPageButtonEnable();
this.Refresh();
}
/// <summary>
/// When modify Usage name, judge if the inputted Name is unique.
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
void usageDataGridView_CellValidating(object sender, DataGridViewCellValidatingEventArgs e)
{
// Modifying the usage name
if (1 == usageDataGridView.CurrentCell.ColumnIndex)
{
System.String newName = e.FormattedValue as System.String;
System.String oldName = usageDataGridView.CurrentCell.FormattedValue as System.String;
if (newName != oldName)
{
for (int i = 0; i < m_dataBuffer.UsageMap.Count; i++)
{
if (m_dataBuffer.UsageMap[i].Name == newName)
{
e.Cancel = true;
}
}
}
}
}
/// <summary>
/// New Combination Button
/// </summary>
private void newCombinationButton_Click(object sender, EventArgs e)
{
// First get the combination name
if (null == combinationNameTextBox.Text || "" == combinationNameTextBox.Text)
{
TaskDialog.Show("Revit", "Combination name should be input.");
return;
}
// Check if it has been used
String name = combinationNameTextBox.Text;
foreach (String s in m_dataBuffer.LoadCombinationNames)
{
if (s == name)
{
TaskDialog.Show("Revit", "Combination name has been used by another combination.");
return;
}
}
// get the data and begin to create.
int typeIndex = combinationTypeComboBox.SelectedIndex;
int stateIndex = combinationStateComboBox.SelectedIndex;
if (!m_dataBuffer.NewLoadCombination(name, typeIndex, stateIndex))
{
TaskDialog.Show("Revit", m_dataBuffer.ErrorInformation);
return;
}
// If create combination successfully, reset some controls.
combinationNameTextBox.Text = null;
combinationTypeComboBox.SelectedIndex = 0;
combinationStateComboBox.SelectedIndex = 0;
this.combinationDataGridView.DataSource = null;
this.combinationDataGridView.DataSource = m_dataBuffer.LoadCombinationMap;
this.formulaDataGridView.DataSource = null;
this.formulaDataGridView.DataSource = m_dataBuffer.FormulaMap;
// Set the state of the button on this page and refresh.
CombinationsTabPageButtonEnable();
this.Refresh();
}
/// <summary>
/// Delete Combination Button
/// </summary>
private void deleteCombinationButton_Click(object sender, EventArgs e)
{
// Get selected index in Combination DataGridView
int index = combinationDataGridView.CurrentRow.Index;
if (0 > index)
{
TaskDialog.Show("Revit", "The program should go here.");
return;
}
// Begin to delete the combination
if (!m_dataBuffer.DeleteCombination(index))
{
TaskDialog.Show("Revit", m_dataBuffer.ErrorInformation);
return;
}
// After deleting combination, refresh combination DataGridView
this.combinationDataGridView.DataSource = null;
this.combinationDataGridView.DataSource = m_dataBuffer.LoadCombinationMap;
// Set the state of the button on this page and refresh.
CombinationsTabPageButtonEnable();
this.Refresh();
}
/// <summary>
/// Add Formula Button
/// </summary>
private void formulaAddButton_Click(object sender, EventArgs e)
{
// Add formula.
if (!m_dataBuffer.AddFormula())
{
TaskDialog.Show("Revit", m_dataBuffer.ErrorInformation);
return;
}
// After adding formula, refresh formula DataGridView
this.formulaDataGridView.DataSource = null;
this.formulaDataGridView.DataSource = m_dataBuffer.FormulaMap;
// Set the state of the button on this page and refresh.
CombinationsTabPageButtonEnable();
this.Refresh();
}
/// <summary>
/// Delete Formula Button
/// </summary>
private void formulaDeleteButton_Click(object sender, EventArgs e)
{
// Get selected index in formula DataGridView
int index = formulaDataGridView.CurrentRow.Index;
if (0 > index)
{
TaskDialog.Show("Revit", "The program should go here.");
return;
}
// Begin to delete the formula
if (!m_dataBuffer.DeleteFormula(index))
{
TaskDialog.Show("Revit", m_dataBuffer.ErrorInformation);
return;
}
// After deleting formula, refresh formula DataGridView
this.formulaDataGridView.DataSource = null;
this.formulaDataGridView.DataSource = m_dataBuffer.FormulaMap;
// Set the state of the button on this page and refresh.
CombinationsTabPageButtonEnable();
this.Refresh();
}
// The following is the event when the DataGridView got focus
private void combinationDataGridView_GotFocus(object sender, EventArgs e)
{
CombinationsTabPageButtonEnable();
}
/// <summary>
/// If the formulaDataGridView get focus, enable the buttons in CombinationsTabPage
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void formulaDataGridView_GotFocus(object sender, EventArgs e)
{
CombinationsTabPageButtonEnable();
}
/// <summary>
/// If the usageDataGridView get focus, enable the buttons in CombinationsTabPage
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void usageDataGridView_GotFocus(object sender, EventArgs e)
{
CombinationsTabPageButtonEnable();
}
/// <summary>
/// The following is the event when the usage DataGridView selection changed
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void usageDataGridView_SelectionChanged(object sender, EventArgs e)
{
CombinationsTabPageButtonEnable();
}
/// <summary>
/// This method used to check the state of all the buttons on Load Combination page,
/// and judge whether the buttons should be enable or disable.
/// </summary>
private void CombinationsTabPageButtonEnable()
{
// first make each button to unable
Boolean usageCheckAllButtonEnabled = true;
Boolean usageCheckNoneButtonEnabled = true;
Boolean usageAddButtonEnabled = true;
Boolean usageDeleteButtonEnabled = true;
Boolean newCombinationButtonEnabled = true;
Boolean deleteCombinationButtonEnabled = true;
Boolean formulaAddButtonEnabled = true;
Boolean formulaDeleteButtonEnabled = true;
// If there is no LoadCase,
// All the button control formula should be disable
if (0 == m_dataBuffer.LoadCases.Count)
{
formulaAddButtonEnabled = false;
formulaDeleteButtonEnabled = false;
}
// If the usage DataGridView has no data
// CheckAll, CheckNone, Delete button should be disable
if (0 == m_dataBuffer.UsageMap.Count)
{
usageCheckAllButtonEnabled = false;
usageCheckNoneButtonEnabled = false;
usageDeleteButtonEnabled = false;
}
else
{
int checkedCount = 0;
foreach (UsageMap map in m_dataBuffer.UsageMap)
{
if (true == map.Set)
{
checkedCount++;
}
}
if (checkedCount <= 0)
{
usageCheckAllButtonEnabled = true;
usageCheckNoneButtonEnabled = false;
}
else if (checkedCount > 0 && checkedCount < m_dataBuffer.UsageMap.Count)
{
usageCheckAllButtonEnabled = true;
usageCheckNoneButtonEnabled = true;
}
else
{
usageCheckAllButtonEnabled = false;
usageCheckNoneButtonEnabled = true;
}
}
// If the formula DataGridView has no data or is not focused
// Delete formula button should be disable
if (0 == m_dataBuffer.FormulaMap.Count)
{
formulaDeleteButtonEnabled = false;
}
// If the combination DataGridView has no data or is not focused
// Delete combination button should be disable.
if (0 == m_dataBuffer.LoadCombinationMap.Count)
{
deleteCombinationButtonEnabled = false;
}
// At last, set the Buttons state
usageCheckAllButton.Enabled = usageCheckAllButtonEnabled;
usageCheckNoneButton.Enabled = usageCheckNoneButtonEnabled;
usageAddButton.Enabled = usageAddButtonEnabled;
usageDeleteButton.Enabled = usageDeleteButtonEnabled;
newCombinationButton.Enabled = newCombinationButtonEnabled;
deleteCombinationButton.Enabled = deleteCombinationButtonEnabled;
formulaAddButton.Enabled = formulaAddButtonEnabled;
formulaDeleteButton.Enabled = formulaDeleteButtonEnabled;
}
private void usageDataGridView_CellValueChanged(object sender, DataGridViewCellEventArgs e)
{
CombinationsTabPageButtonEnable();
}
}
}
+13
View File
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<RevitAddIns>
<AddIn Type="Command">
<Assembly>Loads.dll</Assembly>
<ClientId>1f98ed8c-f1f6-4b06-8fc6-149667f9e529</ClientId>
<FullClassName>Revit.SDK.Samples.Loads.CS.Loads</FullClassName>
<Text>Loads</Text>
<Description>Show how to use load case, nature, usage and combination.</Description>
<VisibilityMode>AlwaysVisible</VisibilityMode>
<VendorId>ADSK</VendorId>
<VendorDescription>Autodesk, www.autodesk.com</VendorDescription>
</AddIn>
</RevitAddIns>
+433
View File
@@ -0,0 +1,433 @@
//
// (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 System.Windows.Forms;
using Autodesk;
using Autodesk.Revit;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;
using Autodesk.Revit.DB.Structure;
namespace Revit.SDK.Samples.Loads.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 Loads : IExternalCommand
{
#region Private Data Members
// Mainly used data definition
Autodesk.Revit.ApplicationServices.Application m_revit; // Store the reference of revit
LoadCombinationDeal m_combinationDeal; // the deal class on load combination page
LoadCaseDeal m_loadCaseDeal; // the deal class on load case page
String m_errorInformation; // Store the error information
// Define the data mainly used in LoadCombinationDeal class
List<String> m_usageNameList; // Store all the usage names in current document
List<LoadUsage> m_loadUsageList; // Used to store all the load usages
List<String> m_combinationNameList; // Store all the combination names in current document
List<LoadCombinationMap> m_LoadCombinationMap;
// Store all the Load Combination information include the user add.
List<FormulaMap> m_formulaMap; // Store the formula information the user add
List<UsageMap> m_usageMap;
// Define the data mainly used in LoadCaseDeal class
List<Category> m_loadCasesCategory; //Store the load case's category
List<LoadCase> m_loadCases; //Store all the load cases in current document
List<LoadNature> m_loadNatures; //Store all the load natures in current document
List<LoadCasesMap> m_loadCasesMap; // Store all the load case information include the user add.
List<LoadNaturesMap> m_loadNaturesMap; //Store all the load natures information
#endregion
#region Properties
/// <summary>
/// Used as the dataSource of load cases DataGridView control,
/// and the information which support load case creation also.
/// </summary>
public List<LoadCasesMap> LoadCasesMap
{
get
{
return m_loadCasesMap;
}
}
/// <summary>
/// Used as the dataSource of load natures DataGridView control,
/// and the information which support load nature creation also.
/// </summary>
public List<LoadNaturesMap> LoadNaturesMap
{
get
{
return m_loadNaturesMap;
}
}
/// <summary>
/// save all loadnature object in current project
/// </summary>
public List<LoadNature> LoadNatures
{
get
{
return m_loadNatures;
}
}
/// <summary>
/// save all loadcase object in current project
/// </summary>
public List<LoadCase> LoadCases
{
get
{
return m_loadCases;
}
}
/// <summary>
/// save all load cases category in current project
/// </summary>
public List<Category> LoadCaseCategories
{
get
{
return m_loadCasesCategory;
}
}
/// <summary>
/// object which do add, delete and update command on load related objects
/// </summary>
public LoadCaseDeal LoadCasesDeal
{
get
{
return m_loadCaseDeal;
}
}
/// <summary>
/// Store the reference of revit
/// </summary>
public Autodesk.Revit.ApplicationServices.Application RevitApplication
{
get
{
return m_revit;
}
}
/// <summary>
/// LoadUsageNames property, used to store all the usage names in current document
/// </summary>
public List<String> LoadUsageNames
{
get
{
return m_usageNameList;
}
}
/// <summary>
/// Used to store all the load usages in current document, include the user add
/// </summary>
public List<LoadUsage> LoadUsages
{
get
{
return m_loadUsageList;
}
}
/// <summary>
/// LoadCombinationNames property, used to store all the combination names in current document
/// </summary>
public List<String> LoadCombinationNames
{
get
{
return m_combinationNameList;
}
}
/// <summary>
/// Show the error information while contact with revit
/// </summary>
public String ErrorInformation
{
get
{
return m_errorInformation;
}
set
{
m_errorInformation = value;
}
}
/// <summary>
/// Used as the dataSource of load combination DataGridView control,
/// and the information which support load combination creation also.
/// </summary>
public List<LoadCombinationMap> LoadCombinationMap
{
get
{
return m_LoadCombinationMap;
}
}
/// <summary>
/// Store all load combination formula names
/// </summary>
public List<FormulaMap> FormulaMap
{
get
{
return m_formulaMap;
}
}
/// <summary>
/// Store all load usage
/// </summary>
public List<UsageMap> UsageMap
{
get
{
return m_usageMap;
}
}
#endregion
#region Methods
/// <summary>
/// Default constructor of Loads
/// </summary>
public Loads()
{
m_usageNameList = new List<string>();
m_combinationNameList = new List<string>();
m_LoadCombinationMap = new List<LoadCombinationMap>();
m_loadUsageList = new List<LoadUsage>();
m_formulaMap = new List<FormulaMap>();
m_usageMap = new List<UsageMap>();
m_loadCasesCategory = new List<Category>();
m_loadCases = new List<LoadCase>();
m_loadNatures = new List<LoadNature>();
m_loadCasesMap = new List<LoadCasesMap>();
m_loadNaturesMap = new List<LoadNaturesMap>();
}
/// <summary>
/// Implement this method as an external command for Revit.
/// </summary>
/// <param name="commandData">An object that is passed to the external application
/// which contains data related to the command,
/// such as the application object and active view.</param>
/// <param name="message">A message that can be set by the external application
/// which will be displayed if a failure or cancellation is returned by
/// the external command.</param>
/// <param name="elements">A set of elements to which the external application
/// can add elements that are to be highlighted in case of failure or cancellation.</param>
/// <returns>Return the status of the external command.
/// A result of Succeeded means that the API external method functioned as expected.
/// Cancelled can be used to signify that the user cancelled the external operation
/// at some point. Failure should be returned if the application is unable to proceed with
/// the operation.</returns>
public Autodesk.Revit.UI.Result Execute(ExternalCommandData commandData,
ref string message, Autodesk.Revit.DB.ElementSet elements)
{
m_revit = commandData.Application.Application;
Transaction documentTransaction = new Transaction(commandData.Application.ActiveUIDocument.Document, "Document");
documentTransaction.Start();
// Initialize the helper classes.
m_combinationDeal = new LoadCombinationDeal(this);
m_loadCaseDeal = new LoadCaseDeal(this);
// Prepare some data for the form displaying
PrepareData();
// Display the form and wait for the user's operate.
// This class give some public methods to add or delete LoadUsage and delete LoadCombination
// The form will use these methods to add or delete dynamically.
// If the user press cancel button, return Cancelled to roll back All the changes.
using (LoadsForm displayForm = new LoadsForm(this))
{
if (DialogResult.OK != displayForm.ShowDialog())
{
documentTransaction.RollBack();
return Autodesk.Revit.UI.Result.Cancelled;
}
}
// If everything goes right, return succeeded.
documentTransaction.Commit();
return Autodesk.Revit.UI.Result.Succeeded;
}
/// <summary>
/// Prepare the data for the form displaying.
/// </summary>
void PrepareData()
{
// Prepare the data of the LoadCase page on form
m_loadCaseDeal.PrepareData();
//Prepare the data of the LoadCombination page on form
m_combinationDeal.PrepareData();
}
/// <summary>
/// Create new Load Combination
/// </summary>
/// <param name="name">The new Load Combination name</param>
/// <param name="typeId">The index of new Load Combination Type</param>
/// <param name="stateId">The index of new Load Combination State</param>
/// <returns>true if the creation was successful; otherwise, false</returns>
public Boolean NewLoadCombination(String name, int typeId, int stateId)
{
// In order to refresh the combination DataGridView,
// We should do like as follow
m_LoadCombinationMap = new List<LoadCombinationMap>(m_LoadCombinationMap);
// Just go to run NewLoadCombination method of LoadCombinationDeal class
return m_combinationDeal.NewLoadCombination(name, typeId, stateId);
}
/// <summary>
/// Delete the selected Load Combination
/// </summary>
/// <param name="index">The selected index in the DataGridView</param>
/// <returns>true if the delete operation was successful; otherwise, false</returns>
public Boolean DeleteCombination(int index)
{
// Just go to run DeleteCombination method of LoadCombinationDeal class
return m_combinationDeal.DeleteCombination(index);
}
/// <summary>
/// Create a new load combination usage
/// </summary>
/// <param name="usageName">The new Load Usage name</param>
/// <returns>true if the process is successful; otherwise, false</returns>
public Boolean NewLoadUsage(String usageName)
{
// In order to refresh the usage DataGridView,
// We should do like as follow
m_usageMap = new List<UsageMap>(m_usageMap);
// Just go to run NewLoadUsage method of LoadCombinationDeal class
return m_combinationDeal.NewLoadUsage(usageName);
}
/// <summary>
/// Delete the selected Load Usage
/// </summary>
/// <param name="index">The selected index in the DataGridView</param>
/// <returns>true if the delete operation was successful; otherwise, false</returns>
public Boolean DeleteUsage(int index)
{
// Just go to run DeleteUsage method of LoadCombinationDeal class
if (false == m_combinationDeal.DeleteUsage(index))
{
return false;
}
// In order to refresh the usage DataGridView,
// We should do like as follow
if (0 == m_usageMap.Count)
{
m_usageMap = new List<UsageMap>();
}
return true;
}
/// <summary>
/// Change usage name when the user modify it on the form
/// </summary>
/// <param name="oldName">The name before modification</param>
/// <param name="newName">The name after modification</param>
/// <returns>true if the modification was successful; otherwise, false</returns>
public Boolean ModifyUsageName(String oldName, String newName)
{
// Just go to run ModifyUsageName method of LoadCombinationDeal class
return m_combinationDeal.ModifyUsageName(oldName, newName);
}
/// <summary>
/// Add a formula when the user click Add button to new a formula
/// </summary>
/// <returns>true if the creation is successful; otherwise, false</returns>
public Boolean AddFormula()
{
// Get the first member in LoadCases as the Case
LoadCase loadCase = m_loadCases[0];
if (null == loadCase)
{
m_errorInformation = "Can't not find a LoadCase.";
return false;
}
String caseName = loadCase.Name;
// In order to refresh the formula DataGridView,
// We should do like as follow
m_formulaMap = new List<FormulaMap>(m_formulaMap);
// Run AddFormula method of LoadCombinationDeal class
return m_combinationDeal.AddFormula(caseName);
}
/// <summary>
/// Delete the selected Load Formula
/// </summary>
/// <param name="index">The selected index in the DataGridView</param>
/// <returns>true if the delete operation was successful; otherwise, false</returns>
public Boolean DeleteFormula(int index)
{
// Just remove that data.
try
{
m_formulaMap.RemoveAt(index);
}
catch (Exception e)
{
m_errorInformation = e.ToString();
return false;
}
return true;
}
#endregion
}
}
+117
View File
@@ -0,0 +1,117 @@
<?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>{62E74082-D02B-4E8D-8A0B-72C20B339CB1}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Loads</RootNamespace>
<AssemblyName>Loads</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="LoadCaseDeal.cs" />
<Compile Include="LoadCaseMap.cs" />
<Compile Include="LoadCaseTabPage.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="LoadCombinationDeal.cs" />
<Compile Include="LoadCombinationFormulaMap.cs" />
<Compile Include="LoadCombinationMap.cs" />
<Compile Include="LoadCombinationsTabPage.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="LoadCombinationUsageMap.cs" />
<Compile Include="Loads.cs" />
<Compile Include="LoadsForm.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="LoadsForm.Designer.cs">
<DependentUpon>LoadsForm.cs</DependentUpon>
</Compile>
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="LoadsForm.resx">
<SubType>Designer</SubType>
<DependentUpon>LoadsForm.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>
+530
View File
@@ -0,0 +1,530 @@
//
// (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.Loads.CS
{
partial class LoadsForm
{
/// <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()
{
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle();
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle();
this.tabControl1 = new System.Windows.Forms.TabControl();
this.loadCasesTabPage = new System.Windows.Forms.TabPage();
this.addLoadNaturesButton = new System.Windows.Forms.Button();
this.duplicateLoadCasesButton = new System.Windows.Forms.Button();
this.loadNaturesroupBox = new System.Windows.Forms.GroupBox();
this.loadNaturesDataGridView = new System.Windows.Forms.DataGridView();
this.loadCasesGroupBox = new System.Windows.Forms.GroupBox();
this.loadCasesDataGridView = new System.Windows.Forms.DataGridView();
this.LoadCombinationsTabPage = new System.Windows.Forms.TabPage();
this.combinationCreationGroupBox = new System.Windows.Forms.GroupBox();
this.deleteCombinationButton = new System.Windows.Forms.Button();
this.newCombinationButton = new System.Windows.Forms.Button();
this.combinationStateComboBox = new System.Windows.Forms.ComboBox();
this.combinationStateLabel = new System.Windows.Forms.Label();
this.combinationTypeComboBox = new System.Windows.Forms.ComboBox();
this.combinationTypeLabel = new System.Windows.Forms.Label();
this.combinationNameTextBox = new System.Windows.Forms.TextBox();
this.combinnationNameLabel = new System.Windows.Forms.Label();
this.combinationFormulaGroupBox = new System.Windows.Forms.GroupBox();
this.formulaDeleteButton = new System.Windows.Forms.Button();
this.formulaAddButton = new System.Windows.Forms.Button();
this.formulaDataGridView = new System.Windows.Forms.DataGridView();
this.usageGroupBox = new System.Windows.Forms.GroupBox();
this.usageDataGridView = new System.Windows.Forms.DataGridView();
this.usageDeleteButton = new System.Windows.Forms.Button();
this.usageAddButton = new System.Windows.Forms.Button();
this.usageCheckNoneButton = new System.Windows.Forms.Button();
this.usageCheckAllButton = new System.Windows.Forms.Button();
this.combinationInfoGroupBox = new System.Windows.Forms.GroupBox();
this.combinationDataGridView = new System.Windows.Forms.DataGridView();
this.okButton = new System.Windows.Forms.Button();
this.cancelButton = new System.Windows.Forms.Button();
this.tabControl1.SuspendLayout();
this.loadCasesTabPage.SuspendLayout();
this.loadNaturesroupBox.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.loadNaturesDataGridView)).BeginInit();
this.loadCasesGroupBox.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.loadCasesDataGridView)).BeginInit();
this.LoadCombinationsTabPage.SuspendLayout();
this.combinationCreationGroupBox.SuspendLayout();
this.combinationFormulaGroupBox.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.formulaDataGridView)).BeginInit();
this.usageGroupBox.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.usageDataGridView)).BeginInit();
this.combinationInfoGroupBox.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.combinationDataGridView)).BeginInit();
this.SuspendLayout();
//
// tabControl1
//
this.tabControl1.Controls.Add(this.loadCasesTabPage);
this.tabControl1.Controls.Add(this.LoadCombinationsTabPage);
this.tabControl1.Location = new System.Drawing.Point(12, 12);
this.tabControl1.Name = "tabControl1";
this.tabControl1.SelectedIndex = 0;
this.tabControl1.Size = new System.Drawing.Size(699, 475);
this.tabControl1.TabIndex = 0;
//
// loadCasesTabPage
//
this.loadCasesTabPage.Controls.Add(this.addLoadNaturesButton);
this.loadCasesTabPage.Controls.Add(this.duplicateLoadCasesButton);
this.loadCasesTabPage.Controls.Add(this.loadNaturesroupBox);
this.loadCasesTabPage.Controls.Add(this.loadCasesGroupBox);
this.loadCasesTabPage.Location = new System.Drawing.Point(4, 22);
this.loadCasesTabPage.Name = "loadCasesTabPage";
this.loadCasesTabPage.Padding = new System.Windows.Forms.Padding(3);
this.loadCasesTabPage.Size = new System.Drawing.Size(691, 449);
this.loadCasesTabPage.TabIndex = 0;
this.loadCasesTabPage.Text = "Load Cases";
this.loadCasesTabPage.UseVisualStyleBackColor = true;
//
// addLoadNaturesButton
//
this.addLoadNaturesButton.Location = new System.Drawing.Point(609, 273);
this.addLoadNaturesButton.Name = "addLoadNaturesButton";
this.addLoadNaturesButton.Size = new System.Drawing.Size(75, 23);
this.addLoadNaturesButton.TabIndex = 4;
this.addLoadNaturesButton.Text = "&Add";
this.addLoadNaturesButton.UseVisualStyleBackColor = true;
this.addLoadNaturesButton.Click += new System.EventHandler(this.addLoadNaturesButton_Click);
//
// duplicateLoadCasesButton
//
this.duplicateLoadCasesButton.Location = new System.Drawing.Point(609, 42);
this.duplicateLoadCasesButton.Name = "duplicateLoadCasesButton";
this.duplicateLoadCasesButton.Size = new System.Drawing.Size(75, 23);
this.duplicateLoadCasesButton.TabIndex = 3;
this.duplicateLoadCasesButton.Text = "&Duplicate";
this.duplicateLoadCasesButton.UseVisualStyleBackColor = true;
this.duplicateLoadCasesButton.Click += new System.EventHandler(this.duplicateLoadCasesButton_Click);
//
// loadNaturesroupBox
//
this.loadNaturesroupBox.Controls.Add(this.loadNaturesDataGridView);
this.loadNaturesroupBox.Location = new System.Drawing.Point(30, 244);
this.loadNaturesroupBox.Name = "loadNaturesroupBox";
this.loadNaturesroupBox.Size = new System.Drawing.Size(573, 190);
this.loadNaturesroupBox.TabIndex = 1;
this.loadNaturesroupBox.TabStop = false;
this.loadNaturesroupBox.Text = "Load Natures";
//
// loadNaturesDataGridView
//
this.loadNaturesDataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.loadNaturesDataGridView.Location = new System.Drawing.Point(7, 20);
this.loadNaturesDataGridView.Name = "loadNaturesDataGridView";
this.loadNaturesDataGridView.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.CellSelect;
this.loadNaturesDataGridView.Size = new System.Drawing.Size(560, 164);
this.loadNaturesDataGridView.TabIndex = 0;
this.loadNaturesDataGridView.CellClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.loadNaturesDataGridView_CellClick);
this.loadNaturesDataGridView.RowHeaderMouseClick += new System.Windows.Forms.DataGridViewCellMouseEventHandler(this.loadNaturesDataGridView_RowHeaderMouseClick);
this.loadNaturesDataGridView.CellValidating += new System.Windows.Forms.DataGridViewCellValidatingEventHandler(this.loadNaturesDataGridView_CellValidating);
//
// loadCasesGroupBox
//
this.loadCasesGroupBox.Controls.Add(this.loadCasesDataGridView);
this.loadCasesGroupBox.Location = new System.Drawing.Point(30, 23);
this.loadCasesGroupBox.Name = "loadCasesGroupBox";
this.loadCasesGroupBox.Size = new System.Drawing.Size(573, 215);
this.loadCasesGroupBox.TabIndex = 0;
this.loadCasesGroupBox.TabStop = false;
this.loadCasesGroupBox.Text = "Load Cases";
//
// loadCasesDataGridView
//
dataGridViewCellStyle1.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
dataGridViewCellStyle1.BackColor = System.Drawing.Color.Gray;
dataGridViewCellStyle1.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
dataGridViewCellStyle1.ForeColor = System.Drawing.SystemColors.WindowText;
dataGridViewCellStyle1.SelectionBackColor = System.Drawing.SystemColors.Highlight;
dataGridViewCellStyle1.SelectionForeColor = System.Drawing.SystemColors.HighlightText;
dataGridViewCellStyle1.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
this.loadCasesDataGridView.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle1;
this.loadCasesDataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.loadCasesDataGridView.GridColor = System.Drawing.SystemColors.ActiveBorder;
this.loadCasesDataGridView.Location = new System.Drawing.Point(7, 19);
this.loadCasesDataGridView.Name = "loadCasesDataGridView";
dataGridViewCellStyle2.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
dataGridViewCellStyle2.BackColor = System.Drawing.Color.Silver;
dataGridViewCellStyle2.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
dataGridViewCellStyle2.ForeColor = System.Drawing.SystemColors.WindowText;
dataGridViewCellStyle2.SelectionBackColor = System.Drawing.SystemColors.Highlight;
dataGridViewCellStyle2.SelectionForeColor = System.Drawing.SystemColors.HighlightText;
dataGridViewCellStyle2.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
this.loadCasesDataGridView.RowHeadersDefaultCellStyle = dataGridViewCellStyle2;
this.loadCasesDataGridView.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.CellSelect;
this.loadCasesDataGridView.Size = new System.Drawing.Size(560, 190);
this.loadCasesDataGridView.TabIndex = 0;
this.loadCasesDataGridView.CellClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.loadCasesDataGridView_CellClick);
this.loadCasesDataGridView.ColumnHeaderMouseClick += new System.Windows.Forms.DataGridViewCellMouseEventHandler(this.loadCasesDataGridView_ColumnHeaderMouseClick);
this.loadCasesDataGridView.CellValidating += new System.Windows.Forms.DataGridViewCellValidatingEventHandler(this.loadCasesDataGridView_CellValidating);
//
// LoadCombinationsTabPage
//
this.LoadCombinationsTabPage.Controls.Add(this.combinationCreationGroupBox);
this.LoadCombinationsTabPage.Controls.Add(this.combinationInfoGroupBox);
this.LoadCombinationsTabPage.Location = new System.Drawing.Point(4, 22);
this.LoadCombinationsTabPage.Name = "LoadCombinationsTabPage";
this.LoadCombinationsTabPage.Padding = new System.Windows.Forms.Padding(3);
this.LoadCombinationsTabPage.Size = new System.Drawing.Size(691, 449);
this.LoadCombinationsTabPage.TabIndex = 1;
this.LoadCombinationsTabPage.Text = "Load Combinations";
this.LoadCombinationsTabPage.UseVisualStyleBackColor = true;
//
// combinationCreationGroupBox
//
this.combinationCreationGroupBox.Controls.Add(this.deleteCombinationButton);
this.combinationCreationGroupBox.Controls.Add(this.newCombinationButton);
this.combinationCreationGroupBox.Controls.Add(this.combinationStateComboBox);
this.combinationCreationGroupBox.Controls.Add(this.combinationStateLabel);
this.combinationCreationGroupBox.Controls.Add(this.combinationTypeComboBox);
this.combinationCreationGroupBox.Controls.Add(this.combinationTypeLabel);
this.combinationCreationGroupBox.Controls.Add(this.combinationNameTextBox);
this.combinationCreationGroupBox.Controls.Add(this.combinnationNameLabel);
this.combinationCreationGroupBox.Controls.Add(this.combinationFormulaGroupBox);
this.combinationCreationGroupBox.Controls.Add(this.usageGroupBox);
this.combinationCreationGroupBox.Location = new System.Drawing.Point(18, 203);
this.combinationCreationGroupBox.Name = "combinationCreationGroupBox";
this.combinationCreationGroupBox.Size = new System.Drawing.Size(651, 229);
this.combinationCreationGroupBox.TabIndex = 1;
this.combinationCreationGroupBox.TabStop = false;
this.combinationCreationGroupBox.Text = "Load Combination Creation";
//
// deleteCombinationButton
//
this.deleteCombinationButton.Location = new System.Drawing.Point(486, 193);
this.deleteCombinationButton.Name = "deleteCombinationButton";
this.deleteCombinationButton.Size = new System.Drawing.Size(146, 23);
this.deleteCombinationButton.TabIndex = 9;
this.deleteCombinationButton.Text = "D&elete Combination";
this.deleteCombinationButton.UseVisualStyleBackColor = true;
this.deleteCombinationButton.Click += new System.EventHandler(this.deleteCombinationButton_Click);
//
// newCombinationButton
//
this.newCombinationButton.Location = new System.Drawing.Point(486, 150);
this.newCombinationButton.Name = "newCombinationButton";
this.newCombinationButton.Size = new System.Drawing.Size(146, 23);
this.newCombinationButton.TabIndex = 8;
this.newCombinationButton.Text = "&New Combination";
this.newCombinationButton.UseVisualStyleBackColor = true;
this.newCombinationButton.Click += new System.EventHandler(this.newCombinationButton_Click);
//
// combinationStateComboBox
//
this.combinationStateComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.combinationStateComboBox.FormattingEnabled = true;
this.combinationStateComboBox.Location = new System.Drawing.Point(528, 109);
this.combinationStateComboBox.Name = "combinationStateComboBox";
this.combinationStateComboBox.Size = new System.Drawing.Size(104, 21);
this.combinationStateComboBox.TabIndex = 7;
//
// combinationStateLabel
//
this.combinationStateLabel.AutoSize = true;
this.combinationStateLabel.Location = new System.Drawing.Point(483, 112);
this.combinationStateLabel.Name = "combinationStateLabel";
this.combinationStateLabel.Size = new System.Drawing.Size(35, 13);
this.combinationStateLabel.TabIndex = 6;
this.combinationStateLabel.Text = "State:";
//
// combinationTypeComboBox
//
this.combinationTypeComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.combinationTypeComboBox.FormattingEnabled = true;
this.combinationTypeComboBox.Location = new System.Drawing.Point(528, 66);
this.combinationTypeComboBox.Name = "combinationTypeComboBox";
this.combinationTypeComboBox.Size = new System.Drawing.Size(104, 21);
this.combinationTypeComboBox.TabIndex = 5;
//
// combinationTypeLabel
//
this.combinationTypeLabel.AutoSize = true;
this.combinationTypeLabel.Location = new System.Drawing.Point(483, 69);
this.combinationTypeLabel.Name = "combinationTypeLabel";
this.combinationTypeLabel.Size = new System.Drawing.Size(34, 13);
this.combinationTypeLabel.TabIndex = 4;
this.combinationTypeLabel.Text = "Type:";
//
// combinationNameTextBox
//
this.combinationNameTextBox.Location = new System.Drawing.Point(528, 25);
this.combinationNameTextBox.Name = "combinationNameTextBox";
this.combinationNameTextBox.Size = new System.Drawing.Size(104, 20);
this.combinationNameTextBox.TabIndex = 3;
//
// combinnationNameLabel
//
this.combinnationNameLabel.AutoSize = true;
this.combinnationNameLabel.Location = new System.Drawing.Point(483, 28);
this.combinnationNameLabel.Name = "combinnationNameLabel";
this.combinnationNameLabel.Size = new System.Drawing.Size(38, 13);
this.combinnationNameLabel.TabIndex = 2;
this.combinnationNameLabel.Text = "Name:";
//
// combinationFormulaGroupBox
//
this.combinationFormulaGroupBox.Controls.Add(this.formulaDeleteButton);
this.combinationFormulaGroupBox.Controls.Add(this.formulaAddButton);
this.combinationFormulaGroupBox.Controls.Add(this.formulaDataGridView);
this.combinationFormulaGroupBox.Location = new System.Drawing.Point(279, 19);
this.combinationFormulaGroupBox.Name = "combinationFormulaGroupBox";
this.combinationFormulaGroupBox.Size = new System.Drawing.Size(201, 197);
this.combinationFormulaGroupBox.TabIndex = 1;
this.combinationFormulaGroupBox.TabStop = false;
this.combinationFormulaGroupBox.Text = "Load Combination Formula";
//
// formulaDeleteButton
//
this.formulaDeleteButton.Location = new System.Drawing.Point(112, 168);
this.formulaDeleteButton.Name = "formulaDeleteButton";
this.formulaDeleteButton.Size = new System.Drawing.Size(75, 23);
this.formulaDeleteButton.TabIndex = 6;
this.formulaDeleteButton.Text = "D&elete";
this.formulaDeleteButton.UseVisualStyleBackColor = true;
this.formulaDeleteButton.Click += new System.EventHandler(this.formulaDeleteButton_Click);
//
// formulaAddButton
//
this.formulaAddButton.Location = new System.Drawing.Point(15, 168);
this.formulaAddButton.Name = "formulaAddButton";
this.formulaAddButton.Size = new System.Drawing.Size(75, 23);
this.formulaAddButton.TabIndex = 5;
this.formulaAddButton.Text = "&Add";
this.formulaAddButton.UseVisualStyleBackColor = true;
this.formulaAddButton.Click += new System.EventHandler(this.formulaAddButton_Click);
//
// formulaDataGridView
//
this.formulaDataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.formulaDataGridView.Location = new System.Drawing.Point(15, 25);
this.formulaDataGridView.Name = "formulaDataGridView";
this.formulaDataGridView.Size = new System.Drawing.Size(172, 129);
this.formulaDataGridView.TabIndex = 4;
this.formulaDataGridView.GotFocus += new System.EventHandler(this.formulaDataGridView_GotFocus);
//
// usageGroupBox
//
this.usageGroupBox.Controls.Add(this.usageDataGridView);
this.usageGroupBox.Controls.Add(this.usageDeleteButton);
this.usageGroupBox.Controls.Add(this.usageAddButton);
this.usageGroupBox.Controls.Add(this.usageCheckNoneButton);
this.usageGroupBox.Controls.Add(this.usageCheckAllButton);
this.usageGroupBox.Location = new System.Drawing.Point(16, 19);
this.usageGroupBox.Name = "usageGroupBox";
this.usageGroupBox.Size = new System.Drawing.Size(257, 197);
this.usageGroupBox.TabIndex = 0;
this.usageGroupBox.TabStop = false;
this.usageGroupBox.Text = "Load Combination Usage";
//
// usageDataGridView
//
this.usageDataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.usageDataGridView.Location = new System.Drawing.Point(6, 25);
this.usageDataGridView.Name = "usageDataGridView";
this.usageDataGridView.Size = new System.Drawing.Size(164, 159);
this.usageDataGridView.TabIndex = 5;
this.usageDataGridView.GotFocus += new System.EventHandler(this.usageDataGridView_GotFocus);
this.usageDataGridView.CellValueChanged += new System.Windows.Forms.DataGridViewCellEventHandler(this.usageDataGridView_CellValueChanged);
this.usageDataGridView.SelectionChanged += new System.EventHandler(this.usageDataGridView_SelectionChanged);
//
// usageDeleteButton
//
this.usageDeleteButton.Location = new System.Drawing.Point(176, 161);
this.usageDeleteButton.Name = "usageDeleteButton";
this.usageDeleteButton.Size = new System.Drawing.Size(75, 23);
this.usageDeleteButton.TabIndex = 4;
this.usageDeleteButton.Text = "D&elete";
this.usageDeleteButton.UseVisualStyleBackColor = true;
this.usageDeleteButton.Click += new System.EventHandler(this.usageDeleteButton_Click);
//
// usageAddButton
//
this.usageAddButton.Location = new System.Drawing.Point(176, 115);
this.usageAddButton.Name = "usageAddButton";
this.usageAddButton.Size = new System.Drawing.Size(75, 23);
this.usageAddButton.TabIndex = 3;
this.usageAddButton.Text = "Ad&d";
this.usageAddButton.UseVisualStyleBackColor = true;
this.usageAddButton.Click += new System.EventHandler(this.usageAddButton_Click);
//
// usageCheckNoneButton
//
this.usageCheckNoneButton.Location = new System.Drawing.Point(176, 72);
this.usageCheckNoneButton.Name = "usageCheckNoneButton";
this.usageCheckNoneButton.Size = new System.Drawing.Size(75, 23);
this.usageCheckNoneButton.TabIndex = 2;
this.usageCheckNoneButton.Text = "Check &None";
this.usageCheckNoneButton.UseVisualStyleBackColor = true;
this.usageCheckNoneButton.Click += new System.EventHandler(this.usageCheckNoneButton_Click);
//
// usageCheckAllButton
//
this.usageCheckAllButton.Location = new System.Drawing.Point(176, 25);
this.usageCheckAllButton.Name = "usageCheckAllButton";
this.usageCheckAllButton.Size = new System.Drawing.Size(75, 23);
this.usageCheckAllButton.TabIndex = 1;
this.usageCheckAllButton.Text = "Check &All";
this.usageCheckAllButton.UseVisualStyleBackColor = true;
this.usageCheckAllButton.Click += new System.EventHandler(this.usageCheckAllButton_Click);
//
// combinationInfoGroupBox
//
this.combinationInfoGroupBox.Controls.Add(this.combinationDataGridView);
this.combinationInfoGroupBox.Location = new System.Drawing.Point(18, 17);
this.combinationInfoGroupBox.Name = "combinationInfoGroupBox";
this.combinationInfoGroupBox.Size = new System.Drawing.Size(651, 180);
this.combinationInfoGroupBox.TabIndex = 0;
this.combinationInfoGroupBox.TabStop = false;
this.combinationInfoGroupBox.Text = "Load Combination Information";
//
// combinationDataGridView
//
this.combinationDataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.combinationDataGridView.Location = new System.Drawing.Point(16, 19);
this.combinationDataGridView.Name = "combinationDataGridView";
this.combinationDataGridView.Size = new System.Drawing.Size(616, 144);
this.combinationDataGridView.TabIndex = 0;
this.combinationDataGridView.GotFocus += new System.EventHandler(this.combinationDataGridView_GotFocus);
//
// okButton
//
this.okButton.DialogResult = System.Windows.Forms.DialogResult.OK;
this.okButton.Location = new System.Drawing.Point(528, 493);
this.okButton.Name = "okButton";
this.okButton.Size = new System.Drawing.Size(75, 23);
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(632, 493);
this.cancelButton.Name = "cancelButton";
this.cancelButton.Size = new System.Drawing.Size(75, 23);
this.cancelButton.TabIndex = 2;
this.cancelButton.Text = "&Cancel";
this.cancelButton.UseVisualStyleBackColor = true;
this.cancelButton.Click += new System.EventHandler(this.cancelButton_Click);
//
// LoadsForm
//
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(723, 527);
this.Controls.Add(this.cancelButton);
this.Controls.Add(this.okButton);
this.Controls.Add(this.tabControl1);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "LoadsForm";
this.ShowInTaskbar = false;
this.Text = "Loads";
this.Load += new System.EventHandler(this.LoadsForm_Load);
this.tabControl1.ResumeLayout(false);
this.loadCasesTabPage.ResumeLayout(false);
this.loadNaturesroupBox.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.loadNaturesDataGridView)).EndInit();
this.loadCasesGroupBox.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.loadCasesDataGridView)).EndInit();
this.LoadCombinationsTabPage.ResumeLayout(false);
this.combinationCreationGroupBox.ResumeLayout(false);
this.combinationCreationGroupBox.PerformLayout();
this.combinationFormulaGroupBox.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.formulaDataGridView)).EndInit();
this.usageGroupBox.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.usageDataGridView)).EndInit();
this.combinationInfoGroupBox.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.combinationDataGridView)).EndInit();
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.TabControl tabControl1;
private System.Windows.Forms.TabPage loadCasesTabPage;
private System.Windows.Forms.TabPage LoadCombinationsTabPage;
private System.Windows.Forms.Button okButton;
private System.Windows.Forms.Button cancelButton;
private System.Windows.Forms.GroupBox combinationCreationGroupBox;
private System.Windows.Forms.GroupBox combinationInfoGroupBox;
private System.Windows.Forms.GroupBox usageGroupBox;
private System.Windows.Forms.DataGridView combinationDataGridView;
private System.Windows.Forms.Button usageDeleteButton;
private System.Windows.Forms.Button usageAddButton;
private System.Windows.Forms.Button usageCheckNoneButton;
private System.Windows.Forms.Button usageCheckAllButton;
private System.Windows.Forms.GroupBox combinationFormulaGroupBox;
private System.Windows.Forms.TextBox combinationNameTextBox;
private System.Windows.Forms.Label combinnationNameLabel;
private System.Windows.Forms.Label combinationTypeLabel;
private System.Windows.Forms.Button deleteCombinationButton;
private System.Windows.Forms.Button newCombinationButton;
private System.Windows.Forms.ComboBox combinationStateComboBox;
private System.Windows.Forms.Label combinationStateLabel;
private System.Windows.Forms.ComboBox combinationTypeComboBox;
private System.Windows.Forms.DataGridView formulaDataGridView;
private System.Windows.Forms.Button formulaDeleteButton;
private System.Windows.Forms.Button formulaAddButton;
private System.Windows.Forms.GroupBox loadNaturesroupBox;
private System.Windows.Forms.DataGridView loadNaturesDataGridView;
private System.Windows.Forms.GroupBox loadCasesGroupBox;
private System.Windows.Forms.DataGridView loadCasesDataGridView;
private System.Windows.Forms.Button duplicateLoadCasesButton;
private System.Windows.Forms.DataGridView usageDataGridView;
private System.Windows.Forms.Button addLoadNaturesButton;
}
}
+86
View File
@@ -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.Text;
using System.Windows.Forms;
namespace Revit.SDK.Samples.Loads.CS
{
public partial class LoadsForm : System.Windows.Forms.Form
{
// Private members
Loads m_dataBuffer; // A reference of Loads.
/// <summary>
/// Constructor of LoadsForm
/// </summary>
/// <param name="dataBuffer"> A reference of Loads class </param>
public LoadsForm(Loads dataBuffer)
{
// Required for Windows Form Designer support
InitializeComponent();
//Get a reference of LoadsForm
m_dataBuffer = dataBuffer;
}
/// <summary>
/// Initialize the data on the form
/// </summary>
private void LoadsForm_Load(object sender, EventArgs e)
{
// Initialize the data of loadCaseTabPage
InitializeLoadCasePage();
// Initialize the data of LoadCombinationsTabPage
InitializeLoadCombinationPage();
}
/// <summary>
/// Respond the ok button click event.
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void okButton_Click(object sender, EventArgs e)
{
this.DialogResult = DialogResult.OK;
this.Close();
}
/// <summary>
/// Respond the cancel button click event.
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void cancelButton_Click(object sender, EventArgs e)
{
this.DialogResult = DialogResult.Cancel;
this.Close();
}
}
}
+120
View File
@@ -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,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("Loads")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Loads")]
[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("578eda76-7773-4b02-ae2c-16d1c7dcd1f0")]
// 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.