Family Editor - Load a new Shared Parameter

Family Editor - Load a new Shared Parameter

stever66
Advisor Advisor
1,639 Views
8 Replies
Message 1 of 9

Family Editor - Load a new Shared Parameter

stever66
Advisor
Advisor

Can someone provide the C# line or lines of code that would load a new shared parameter into a family? 

 

When we download a new light fixture family, we load about 12 shared parameters into the family so we can schedule all the different light fixture families on the same schedule.   But it takes a long time to do this with several different families, and several different parameters for each family, so I would like to automate this.

 

So I'm basically trying to duplicate the work flow shown in the attached PDF.   I would like to do this with the macro editor, if that makes a difference.

 

Also, I assume there is a way to select if each parameter should be a type or instance parameter, and I assume there are options for the discipline, type of parameter, and parameter group.

 

Thanks in advance:

Steve

0 Likes
1,640 Views
8 Replies
Replies (8)
Message 2 of 9

stever66
Advisor
Advisor

Any suggestions on how to get started?

 

Would it help if I use Visual Studio instead of macros?

0 Likes
Message 3 of 9

matthew_taylor
Advisor
Advisor

Hi Steve,

A good search will turn up examples of this process, though they are more likely to be 'Visual Studio' solutions and not macros.

 

The AutoParameter solution in the SDK will do what you want.

 

Also see this link for an example: https://forums.autodesk.com/t5/revit-api-forum/shared-parameter-is-showing-in-the-wrong-parameter-gr...

 

Good luck!

 

Cheers,

 

-Matt


Cheers,

-Matt
_______________________________________________________________________________
Marking a post as a 'solution' helps the community. Giving a post 'Kudos' is as good as saying thanks. Why not do both?
0 Likes
Message 4 of 9

stever66
Advisor
Advisor

Thanks for the link.   I'll try using that as a starting point.

0 Likes
Message 5 of 9

Moustafa_K
Collaborator
Collaborator

Hi Stever66

Try consuming this website. It explains the how in a very nice way. also in the same website you can search for shared parameters and how to implement them

http://spiderinnet.typepad.com/blog/2011/05/parameter-of-revit-api-30-project-parameter-information....

Moustafa Khalil
Cropped-Sharp-Bim-500x125-Autodesk-1
0 Likes
Message 6 of 9

stever66
Advisor
Advisor

Thanks Moustafa.  I'll look through that.  It looks like it explains parameters in general, which is good, because I think I'm confused.

 

Since I started this thread, a co-worker discovered we can add parameters to ALL the light fixture families at once by going to the "filters" button on the ribbon, and adding parameters there.  (Before that, we always added them to each family in the family editor.)   So I'm thinking those are "project parameters", which may be what we really want.   (We are really just looking for a way to schedule different light fixture families on the same schedule.)

 

 

0 Likes
Message 7 of 9

matthew_taylor
Advisor
Advisor

Hi @stever66,

Well that's certainly the easier way if the parameters don't depend on any of the family parameters (such as in a formula).

You can add the project parameters using the API also. Take a look at the CreateShared project in the SDK if you want to try that.

 

Best of luck!

 

Cheers,

 

-Matt


Cheers,

-Matt
_______________________________________________________________________________
Marking a post as a 'solution' helps the community. Giving a post 'Kudos' is as good as saying thanks. Why not do both?
0 Likes
Message 8 of 9

Moustafa_K
Collaborator
Collaborator
That is Exactly the point behind the Link. I usually do not add parameters
to the family itself unless it is related to the family as an Identity, but
if project schedule and definition I assign it the lighting Family category
in the project Document and not in the family Document.

So Glad you found a way through.

--
--
Best Regards,

--------------------------------------------------
Mostafa Khalil
Moustafa Khalil
Cropped-Sharp-Bim-500x125-Autodesk-1
0 Likes
Message 9 of 9

MarryTookMyCoffe
Collaborator
Collaborator

lately I was dealing with shared parameters I used to use something like that

            /// <summary>
            /// create new sharedparametr in chosen group
            /// </summary>
            /// <param name="document"></param>
            /// <param name="definitionGroup"></param>
            /// <param name="name"></param>
            /// <param name="parameterType"></param>
            /// <returns></returns>
            public SharedParameterElement newSharedParameterElement(Document document, DefinitionGroup definitionGroup, string  name, ParameterType parameterType,bool userModifiable = false , string description = "")
            {
                ExternalDefinitionCreationOptions edCreationOption = new ExternalDefinitionCreationOptions(name, parameterType);
                edCreationOption.UserModifiable = userModifiable;
                edCreationOption.Description = description;
                if (!definitionGroup.isContainParameter(name))
                {
                    ExternalDefinition externalDefinition = definitionGroup.Definitions.Create(edCreationOption) as ExternalDefinition;
                    return SharedParameterElement.Create(document, externalDefinition);
                }
                else
                {
                    ExternalDefinition externalDefinition = definitionGroup.Definitions.get_Item(name) as ExternalDefinition;
                  
                    FilteredElementCollector filteredElementCollector = new FilteredElementCollector(document);
                    filteredElementCollector.OfClass(typeof(SharedParameterElement));
                    foreach (SharedParameterElement spe in filteredElementCollector)
                    {
                        if (spe.Name == externalDefinition.Name)
                        {
                            return spe;
                        }
                    }
                    return SharedParameterElement.Create(document, externalDefinition);
                }
            }

it's not perfect but it works. I suggest read more about it here:
http://help.autodesk.com/view/RVT/2017/ENU/?guid=GUID-D0F45890-91E0-419B-B0EF-575BA83A4BE9

 

-------------------------------------------------------------
--------------------------------|\/\/|------------------------
do not worry it only gonna take Autodesk 5 years to fix bug
0 Likes