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: 

Set BuiltInParameter.WALL_ATTR_ROOM_BOUNDING value for linked revit file

6 REPLIES 6
SOLVED
Reply
Message 1 of 7
TheCadmonkeyCouch
295 Views, 6 Replies

Set BuiltInParameter.WALL_ATTR_ROOM_BOUNDING value for linked revit file

Hello,

I am trying to set the Yes/No Parameter of the room bounding Built-in Parameter of a linked revit instance.

 

Parameter linkedModelTypeProp = rvtlink.Document.GetElement(rvtlink.GetTypeId()).get_Parameter(BuiltInParameter.WALL_ATTR_ROOM_BOUNDING);
                    
if (linkedModelTypeProp.AsInteger() == 0)
{
    using (Transaction tx = new Transaction(Doc, "Set Room Bounding"))
    {
        tx.Start();
        try
        {
            linkedModelTypeProp.Set(1);
            tx.Commit();
        }
        catch (Exception ex)
        {
            tx.RollBack();
            TaskDialog.Show("Error", ex.Message);
        }
    }
}

 I get the value of the built-in parameter but it will not change the value with the .Set(1)

The storage type is Integer.

I have tried to create a ParameterValue and then IntegerParameterValue as I have used this method to control other Yes/No Parameters but I am not able to figure out how it works for this built-in yes/no parameter.

 

 

6 REPLIES 6
Message 2 of 7

Update:

The Room Bounding Yes/No box is what I am trying to control in a linked Revit file.

TheCadmonkeyCouch_0-1731380687209.png

When I snoop the Linked Type > Parameters I can see that this Parameter is not read-only and that the storage type is of Integer. 

TheCadmonkeyCouch_1-1731381033420.png

 

I believe I am accessing this parameter correctly but it is still not changing the value to 1 when the code runs.

TheCadmonkeyCouch_2-1731383203575.png

 



 

Message 3 of 7

Hi @TheCadmonkeyCouch ,

 

I was unable to reproduce the issue on my end, as everything appears to be functioning correctly. Below is the sample code I used:

RevitLinkInstance revitLinkInstance;
using(Transaction actrans=new Transaction(document))
{
    actrans.Start("1");
    Parameter linkedModelTypeProp = revitLinkInstance.Document.GetElement(revitLinkInstance.GetTypeId()).get_Parameter(BuiltInParameter.WALL_ATTR_ROOM_BOUNDING);
    if (linkedModelTypeProp.AsInteger() == 1)
    {                        
        linkedModelTypeProp.Set(0);                        
    }
    else
    {                      
        linkedModelTypeProp.Set(1);
    }
    actrans.Commit();
}

Need more details to analyse the issue at my end.


Naveen Kumar T
Developer Technical Services
Autodesk Developer Network

Message 4 of 7

Hi @TheCadmonkeyCouch ,

 

To assist effectively, please isolate the issue and provide a concise, non-confidential, buildable sample project along with a test drawing that demonstrates the behavior. Code snippets alone are insufficient, as they don’t enable us to reproduce the full context in which the code operates.


Naveen Kumar T
Developer Technical Services
Autodesk Developer Network

Message 5 of 7

@naveen.kumar.t Thank you for your response.

I moved the Transaction statement to encompass the if/else statement and now it is functioning correctly.

 

Here is my updated code sample:

    FilteredElementCollector rvtLinksCollector = new FilteredElementCollector(Doc).OfClass(typeof(RevitLinkInstance)).WhereElementIsNotElementType();
    string selectedRvtFile = linked_Files.SelectedItem.ToString();
    
    foreach (Element rvtlink in rvtLinksCollector)
    {
         RevitLinkInstance Instance = rvtlink as RevitLinkInstance;
        if (Instance.Name == selectedRvtFile)
        {
            Parameter linkedModelTypeProp = rvtlink.Document.GetElement(rvtlink.GetTypeId()).get_Parameter(BuiltInParameter.WALL_ATTR_ROOM_BOUNDING);
            using (Transaction tx = new Transaction(Doc, "Set Room Bounding"))
            {
                tx.Start();
                try
                { 
                    if (linkedModelTypeProp.AsInteger() == 0)
                    {
                        linkedModelTypeProp.Set(1);
                        tx.Commit();
                    }
                    else
                    {
                        linkedModelTypeProp.Set(0);
                        tx.Commit();
                    }
                    
                }
                catch (Exception ex)
                {
                    tx.RollBack();
                    TaskDialog.Show("Error", ex.Message);
                }
            }

        }
    }
}

 

Message 6 of 7

That doesn't make sence that this works and the first one not (I tried the first one and that worked, on a direct link).

I do see a check on the name now.

 

Is it possible the first code tried to edit a nested link, could be those can't be edited (can't be done in the UI either I believe)

Message 7 of 7

@TripleM-Dev.net 

I have attached my test files which are in 2023.

 

I only have one revit link in my test file and that file only contains 4 walls.

 

I tested this code segment on two different workstations and got the same result before I changed the location of the transaction statement.

 

This code snippet is part of a WPF window.

The user selects the revit file from a drop down list. From there the user can select any of the 3 button options. "Transfer Project Info", "Set Room Bounding", "Pin Element", and there is a close button.

 

 

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

Post to forums  

Autodesk Design & Make Report