Starting in December, we will archive content from the community that is 10 years and older. This FAQ provides more information.
Hi all,
New to the API(and c# for that matter) but im getting somewhere with it.
I'm trying to get the FilteredElementCollector to filter sheets by SheetNumber.Contains(//user input//) which works just fine. But i would like it to add 1 sheet that will always be the same number "100-Temp".
I've tried everything to get the collector to add this sheet to its collection with the user defiend string (match) but my Sheet Set (which the code creates) never has this sheet added to it.
Document doc = this.ActiveUIDocument.Document;
// create a new ViewSet - add views to it that match the desired criteria
ViewSet myViewSet = new ViewSet();
string match = Microsoft.VisualBasic.Interaction.InputBox("Enter Unit Number", "Create Sheet Set", "");
string temp = "100-Temp";
if (match =="")
{
TaskDialog.Show("Error", "Cancelled or no information entered.");
return;
}
foreach (ViewSheet vs in new FilteredElementCollector(doc).OfClass(typeof(ViewSheet)).Cast<ViewSheet>()
.Where(q => q.SheetNumber.Contains(match ) ))
// .Where (q => q.SheetNumber.Equals(temp)))
{
myViewSet.Insert(vs );
}
Thanks!
Solved! Go to Solution.
Solved by Ryan. Go to Solution.
Dear Ryabn
Optimally, you could (1) post your solution as well, and (2) mark it as the solution to the issue, so your whole thread will be classed as solved.
Thank you!
Cheers,
Jeremy
Thanks Jeremy,
I was trying to figure out how to delete the post entirely, but i can do as you suggest.
To solve it, i just created another FilteredElementCollecter that only finds the single sheet i want, then adds it to the same Collection set.
foreach (ViewSheet vt in new FilteredElementCollector(doc).OfClass(typeof(ViewSheet)).Cast<ViewSheet>() .Where (q => q.SheetNumber.Equals("100-Temp"))) { myViewSet.Insert(vt ); } foreach (ViewSheet vs in new FilteredElementCollector(doc).OfClass(typeof(ViewSheet)).Cast<ViewSheet>() .Where(q => q.SheetNumber.Contains(match) && q.ViewName !=("11x17"))) //.OrderBy (x => numeric(x.SheetNumber) )) { myViewSet.Insert(vs ); }
Can't find what you're looking for? Ask the community or share your knowledge.