Revit API Forum
Welcome to Autodesk’s Revit API Forums. Share your knowledge, ask questions, and explore popular Revit API topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Revit Structure 2013. Load combination. Is it bug?

1 REPLY 1
Reply
Message 1 of 2
40ushek
493 Views, 1 Reply

Revit Structure 2013. Load combination. Is it bug?

 

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 visiblebug.png

 

1 REPLY 1
Message 2 of 2
andrzej.trelinski
in reply to: 40ushek

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));
}

 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Rail Community