Correct way to store information in a element

Correct way to store information in a element

Anonymous
Not applicable
555 Views
3 Replies
Message 1 of 4

Correct way to store information in a element

Anonymous
Not applicable
Hello

I have a pit(family instance) and I want to store/attach some information(upstream hgl) to this pit.

What is the best/correct way to store this info in revit? Is it through parameters (instance or shared?) or some other method?
0 Likes
Accepted solutions (1)
556 Views
3 Replies
Replies (3)
Message 2 of 4

Anonymous
Not applicable
Accepted solution

There are two ways I know of to store your own data with an element: using shared parameters or using extensible storage. It really depends on what you want to do with the data. Shared parameters can be seen and edited by others and I believe they can be scheduled. Extensible storage isn't visitble to the user and is only accessible via the API.

 

HTH,

Message 3 of 4

Anonymous
Not applicable

Thanks for the reply 🙂

 

Looks like I'll use shared parameters because I want to expose it to the user. The way I know of adding parameters is by editting/creating a shared param file, havn't tried the code yet just found a sample in the SDK. I'll give it a go, is this the way you do it?....

 

doc.Application.SharedParametersFilename = "mySharedParams.txt";

//Open shared parameter file
DefinitionFile parafile = doc.Application.OpenSharedParameterFile();
Category wallCat = doc.Settings.Categories.get_Item(BuiltInCategory.OST_PlumbingFixtures); 
CategorySet categories = doc.Application.Create.NewCategorySet();
categories.Insert(wallCat);

InstanceBinding binding = doc.Application.Create.NewInstanceBinding(categories);

//Create a group
DefinitionGroup apiGroup = parafile.Groups.Create("APIGroup");

//Create a visible "VisibleParam" of text type.
Definition visibleParamDef = apiGroup.Definitions.Create("MyParam", ParameterType.Text, true);
BindingMap bindingMap = doc.ParameterBindings;
bindingMap.Insert(visibleParamDef, binding);

 

0 Likes
Message 4 of 4

Anonymous
Not applicable

That looks about right. If you do it right, I think you should see the new parameters listed in the properties pane for elements in the categories you indicated. If it doens't show up, then try setting the value via the API and then look at the element for which you set the value. You can do this by getting an element, in your case a plumbing fixture, and then calling something like;

 

Parameter param = fixture.get_Parameter("MyParam");