Announcements

Starting in December, we will archive content from the community that is 10 years and older. This FAQ provides more information.

Revit API Forum
Welcome to Autodesk’s Revit API Forums. Share your knowledge, ask questions, and explore popular Revit API topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

FilteredElementCollector

3 REPLIES 3
SOLVED
Reply
Message 1 of 4
Ryan
2623 Views, 3 Replies

FilteredElementCollector

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!

 

3 REPLIES 3
Message 2 of 4
Ryan
in reply to: Ryan

Nevermind,

I solved it right after i posted.

Message 3 of 4
jeremytammik
in reply to: Ryan

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



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

Message 4 of 4
Ryan
in reply to: jeremytammik

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.

Post to forums  

Autodesk Design & Make Report