Results 1 to 4 of 4

Thread: AcitveDocument.Elements v. ActiveDocument.ActiveView.Elements

  1. #1
    I could stop if I wanted to rkitect's Avatar
    Join Date
    2006-01
    Posts
    449

    Default AcitveDocument.Elements v. ActiveDocument.ActiveView.Elements

    I'm trying to get an element set from the active view using a some code from th DevTV tutorials. This works to grab an element set from the entire model:

    ElementSet elems = revitApp.Create.NewElementSet();
    ElementIterator iter = revitApp.ActiveDocument.Elements;
    while (iter.MoveNext())



    So I assumed that changing it to

    ElementSet elems = revitApp.Create.NewElementSet();
    ElementIterator iter = revitApp.ActiveDocument.ActiveView.Elements;
    while (iter.MoveNext())



    Would allow me to work from the active view element set however, I'm getting the error:

    "Cannot implicitly convert type 'Autodesk.Revit.ElementSet' to 'Autodesk.Revit.ElementIterator'"

    Any insight into why this happens and what the type difference between the Elements object in ActiveDocument is compared to ActiveView?



    TIA,

  2. #2
    Active Member
    Join Date
    2005-09
    Posts
    69

    Default Re: AcitveDocument.Elements v. ActiveDocument.ActiveView.Elements

    Because the ActiveDocument property is of type ElementIterator
    From the ElementSet returned from the ActiveView, you can use ForwardIterator which returns an ElementSetIterator (note the subtle difference there as well)

  3. #3
    I could stop if I wanted to rkitect's Avatar
    Join Date
    2006-01
    Posts
    449

    Default Re: AcitveDocument.Elements v. ActiveDocument.ActiveView.Elements

    Thanks David. I'm slowly beginning to understand these subtle differences but your response helped complete my understanding.

  4. #4
    I could stop if I wanted to Danny Polkinhorn's Avatar
    Join Date
    2003-12
    Location
    Honolulu, HI
    Posts
    447

    Default Re: AcitveDocument.Elements v. ActiveDocument.ActiveView.Elements

    This is one of the inconsistencies with the API that drives me nuts.
    Danny Polkinhorn
    WATG

Similar Threads

  1. Elements in linked files obscure local elements
    By JoelB in forum Revit - Platform
    Replies: 5
    Last Post: 2010-11-15, 06:30 PM
  2. Replies: 3
    Last Post: 2009-08-07, 05:34 PM
  3. Problems about "ActiveDocument.ActiveView"
    By wenshin in forum Revit - API
    Replies: 2
    Last Post: 2008-04-17, 01:37 PM
  4. Detail Lines are model elements, how about annotation elements?
    By scowsert in forum Revit Architecture - General
    Replies: 5
    Last Post: 2007-08-03, 07:08 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •