Is there any method to prevent deletion of parameters?

Is there any method to prevent deletion of parameters?

DAHAM_CHUNGHUNHO
Participant Participant
642 Views
3 Replies
Message 1 of 4

Is there any method to prevent deletion of parameters?

DAHAM_CHUNGHUNHO
Participant
Participant

I make 4 shared parameters with revit api for to log the element's creator, modifier, and time. I want to prevent this parameter from being deleted. Is there any method to prevent deletion of parameters? Btw I use Revit 2021.

0 Likes
Accepted solutions (1)
643 Views
3 Replies
Replies (3)
Message 2 of 4

jeremy_tammik
Alumni
Alumni
Accepted solution

If you want to protect this data more securely, the safest method is to store it in an extensible storage data entity and set the permissions to only allow the creating application access:

  

  

Parameters are basically and originally implemented for end user access. Extensible storage was created for pure programmatic add-in access and is therefore equipped with much more robust protection.

  

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
0 Likes
Message 3 of 4

DAHAM_CHUNGHUNHO
Participant
Participant

Hello, jeremy.tammik.

The method I've been using involves creating shared parameters and storing data using IUpdater. 

The workflow is as follows:

  1. When the application is launched, collect current user's name.
  2. Subscribing to DocumentOpened, DocumentCreated, FamilyLoadingIntoDocument, and ElementTypeDuplicating events, check for the existence of a shared parameter with a specific GUID and name. If parameter doesn't exist,  create parameter and binds it.
  3. subscribe Element.GetChangeTypeElementAddition to use IUpdater for adding the user's name to the Creator.
  4. subscribe Element.GetChangeTypeGeometry to use IUpdater for adding the user's name to the Modifyer.

The following image is the result of my work.

 

Screenshot 2023-09-06 125443.png

I have some questions regarding the suggested extensible storage approach:

 

  1. Will the data stored in extensible storage be displayed to end-users in a manner similar to shared parameters, as shown in the image?

  2. Can data updates be achieved with extensible storage by subscribing to events like Element.GetChangeTypeAny(), similar to how it's done with IUpdater? Or should I subscribe to application.ControlledApplication.DocumentChanged with Transaction?
  3. I need to apply extensible storage to all elements in a Revit document. Is this possible?

I've only been working with the Revit API for about a week, so my knowledge is still limited. Please advise.

0 Likes
Message 4 of 4

jeremy_tammik
Alumni
Alumni

Wow. So new. Welcome! Well, take some time to get used to it before attempting anything too adventurous affecting many users.

 

1. No. Extensible storage is up to the add-in. Revit does nothing to display it to the user. If you want the user to see it, that's up to you to do.

  

2. I don't know off-hand. Try it out.

  

3. Yes, absolutely possible.

  

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
0 Likes