code
private void btDebug_Click(object sender, EventArgs e)
{
LoadCaseArray loadCases = new LoadCaseArray();
IList<Autodesk.Revit.DB.Element> elements = new Autodesk.Revit.DB.FilteredElementCollector(m_document).OfClass(typeof(LoadCase)).ToElements();
foreach (Autodesk.Revit.DB.Element el in elements)
{
//get all the loadcases
LoadCase loadCase = el as LoadCase;
loadCases.Append(loadCase);
}
// Create the factor array for load combination creation
double[] factorArray = new double[loadCases.Size];
for (int ii = 0; ii < loadCases.Size; ii++)
{
factorArray[ii] = ii + 1;
}
// Create a new load combination
int typeInd = 0; // Combination
LoadUsageArray loadUsages = new LoadUsageArray();
int stateInd = 0; // Servicebility
LoadCombinationArray combinations = new LoadCombinationArray();
LoadCombination loadCombination = m_document.Create.NewLoadCombination("debug new combination",
typeInd, stateInd, factorArray, loadCases,
combinations, loadUsages);
if (null == loadCombination)
{
throw new Exception("Create a load combination failed.");
}
// Give the user some information
TaskDialog.Show("Revit", "Load combination created successfully.");
}
combination is not visible....
creation but not visible
Hi 40ushek,
I have run code provided in above post in Revit 2015 with UR1.
Code correctly created LoadCombination object.
Watch attached "LoadCombinationCreation.swf" movie to see how I had run "CreateLoadCombination" macro.
Working code is inside "CreateLoadCombination_R2015.rvt" file, also for convenience I pasted text copy of it.
Thank You,
Andrzej Trelinski
Revit Structure developer
public void CreateLoadCombination() { ElementId loadCombinationId; using (Transaction tran = new Transaction(this.Document, "CreateLoadCombination")) { tran.Start(); LoadCaseArray loadCases = new LoadCaseArray(); IList<Element> elements = new FilteredElementCollector(this.Document).OfClass(typeof(LoadCase)).ToElements(); foreach (Autodesk.Revit.DB.Element el in elements) { //get all the loadcases LoadCase loadCase = el as LoadCase; loadCases.Append(loadCase); } // Create the factor array for load combination creation double[] factorArray = new double[loadCases.Size]; for (int ii = 0; ii < loadCases.Size; ii++) { factorArray[ii] = ii + 1; } // Create a new load combination int typeInd = 0; // Combination LoadUsageArray loadUsages = new LoadUsageArray(); int stateInd = 0; // Servicebility LoadCombinationArray combinations = new LoadCombinationArray(); LoadCombination loadCombination = this.Document.Create.NewLoadCombination("debug new combination", typeInd, stateInd, factorArray, loadCases, combinations, loadUsages); if (null == loadCombination) { TaskDialog.Show("ERROR", "ERROR: LoadCombination not created"); return; } loadCombinationId = loadCombination.Id; if (tran.Commit() != TransactionStatus.Committed) { TaskDialog.Show("ERROR", "ERROR: Committing transaction failed"); return; } } // Give the user some information TaskDialog.Show("Revit", string.Format("Load Combination ID='{0}' created successfully!", loadCombinationId.IntegerValue)); }