View Filter by Workset name

View Filter by Workset name

Anonymous
Not applicable
1,599 Views
3 Replies
Message 1 of 4

View Filter by Workset name

Anonymous
Not applicable

I am new to creating Revit macros I am having a rough time interfacing with a programs API.

I have written stand alone programs in VB.NET but that was a long time ago & they mostly just calculated things.

 

I am trying to create a VB.NET macro that makes worksets & then creates a view filter that filters by workset.

 

My macro currently checks for worksharing, checks for existing worksets & creates the worksets just fine.

 

I have looked at other posts about view filters & have found one if I wanted to filter entities like walls etc. but I cannot seem to find a way of creating a rule for returning the name of a workset for the filter.

 

Any help would be appreciated.

 

Thanks,

Rick

 

 

0 Likes
1,600 Views
3 Replies
Replies (3)
Message 2 of 4

Anonymous
Not applicable

I am not sure if I understand completely your problem. Are we talking about something like this:

 

FilteredWorksetCollector col = new FilteredWorksetCollector(uiapp.ActiveUIDocument.Document);
Workset workset = col.FirstOrDefault<Workset>(e => e.Name.Equals("Lala")) as Workset;

regards

Christian

0 Likes
Message 3 of 4

Anonymous
Not applicable

Thanks for attempting. I'll try to explain better.

 

Here is the guts of something I found that I am trying to change it is selecting wall by width

Buy I want to select by workset name that I just created: (it is written in C# but I am converting to VB)

 

// create list of categories that will for the filter
IList<ElementId> categories = new List<ElementId>();
categories.Add(new ElementId(BuiltInCategory.OST_Walls));  <---- this I understand


Its this rule portion I want to give it a workset (name, ID or something) but I cant
figure out what to make it ask for when It comes to worksets,

 

// create a list of rules for the filter
IList<FilterRule> rules = new List<FilterRule>();

 

// This filter will have a single rule that the wall type width must be less than 1/2 foot

Parameter wallWidth = new FilteredElementCollector(doc).OfClass(typeof(WallType)).FirstElement().get_Parameter(BuiltInParameter.WALL_ATTR_WIDTH_PARAM);

 


rules.Add(ParameterFilterRuleFactory.CreateLessRule(wallWidth.Id, 0.5, 0.001));

 

I think the line above needs to read something like this:

rules.Add(ParameterFilterRuleFactory.CreateEqualsRule( Something about a workset ));

 

Did I add to the confusion?

 

-Rick

 

 

 

 

0 Likes
Message 4 of 4

mikako_harada
Community Manager
Community Manager

Hi Rick, 

 

Jeremy wrote a post about how to access workset: 

 

http://thebuildingcoder.typepad.com/blog/2011/11/read-only-workset-api.html

 

Maybe this helps clarify the logic behind it.  I myself also thought workset table is enough to iterate initially.  You can use special workset filter to access a list of workset, then among them, you can find a name and id. 

 

I hope this helps.


Mikako Harada
Developer Technical Services
0 Likes