Set BuiltInParameter.WALL_ATTR_ROOM_BOUNDING value for linked revit file

TheCadmonkeyCouch
Participant
Participant

Set BuiltInParameter.WALL_ATTR_ROOM_BOUNDING value for linked revit file

TheCadmonkeyCouch
Participant
Participant

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.

 

 

0 Likes
Reply
Accepted solutions (1)
295 Views
6 Replies
Replies (6)

TheCadmonkeyCouch
Participant
Participant

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

 



 

0 Likes

naveen.kumar.t
Autodesk Support
Autodesk Support
Accepted solution

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

0 Likes

naveen.kumar.t
Autodesk Support
Autodesk Support

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

0 Likes

TheCadmonkeyCouch
Participant
Participant

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

        }
    }
}

 

0 Likes

TripleM-Dev.net
Advisor
Advisor

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)

0 Likes

TheCadmonkeyCouch
Participant
Participant

@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.

 

 

0 Likes