Retrieving Shared Parameter Value to Rename Assembly Instance

Retrieving Shared Parameter Value to Rename Assembly Instance

Anonymous
Not applicable
835 Views
4 Replies
Message 1 of 5

Retrieving Shared Parameter Value to Rename Assembly Instance

Anonymous
Not applicable

Hi Everyone, I am having some difficulty trying to retrieve the shared parameter value and use it in the renaming of the assembly instance. I have tried the method below however, it returns the name of the parameter instead of the value.

 

I am using c# code and the goal is to create views and and use the assembly name to rename a part of the views. I have the part that creates the views except for the renaming. 

 

Any help is appreciated. Thanks in advance!

 

AssemblyInstance assemblyInstance = AssemblyInstance.Create(doc, uidoc.Selection.GetElementIds(), categoryId);

Guid sharedGuid = new Guid("7ca1c138-e50a-4608-a28d-cb149048819d");
SharedParameterElement sharedParameter = SharedParameterElement.Lookup(doc, sharedGuid);

assemblyInstance.AssemblyTypeName = sharedParameter.ToString();

0 Likes
Accepted solutions (1)
836 Views
4 Replies
Replies (4)
Message 2 of 5

RPTHOMAS108
Mentor
Mentor

Not clear on what you want to do.

 

You say you want to use part of the assembly name in a view (AssemblyInstance.Name) but are trying to get the value of a shared parameter on a newly created AssemblyInstance (AssemblyInstance.get_Parameter(GUID) & Parameter.AsString [if storage type is string]). I don't see how the empty value of a shared parameter on a newly created instance will be meaningful?

0 Likes
Message 3 of 5

Anonymous
Not applicable

@RPTHOMAS108 The goal is to take a shared parameter that belongs to an element that is part of the assembly and use it in the renaming of the assembly instance. 

0 Likes
Message 4 of 5

RPTHOMAS108
Mentor
Mentor

If you want to identify an element that contains a certain parameter the usual way is to use ElementParameterFilter

 

Use SharedParameterApplicableRule (1) (this takes name not GUID)
AssemblyInstance.GetMemberIds can be passed to FilteredElementCollector constructor
ElementParameterFilter containing (1) can be used with FilteredElementCollector.WherePasses

 

Once you have the element containing the parameter you can get the parameter and value as noted previously above.

 

AssemblyInstance.Name is ReadWrite.

0 Likes
Message 5 of 5

Anonymous
Not applicable
Accepted solution

Thanks for the help! I was able to figure it out. I ended up getting each member id of the assembly and putting this in to retrieve the value:

 

ElementId id_type = ei.GetTypeId();
Element element_type = doc.GetElement(id_type);
Parameter sharedParameter = element_type.get_Parameter(new Guid("xxxxxxxxxxxxxxxxxxxxxxxx"));
string catalogPageNumber = sharedParameter.AsString();

0 Likes