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.
Solved! Go to Solution.
Solved by naveen.kumar.t. Go to Solution.
Update:
The Room Bounding Yes/No box is what I am trying to control in a linked Revit file.
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.
I believe I am accessing this parameter correctly but it is still not changing the value to 1 when the code runs.
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.
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 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);
}
}
}
}
}
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)
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.