Autonumber instances of family with C#

Autonumber instances of family with C#

julia.hannu
Explorer Explorer
336 Views
1 Reply
Message 1 of 2

Autonumber instances of family with C#

julia.hannu
Explorer
Explorer

Hi all, 

 

I'm new to Revit but old to C# so I have a newbie question. I am looking to build a family where the instances are automatically numbered when a instance is created. However, I am not sure how to connect a script to a family that is called whenever a instance is created. There are a lot of material on how to create plugins, but can't find anything on how to attach a script to a family. Any ideas, anyone? It would be greatly appreciated. 

 

/JMH

0 Likes
337 Views
1 Reply
Reply (1)
Message 2 of 2

RPTHOMAS108
Mentor
Mentor

Best to implement the IUpdater interface.

 

Add trigger during IExternalApplication.OnStartUp for Element.GetChangeTypeElementAddition

 

The Execute method on that returns the id of the objects that have been created by the user (UpdaterData.GetAddedElementIds) and you can then in that function context find these elements and update their parameters with your numbering script.

 

If you look in the RevitAPI.chm there is an example under 'IUpdater interface'

There are also likely some samples in the SDK.

 

Should also say there is no way to embed that process in the family itself, it is done at application level in the product. Obviously you could embed a script in the family and execute it in an open ended updater but that isn't the workflow and probably a poor security choice because your addin would be executing potentially unknown code.

 

 

0 Likes