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: 

Is there any method to prevent deletion of parameters?

3 REPLIES 3
SOLVED
Reply
Message 1 of 4
DAHAM_CHUNGHUNHO
309 Views, 3 Replies

Is there any method to prevent deletion of parameters?

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.

Labels (3)
3 REPLIES 3
Message 2 of 4

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
Message 3 of 4

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.

Message 4 of 4

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

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

Post to forums  

Rail Community


Autodesk Design & Make Report