I am trying to take advantage of RevitLookup project as a starting template for new plugin, which is a good start with basic features such as modern UI, settings , update checking, etc. Which is great! :)
But I get a problem when trying to add my customer features. I found the RevitAPI.Document.isReadOnly = true when the form shows up, so I cannot manipulate the revit document in following steps.
Exception:
Autodesk.Revit.Exceptions.InvalidOperationException:“The document is currently in read-only state. EditFamily may not be executed.”
As it shows in the breakpoint.
To reproduce, in \ViewModels\Pages\DashboardViewModel.cs, add following code:
if (!Validate()) return;
// actually I will put following code in a service, and call it from viewModel, but
// for testing, I make the business logic code simple and put it below
// check whether the document is readonly or not
bool docRO = RevitApi.Document.IsReadOnly;
Document doc = RevitApi.Document;
// keep manipulate the document
// for example, open a family and get parameters
// Create a new document
FilteredElementCollector collector = new FilteredElementCollector(doc).OfClass(typeof(Family));
foreach (Family family in collector)
{
if (family.IsEditable)
{
try
{
Document familyDocument = doc.EditFamily(family); // exceptions here due to Document Readonly
// get family parameters
// ...
}
catch (Exception ex)
{
//
notificationService.ShowError("Exception",ex.Message);
}
}
}
Any idea?
PS: But if I keep going and check the Document status in revitLookup, and it says isReadOnly is false again.
Would you please help to explain what's happening under the hood, and what is the correct way to add custom features to manipulate the revit Document?
Hi there,
I am trying to take advantage of RevitLookup project as a starting template for new plugin, which is a good start with basic features such as modern UI, settings , update checking, etc. Which is great! :)
But I get a problem when trying to add my customer features. I found the![image](https://github.com/jeremytammik/RevitLookup/assets/2436027/96890cac-8b95-4df2-ac48-e13fe8d4ad99)
RevitAPI.Document.isReadOnly = true
when the form shows up, so I cannot manipulate the revit document in following steps.Exception:
As it shows in the breakpoint.
To reproduce, in \ViewModels\Pages\DashboardViewModel.cs, add following code:
Any idea?
PS: But if I keep going and check the Document status in revitLookup, and it says isReadOnly is false again.![image](https://github.com/jeremytammik/RevitLookup/assets/2436027/782a2116-47c1-40a2-b676-300c63927047)
Would you please help to explain what's happening under the hood, and what is the correct way to add custom features to manipulate the revit Document?