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: 

Getting Linked elements visible in a 3D view

1 REPLY 1
Reply
Message 1 of 2
TomB.ADV
220 Views, 1 Reply

Getting Linked elements visible in a 3D view

I know this may sound similar to other questions about the same topic but I didn't find a good solution.

 

My objective is to create a function which will get the all the elements in all Linked models Visible in a 3D view.

Afterwards, it should copy all the elements to the active document from which we called this function.

 

I can't figure out how to get the elements from the linked models effectively, I tried using the Bounding Box Filter
but it doesn't return any results, just some other 3D views, it worked for me before when applied to  non-linked

models but doesn't give me the same result here:

 

 

 {
            
            var activeView = ActiveDoc.ActiveView;
            var activeBBox = activeView.get_BoundingBox(null);
            var activeOutline = new Outline(activeBBox.Min, activeBBox.Max);

            var result = new List<Element>();
            foreach (var doc in Documents)
            {

                var collector = new FilteredElementCollector(doc)
                    .WherePasses(new BoundingBoxIntersectsFilter(activeOutline));

                result.AddRange(collector.ToElements().ToList()); 
            }

        }

 

 

 

I was able to solve this using ElementIntersectsSolidFilter, with some help from this post:
https://forums.autodesk.com/t5/revit-api-forum/create-solid-from-boundingbox/td-p/6330376

 

but I really didn't want to use this slow filter, any way this can be solved with a quick filter ?

 

 

 

var activeView = ActiveDoc.ActiveView as View3D;
            if(activeView == null) { return; }

            var activeSolid = solidBoundingBox(activeView.GetSectionBox());

            var result = new List<Element>();
            foreach (var doc in Documents)
            {

                var collector = new FilteredElementCollector(doc)
                    .WherePasses(new ElementIntersectsSolidFilter(activeSolid));

                Transaction targetTrans = new Transaction(ActiveDoc);
                CopyPasteOptions copyOptions = new CopyPasteOptions();
                copyOptions.SetDuplicateTypeNamesHandler(new CopyUseDestinationHandler());

                targetTrans.Start("Copy and paste linked familys");
                ElementTransformUtils.CopyElements(doc, collector.ToElementIds(), ActiveDoc, null, copyOptions);
                ActiveDoc.Regenerate();

                targetTrans.Commit();
            }

 

 

 



Thanks.

1 REPLY 1
Message 2 of 2
TomB.ADV
in reply to: TomB.ADV

sorry for double posting.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report