problem getting all clouds shown on a sheet

problem getting all clouds shown on a sheet

james.levieux
Advocate Advocate
1,268 Views
7 Replies
Message 1 of 8

problem getting all clouds shown on a sheet

james.levieux
Advocate
Advocate

Hi all,

 

I'm trying to acquire all the clouds that are shown on a sheet (so I can extract the comments for a revision narrative).  I have a condition where I've taken a master 1/4" scale floor plate and divided it into three separate 1/4" scale area plans where each of the three area plans are dependent views, each with the crop adjusted to show the different portions of the floor plate.  Pretty standard matchline treatment so far, right?

 

If I iterate through the collection of clouds, even if a cloud is only visible on one sheet, Revit includes that cloud in every dependent view  (presumably because all three sheets show a dependant view that sources the same master view--I'm fairly certain of this because the view name that is returned with the cloud is the name of the master view and not the dependent view).

 

Is there any other way to reliably acquire the clouds that are shown on a sheet?

 

Regards,

James

0 Likes
Accepted solutions (1)
1,269 Views
7 Replies
Replies (7)
Message 2 of 8

jeremytammik
Autodesk
Autodesk

It would help if you would share a code snippet showing how you are collecting these things, what filters are set up, what view ids are you providing to the filtered element collectors, etc.

 



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

0 Likes
Message 3 of 8

james.levieux
Advocate
Advocate

Thanks Jeremy, here is the gist of the code:

 

FilteredElementCollector allInstances = new FilteredElementCollector(uidoc.Document).OfCategory(BuiltInCategory.OST_RevisionClouds).OfClass(typeof(RevisionCloud)); 
IList clouds = allInstances.ToElements();

foreach (RevisionCloud cloud in clouds)
{

     string RevNum = cloud.LookupParameter("Revision Number").AsString();
     string RevDate = cloud.LookupParameter("Revision Date").AsString();
     string RevComment = cloud.LookupParameter("Comments").AsString();
     bool isViewSpecific = cloud.ViewSpecific;
     Autodesk.Revit.DB.View ownerView = (Autodesk.Revit.DB.View)uidoc.Document.GetElement(cloud.OwnerViewId);
     if (ownerView != null) view = ownerView.ViewType.ToString() + ":" + ownerView.Name;

	Set<ElementId> sheetIDs = cloud.GetSheetIds();
	foreach (ElementId sheetID in sheetIDs)
	{
           ViewSheet thisSheet = (ViewSheet)uidoc.Document.GetElement(sheetID);
           sheetName = thisSheet.Name;
           sheetNum = thisSheet.SheetNumber;
	}

}

 

 

I'm getting good data.  Here's a screen shot:

 

(the gray lines are the problems...they show up because they are drawn on the "master view".  You can see the the owner view is the master view and not the dependent.

image.png

 

This plan screen shot below shows the lay of the land.  You can see the master view and the dependent views in the project browser.  I've circled the three clouds that are drawn on the master view.  The fourth cloud is drawn on the sheet.  Revit includes them on every sheet (A5 & A6) even though those clouds are cropped out of each of their dependent views.  

image.png

0 Likes
Message 4 of 8

RPTHOMAS108
Mentor
Mentor
Accepted solution

RevisionCloud.GetSheetIds

 

"A RevisionCloud can appear on a ViewSheet because it is drawn directly on the ViewSheet or because its owner view is placed on the ViewSheet. If the RevisionCloud is owned by a view that is a dependent view or has associated dependent views, then the RevisionCloud can also be visible on the sheets where the related dependent or primary views have been placed.


This RevisionCloud may not be visible in all ViewSheets reported by this method. Additional factors, such as the visibility settings or annotation crop of the Views or the visibility settings of the associated Revision may still cause this RevisionCloud to not appear on a particular ViewSheet.

If this RevisionCloud is owned by a ViewLegend, no sheets will be returned because the RevisionCloud will not participate in revision schedules."

 

In short I think you are doing things the wrong way around. It may be better to iterate the sheets, the views on the sheet and see if a filtered element collector with ViewID set to ID of view on sheet returns the cloud to determine such relationships.

0 Likes
Message 5 of 8

james.levieux
Advocate
Advocate

Thanks.  Much better results now.

 

James

0 Likes
Message 6 of 8

jeremytammik
Autodesk
Autodesk

And what does the code look like producing much better results?

 

Thank you!

 



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

0 Likes
Message 7 of 8

james.levieux
Advocate
Advocate
//get sheets in project
FilteredElementCollector sheets = new FilteredElementCollector(uidoc.Document).OfClass(typeof(ViewSheet));

//find revisions on sheets
foreach (ViewSheet sheet in sheets)
{
    //get the clouds drawn directly on the sheet
    View sheetView=uidoc.Document.GetElement(sheet.Id) as View;
    getCloudDataInView(sheetView, sheet, null);

    //first get the viewports to get the detail number and "name on sheet" if different than view name
    // then get the view from the viewport to get the clouds drawn within each placed view of the sheet

    ICollection<ElementId> vpIDs=sheet.GetAllViewports();

    foreach (ElementId vpID in vpIDs)
    {
        Viewport viewport = uidoc.Document.GetElement(vpID) as Viewport;
        View view = uidoc.Document.GetElement(viewport.ViewId) as View;
        getCloudDataInView(view, sheet, viewport);
    }
}

//find revisions NOT on sheets
FilteredElementCollector allInstances = new FilteredElementCollector(uidoc.Document).OfCategory(BuiltInCategory.OST_RevisionClouds).OfClass(typeof(RevisionCloud));
IList<Element> clouds = allInstances.ToElements();

foreach (RevisionCloud cloud in clouds)
{
    if (cloud.GetSheetIds().Count==0)
    {

        //make sure the cloud hasn't already been found on a sheet
        if (revsProcessed.Contains(cloud.Id))
        {
            //do nothing
        }
        else
        {
            RevisionData rev = new RevisionData(cloud, null, null);
            revsList.Add(rev.SortString, rev);
        }
    } 
}

 

If you go through the project sheet by sheet, you fail get any clouds that aren't on sheets.  I wanted those too  so I could check for drafting errors.  So, as I processed each sheet, I use this method below to collect a list of clouds that had already been processed.  Afterwards I collected all the clouds and check to see if they were NOT on the list.

private void getCloudDataInView(Autodesk.Revit.DB.View view, ViewSheet sheet, Viewport viewport)
{
    FilteredElementCollector clouds;
    clouds = new FilteredElementCollector(view.Document, view.Id).OfCategory(BuiltInCategory.OST_RevisionClouds).OfClass(typeof(RevisionCloud));
    foreach (RevisionCloud cloud in clouds)
    {
        RevisionData rev = new RevisionData(cloud, sheet, viewport);
        revsList.Add(rev.SortString, rev);
        revsProcessed.Add(cloud.Id);
    }
}

 

  

0 Likes
Message 8 of 8

markjvlampad
Advocate
Advocate

any chance to share the code for this?

RevisionData rev = new RevisionData(cloud, sheet, viewport);

 

0 Likes