Revit API Forum
Welcome to Autodesk’s Revit API Forums. Share your knowledge, ask questions, and explore popular Revit API topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Group Edit Event

10 REPLIES 10
Reply
Message 1 of 11
dboghean
1161 Views, 10 Replies

Group Edit Event

Is it possible somehow to know when a user enters the group edit mode and present them with a dialog? 

 

The ultimate goal is to not allow users to edit specific detail groups, so perhaps there is a different way to do this? My initial thinking is to use an DMU to determine any changes made to the detail group, and if certain conditions are met, then it will display a dialog to the user notifying them that they should not edit the group.

 

The downside to this that I've found is that if any family types are edited that are within the group, such as a detail component, then the user receives the dialog for each instance of the group which is not favorable. 

 

Does anyone have any other alternative ways to ensure that a detail group is not edited? Or perhaps a way to determine if a user is within the group edit mode?

 

Thank you!

10 REPLIES 10
Message 2 of 11
adam.krug
in reply to: dboghean

If this is not available in API then I would try to set a FileChanged event on current Journal File, analyze its delta each time it changes to find out if the user is in Group Edit Mode.

But I don't know if this is available in API or not, and I haven't tried such approach myself yet. It's just an idea for a workaround.

Message 3 of 11
jeremytammik
in reply to: dboghean

Dear Dan,

 

Thank you for your query.

 

I cannot suggest a clean ready-made solution for your specific need off-hand, I'm afraid.

 

You can probably determine when a user enters the group edit mode by subscribing to some .NET API Automation event that is triggered when certain ribbon panels are displayed:

 

http://thebuildingcoder.typepad.com/blog/2015/02/automation-ribbon-panel-itemexecuted-and-vacation.h...

 

However, you say that you are only interested in specific  detail groups, so maybe you need to be more specific than that.

 

You could also implement an updater using the Dynamic Model Updater Framework DMU:

 

http://thebuildingcoder.typepad.com/blog/about-the-author.html#5.31

 

That would enable you to detect changes to specific elements and veto the action, if so desired.

 

I hope this helps.

 

Best regards,

 

Jeremy

 



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

Message 4 of 11
bigbolbol
in reply to: dboghean

You can do this by handling the DocumentChanged event and checking if the transaction name is "Edit Group"

 

 public Result OnStartup(UIControlledApplication application)
        {
            application.ControlledApplication.DocumentChanged += ControlledApplication_DocumentChanged;
            return Result.Succeeded;
        }

        private void ControlledApplication_DocumentChanged(object sender, Autodesk.Revit.DB.Events.DocumentChangedEventArgs e)
        {
            if (e.GetTransactionNames().FirstOrDefault() == "Edit Group")
            {
                // user enters Edit Group 
            }
        }

 ---

Ahmed Nabil

https://www.linkedin.com/in/anabil1/

https://www.upwork.com/o/profiles/users/_~01676f5c2a8157f5d3

Message 5 of 11
jeremytammik
in reply to: bigbolbol

Thank you for the suggestion.

 

The document changed event is fired after the transaction has been terminated.

 

So, would this event not be triggered after the user exits the group edit mode?

 



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

Message 6 of 11
bigbolbol
in reply to: jeremytammik

Hi Jeremy, it's my pleasure.

This event is fired both on entering the Edit Mode (under the transaction name "Edit Group") and on exiting (under the transaction name "Finish Edit Group")

 

 ---

Ahmed Nabil

https://www.linkedin.com/in/anabil1/

https://www.upwork.com/o/profiles/users/_~01676f5c2a8157f5d3

Message 7 of 11
bweinreder
in reply to: bigbolbol

Hi, interesting topic. Is there a way to determine to which group this event pertains? I want to write the group name and ID to a project parameter in the members of the group.

Message 8 of 11
jeremytammik
in reply to: bweinreder

If the group was actually modified, it is reported by the DocumentChanged event mentioned above:

 

https://www.revitapidocs.com/2020/f7acc5b4-a1b4-12ca-802b-0ee78942589e.htm

  



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

Message 9 of 11
bweinreder
in reply to: jeremytammik

Yes I've seen the post, and the EventArguments are pointing to the Model Group that has last changed. However, it would be cool if I had access to the group instance, and not the group prototype that was saved in the Project Browser (let's call it the prototype or original).

Message 10 of 11
bweinreder
in reply to: bweinreder

Edit time expired when I was doing my research...

 

It is interesting to note that ModifiedElementIds contains several elements. This depends on the number of group instances and the number of elements that are actually modified in the group. The first ID will point to the 'prototype' of the Group in the Project Browser. The other IDs point to the edited group instance, the number of elements changed in the group instance, and all elements in the other group instances (which I assume based on the numbers given).

Since the project parameter I want to edit is not aligned (can vary by instance) I would have to iterate through all model groups, and edit the elements of group instances with the same name programmatically. This way I can avoid infinite loops.

 

I'm checking for transaction name Finish Editing Group by the way, which I think is relevant to the results I get.

Message 11 of 11
bweinreder
in reply to: bweinreder

...and another thing that should be obvious: OF COURSE you can't change the document triggered by the DocumentChanged event! I read it somewhere and it seemed so obvious that I should've remembered it (instead I used the DocumentSaving event).
Sorry for hijacking this topic. I find it useful for rubberducking and if someone ever does respond or learns from it, that's a bonus.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Rail Community