isolate elements

isolate elements

Anonymous
Not applicable
846 Views
6 Replies
Message 1 of 7

isolate elements

Anonymous
Not applicable

Hi ,

 

I can isolate a pair of elements via the following code if the elements are in the same document but if one of them is in linked doc the code does not isolates the element if its in a linked doc.

 

IList<ElementId> ids = new List<ElementId>();

ids.Add(new ElementId(1);
ids.Add(new ElementId(2);

 

ViewFamilyType viewFamilyType = (from v in new FilteredElementCollector(doc).
OfClass(typeof(ViewFamilyType)).
Cast<ViewFamilyType>()
where v.ViewFamily == ViewFamily.ThreeDimensional
select v).First();

 

View3D view = null;

 

view = View3D.CreateIsometric(doc, viewFamilyType.Id);

 

view.IsolateElementsTemporary(ids);

 

view.ConvertTemporaryHideIsolateToPermanent();

 

uidoc.ActiveView = view;

 

doc.ActiveView.set_ProjColorOverrideByElement(ids, color);


view.UnhideElements(ids);

 

 

Thanks & Regards

Sanjay Pandey

 

 

 

0 Likes
847 Views
6 Replies
Replies (6)
Message 2 of 7

jeremytammik
Autodesk
Autodesk

Dear Sanjay,

 

Your code will be more legible if you use the 'Insert Code' button.

 

Have you tested the isolate behaviour through the user interface?

 

Does it behave in the way you wish there?

 

If not, it will probably not do so when driven programmatically either.

 

Cheers,

 

Jeremy



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

0 Likes
Message 3 of 7

Anonymous
Not applicable

Thanks for a quick reply.

 

OK now can I do the following as doing this manually in revit is possible:

 

I have main doc and a linked doc. Now I select one element from main doc and one element from linked doc; I do a right click and Hide In View - Elements. Both the selected element gets hidden.

 

The following code doesn't help:

 

FilteredElementCollector links = new FilteredElementCollector(Command.doc).OfCategory(BuiltInCategory.OST_RvtLinks);
            foreach (Document d in Command.app.Documents)
            {

                coll = new FilteredElementCollector(d);
                coll.WherePasses(new LogicalOrFilter(new ElementIsElementTypeFilter(false), new ElementIsElementTypeFilter(true)));
                elemSet = new ElementSet();
                
                foreach (Element el in coll)
                {

                    try
                    {
                        if (el.Id == new ElementId(int.Parse(arrgotvals[0])) && el.Id == new ElementId(int.Parse(arrgotvals[1])))
                        {
                           

                            IList<ElementId> ilds = new List<ElementId>();
                            ilds.Add(el.Id);

                            ICollection<ElementId> elemIdsColl = (ICollection<ElementId>)ilds.Cast<ElementId>().ToList();

                          

                            Command.doc.ActiveView.HideElements(ilds);

                        }
                    }
                    catch (Exception sd)
                    {

                        string fg = sd.ToString();
                    }

                }

Thanks & Regards

Sanjay Pandey

0 Likes
Message 4 of 7

Revitalizer
Advisor
Advisor

Hi sanjaymann,

 

there is a rule:

if you cannot do it manually, you cannot do it via API (in 99.9% of the cases).

 

If you select an Element in a linked file manually, all relating menue entries are disabled, thus you just cannot isolate it.

Testing that before asking would have taken just a second.

 

 

Revitalizer




Rudolf Honke
Software Developer
Mensch und Maschine





0 Likes
Message 5 of 7

Anonymous
Not applicable

Dear Revitalizer,

 

I wish you had viewed my response after jeremy responded to it. What I am trying to acheive is; which revit is comfortable with. You can yourself try it out. So I hope this is achievable.

 

Thanks & Regards

Sanjay Pandey

 

 

0 Likes
Message 6 of 7

Revitalizer
Advisor
Advisor

Dear sanjaymann,

 

do you want to hide elements or do you want to isolate them ?

The title of your thread is "isolate elements".

In the GUI, I can hide also elements in a linked file (as you did, too), but I cannot isolate them.

 

Thus, what I mentioned in my previous posting is still valid.

There is no solution for your problem.

 

 

Revitalizer




Rudolf Honke
Software Developer
Mensch und Maschine





0 Likes
Message 7 of 7

Anonymous
Not applicable

Dear Revitalizer,

 

My initial objective was isolation. But now I will go other way round and try to hide a pair of element one in main doc and the other in lilnked doc. Any Ideas for acheiving this.

 

Thanks & Regards

Sanjay Pandey

0 Likes