Сообщество программистов Autodesk в СНГ

ADN Club => Revit API => Тема начата: enot от 13-09-2018, 17:59:32

Название: Ошибка получения докум семейства в Updater-е
Отправлено: enot от 13-09-2018, 17:59:32
При выполнении в коде:

Код - C# [Выбрать]
  1.     public class Updater_ : IUpdater
  2.     {
  3.         public void Execute(UpdaterData data)
  4.         {
  5.             Document doc = data.GetDocument();
  6.             Autodesk.Revit.ApplicationServices.Application app = doc.Application;
  7.  
  8.          ...

Ошибка здесь,


Код - C# [Выбрать]
  1.            Document fam_doc = doc.EditFamily(owner_family);

в чем может быть причина?

Название: Re: Ошибка получения докум семейства в Updater-е
Отправлено: Александр Игнатович от 13-09-2018, 18:04:45
Из документации метода EditFamily:

Цитировать
This method may not be called if the document is currently modifiable (has an open transaction) or is in a read-only state. The method may not be called during dynamic updates. To test the document's current status, check the values of IsModifiable and IsReadOnly properties.

Вам Прийдется пересмотреть логику приложения.
Название: Re: Ошибка получения докум семейства в Updater-е
Отправлено: enot от 13-09-2018, 18:24:22
не использовать EditFamily  в updatere?
Название: Re: Ошибка получения докум семейства в Updater-е
Отправлено: Александр Игнатович от 13-09-2018, 18:29:22
не использовать. Еще о том, что можно и нельзя использовать в апдейтерах (из документации):

Цитировать
The following methods may not be called while executing an Updater, because they introduce cross references between elements. A ForbiddenForDynamicUpdateException will be thrown when an updater attempts to call any of these methods:

void Autodesk.Revit.DB.ViewSheet.AddView(Autodesk.Revit.DB.View, Autodesk.Revit.DB.UV)
Autodesk.Revit.DB.Family Autodesk.Revit.DB.Document.LoadFamily(Autodesk.Revit.DB.Document, Autodesk.Revit.DB.IFamilyLoadOptions)
Autodesk.Revit.DB.Structure.AreaReinforcement Autodesk.Revit.Creation.Document.NewAreaReinforcement(Autodesk.Revit.DB.Element, Autodesk.Revit.DB.CurveArray, Autodesk.Revit.DB.XYZ)
Autodesk.Revit.DB.Structure.PathReinforcement Autodesk.Revit.Creation.Document.NewPathReinforcement(Autodesk.Revit.DB.Element, Autodesk.Revit.DB.CurveArray, bool)
void Autodesk.Revit.DB.MEPSystem.Add(Autodesk.Revit.DB.ConnectorSet)

Although the following methods are allowed during execution of an updater, they can also throw ForbiddenForDynamicUpdateException when cross-references between elements are established as a result of the call. One such example could be creating a face wall that intersect with an existing face wall, so those two would have to be joined together. Apply caution when calling these methods from an updater:

Autodesk.Revit.DB.ElementSet Autodesk.Revit.Creation.ItemFactoryBase.NewFamilyInstances(System.Collections.Generic.List<Autodesk.Revit.Creation.FamilyInstanceCreationData>)
Autodesk.Revit.DB.FamilyInstance Autodesk.Revit.Creation.ItemFactoryBase.NewFamilyInstance(Autodesk.Revit.DB.XYZ, Autodesk.Revit.DB.FamilySymbol, Autodesk.Revit.DB.Element,Autodesk.Revit.DB.Structure.StructuralType)
Autodesk.Revit.DB.FamilyInstance Autodesk.Revit.Creation.Document.NewFamilyInstance(Autodesk.Revit.DB.XYZ, Autodesk.Revit.DB.FamilySymbol, Autodesk.Revit.DB.Element, Autodesk.Revit.DB.Level, Autodesk.Revit.DB.Structure.StructuralType)
Autodesk.Revit.DB.FaceWall Autodesk.Revit.DB.FaceWall.Create(Autodesk.Revit.DB.Document, Autodesk.Revit.DB.ElementId, Autodesk.Revit.DB.WallLocationLine, Autodesk.Revit.DB.Reference)

Some UI methods may not be called while executing an Updater too, otherwise ForbiddenForDynamicUpdateException will be thrown. Such methods include: PickObject, PickObjects, PickElementsByRectangle, PickPoint, PickOne and WindowSelect.

Also, most of the methods of the UpdaterRegistry class may not be called during an updater's execution otherwise an InvalidOperationException would be thrown.

In addition to the forbidden methods listed above, other API methods that require documents to be in transaction-free state may not be called either. Such methods include but are not limited to Save, SaveAs, Close, LoadFamily, etc. Please refer to the documentation of the respective methods for more information.
Название: Re: Ошибка получения докум семейства в Updater-е
Отправлено: enot от 13-09-2018, 20:39:50
Спасибо за развернутый ответ