Getting Shared Parameters for ViewSchedules

Getting Shared Parameters for ViewSchedules

kevin_fielding
Advocate Advocate
576 Views
3 Replies
Message 1 of 4

Getting Shared Parameters for ViewSchedules

kevin_fielding
Advocate
Advocate

Hi,

 

I am trying to get the parameter definition for a shared parameter bound to a ViewSchedule however when I use the Parameters property it does not return any Shared Parameters, only internal parameters. 

 

Below is my code. 

 

ICollection<ViewSchedule> DeleteSchedules
            = new FilteredElementCollector(doc)
                .WhereElementIsNotElementType()
                .OfClass(typeof(ViewSchedule))
.Cast<ViewSchedule>() .ToList(); // Parameter definition for Retained_Sheet/View parameter Definition retainedSheetViewParamDef = null; if (DeleteSchedules.Count() >0) { ViewSchedule firstSchedule = DeleteSchedules.First(); ParameterSet scheduleParamSet = firstSchedule.Parameters; foreach (Parameter p in scheduleParamSet) { if (p.Definition.Name == "Retained_Sheet/View" && p.IsShared) { retainedSheetViewParamDef = p.Definition; break; } } }

Confusingly, when I use the RevitLookup tool, I can see the Shared Parameter Definition within the Parameters.

 

Am I missing anything?

 

Regards,

 

Kevin

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

BenoitE&A
Collaborator
Collaborator

Hi there,

First of all you should definitely try Revit Lookup so that you don't ask this type of questions anymore. Do it !

 

Secondly when I do the same as you do I find the shared parameters in the ParameterSet returned by Sheet.Parameter. So you must have made a mistake in spelling or something this way (or the parameter is not bound to the sheets).

 

Finally you should consider the Parameter.Lookup method which is way faster than your foreach().

Hope it helps.

Benoit


Benoit FAVRE
CEO of etudes & automates
www.etudesetautomates.com/
0 Likes
Message 3 of 4

kevin_fielding
Advocate
Advocate
Accepted solution

I mean this in the kindest sense, but did you read my post?

 

Firstly, I am already using the RevitLookUp tool already to interrogate the schedules. 

Secondly, I am looking at schedules i.e. ViewSchedule elements, and not sheets. 

Finally, I am using the foreach so I can be assured that I am selecting the shared parameter and not a non-shared project parameter by the same name. The Lookup method only selects the first parameter by that name which is risky.

 

I appreciate your time to respond, however I have now resolved the issue. I need to filter out viewtemplates, and revision schedules. 

 

ICollection<ViewSchedule> DeleteSchedules
            = new FilteredElementCollector(doc)
                .WhereElementIsNotElementType()
                .OfClass(typeof(ViewSchedule)).Cast<ViewSchedule>()
                .Where(k => !k.IsTemplate && !k.IsTitleblockRevisionSchedule && !k.IsInternalKeynoteSchedule)
                .ToList();

regards,

k

0 Likes
Message 4 of 4

BenoitE&A
Collaborator
Collaborator

Hey there,

Sorry I missed your final line under your code.

Glad you found it by yourself.

Benoit


Benoit FAVRE
CEO of etudes & automates
www.etudesetautomates.com/
0 Likes