// // (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 { /// /// A class to store Load Combination and it's properties. /// 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 /// /// Name property of LoadCombinationMap /// public String Name { get { return m_name; } } /// /// Formula property of LoadCombinationMap /// public String Formula { get { return m_formula; } } /// /// Type property of LoadCombinationMap /// public String Type { get { return m_type; } } /// /// State property of LoadCombinationMap /// public String State { get { return m_state; } } /// /// Usage property of LoadCombinationMap /// public String Usage { get { return m_usage; } set { m_usage = value; } } /// /// Default constructor of LoadCombinationMap /// /// the reference of LoadCombination 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 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 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(); } } }