Hide window indicating that a single-occurrence group has been modified

Hide window indicating that a single-occurrence group has been modified

hugo.alanoreSBUB6
Explorer Explorer
195 Views
1 Reply
Message 1 of 2

Hide window indicating that a single-occurrence group has been modified

hugo.alanoreSBUB6
Explorer
Explorer

Hello,

 

When I modify a group instance of a GroupType composed of only one instance, I get this window:

 

hugoalanoreSBUB6_0-1703084551588.png

(Un groupe a été modifié hors du mode d'édition de groupe. Comme il n'existe qu'une occurrence de ce type, la modification est autorisée.)

 

I've noticed that the window no longer opens if I move the group and put it back in its place.

I'd like to know if this behavior is normal and what is the best way to prevent it.

 

Thank you in advance.

 

Here is my code:

public void AdaptToLevel()
{
    Document.Edit("Adaptation du module au niveau", () =>
    {
        Group.UngroupMembers();

        PlancherBas.SetAboveLevel();
        PlancherHaut?.ResetSuperiorOffset();
        ResetWallSuperiorOffset();
        LayWallsOnFloor();

        Group group = GroupService.CreateGroup(Document, GetElementIds());

        XYZ movingVector = new XYZ(1, 1, 0);
        ElementTransformUtils.MoveElement(Document, group.Id, movingVector);
        ElementTransformUtils.MoveElement(Document, group.Id, movingVector.Negate());
    });
}

 

Lines 14, 15 and 16 prevent the window from opening.

196 Views
1 Reply
Reply (1)
Message 2 of 2

RPTHOMAS108
Mentor
Mentor

You can handle that dialogue via failures framework but it points to a scenario that will cause you issues if you have more than one instance of a group type in the model.

 

It is telling you that the group was changed without going into group edit mode but it allowed the changes because there was only one group instance (making changes would not cause inconsistencies with other instances of that group type). If you had two or more group instances then it wouldn't have allowed you to proceed which is the real problem with groups and the API.

 

The Revit API has no group edit context so there is no right way to do this. It is a bit frustrating since if a group containing say structural framing is copied elsewhere then that action could trigger this failure since the structural framing member would auto join with perhaps varying items outside of the group (being changed outside of group edit context). Since it is a copy and you now have two instances of the type the change isn't allowed. So just moving groups around can be problematic for the API.

 

This kind of behaviour really needs investigating more generally i.e. the behaviour of grouped items that interact with nearby items outside of groups (automatic changes to items in the group outside of group edit mode).