View.IsolateElementTemporary not isolating Element

View.IsolateElementTemporary not isolating Element

Anonymous
Not applicable
2,705 Views
14 Replies
Message 1 of 15

View.IsolateElementTemporary not isolating Element

Anonymous
Not applicable

Im trying to create a ViewPlan and isolate a Element in it, but the following code does create the ViewPlan, it just doesn't isolate the Element. Any help would be appreciated.

 

 

 

               public View ByBoundingBox(
            BoundingBoxXYZ bb,
            View viewTemplate,
            ViewFamilyType viewFamilyType,
            Level level,
            string name,
            float[] offset,
            ElementId isolateElementId = null
            )
        {
            XYZ minPt = new XYZ(bb.Min.X - offset[3], bb.Min.Y - offset[2], 0);
            XYZ maxPt = new XYZ(bb.Max.X + offset[1], bb.Max.Y + offset[0], 0);

            bb.Min = minPt;
            bb.Max = maxPt;

            ViewPlan vp = ViewPlan.Create(this.UIDocument.Document, viewFamilyType.Id, level.Id);

            vp.Name = name;
            vp.CropBox = bb;
            vp.CropBoxActive = true;
            vp.ViewTemplateId = viewTemplate.Id;

            if (isolateElementId != null && isolateElementId != ElementId.InvalidElementId)
            {
                vp.EnableTemporaryViewPropertiesMode(vp.Id);
                vp.IsolateElementTemporary(isolateElementId);
            }

            return vp;
        }

 

0 Likes
2,706 Views
14 Replies
Replies (14)
Message 2 of 15

Anonymous
Not applicable

Hi ! I'm afraid the IsolateElementTemporary method requires a transaction ! 

Source and examples from The Building Coder HERE.

 

Message 3 of 15

Anonymous
Not applicable

When i view the generated view plans i do see a blue like border around the screen showing me a text "Temporary Hide/Isolate".

 

Added screenshots. In the first screenshot "one.png" we see the generated view. In "two.png" i selected the model group which actually shoud be isolated but it's not. In "tree.png" we see how it should look like. I did this Isolation manually, so i selected the gruop and pressed the glasses down in the window to isolate the element. But that should be done by the snippet above.

0 Likes
Message 4 of 15

Anonymous
Not applicable

It's wrapped in a Transaction at a higher level. So not in this method itself.

0 Likes
Message 5 of 15

Anonymous
Not applicable
ElementId isolateElementId = null

In your method arguments ? ^^'

0 Likes
Message 6 of 15

Anonymous
Not applicable
Sure... but i have checked if a parameter is passed an it is. So that is just the default value.
0 Likes
Message 7 of 15

Anonymous
Not applicable

So this seems to be a bug in the Revit API.

 

When i try to select a Model Group to be isolated, it does not work.

 

I have brought everything back to the smallest snippet:

 

 

            this.UIDocument = commandData.Application.ActiveUIDocument;
            this.Document = this.UIDocument.Document;

            using(Transaction tx = new Transaction(this.Document))
            {
                tx.Start("tx");

                View v = this.Document.ActiveView;
                ElementId isolateElementId = new ElementId(14758028);
                v.IsolateElementTemporary(isolateElementId);
                tx.Commit();
            }
            return Result.Succeeded

When you give a Model Group ElementId, it does not isolate the model group. When given a plain Element ID, like of a stair, it isolates the stair as expected. When doing isolating manually, you are able to select a model group and than that model group is isolated as expected.

 

For now as a workaround i will see how far i will get with isolating the Model Group members. 

 

So using the members of the group doesn't do it either and returns a white canvas again.

 

        public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
        {
            this.UIDocument = commandData.Application.ActiveUIDocument;
            this.Document = this.UIDocument.Document;

            using(Transaction tx = new Transaction(this.Document))
            {
                tx.Start("tx");

                
                ElementId isolateElementId = new ElementId(14758028);
                RevitGroup g = this.Document.GetElement(isolateElementId) as RevitGroup;
                
                View v = this.Document.ActiveView;
                v.IsolateElementsTemporary(g.GetMemberIds());
                tx.Commit();
            }

            return Result.Succeeded;
}
0 Likes
Message 8 of 15

Anonymous
Not applicable

Ok, so this has to do with Model Groups and Nested Groups. IsolateElementsTeporary wont work with GetMemberIds because of Nested Groups. Sure if you don't have nested groups it will work.

 

I have a method which recursively gets elements from a model group and nested groups. After using that everything worked as expected.

 

 

 

        public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
        {
            this.UIDocument = commandData.Application.ActiveUIDocument;
            this.Document = this.UIDocument.Document;

            using(Transaction tx = new Transaction(this.Document))
            {
                tx.Start("tx");

                
                ElementId isolateElementId = new ElementId(14758028);
                RevitGroup g = this.Document.GetElement(isolateElementId) as RevitGroup;
                List<ElementId> elems = Uploader.GetMembersRecursive(this.Document, g);
                
                View v = this.Document.ActiveView;
                v.IsolateElementsTemporary(elems);
                tx.Commit();
            }

            return Result.Succeeded;
}

 

This still does feel as a bug tough.

Message 9 of 15

jeremytammik
Autodesk
Autodesk

Dear Michal,

 

Thank you for your report and please excuse the delay in responding to the issue.

 

I escalated this thread to an ADN case 12169210 [View.IsolateElementTemporary not isolating Element] and logged the issue REVIT-99053 [View.IsolateElementTemporary not isolating Element -- 12169210] with our development team for this on your behalf as it requires further exploration and possibly a modification to our software. Please make a note of this number for future reference.

 

The development team really truly need exact succinct reproducible steps in order to analyse the issue.

 

They do not have the time, patience and resources to read and analyse the entire discussion to figure out what the problem might be.

 

Also, they prefer having the API problem presented as an embedded macro, so they do not have to painfully re-create your add-in.

 

Could you therefore please produce a complete reproducible case for this including a macro that demonstrates the problem and your workaround?

 

http://thebuildingcoder.typepad.com/blog/about-the-author.html#1b

 

Thank you!

 

You are welcome to request an update on the status of this issue or to provide additional information on it at any time quoting this change request number.

 

This issue is important to me. What can I do to help?

 

This issue needs to be assessed by our engineering team, and prioritised against all of the other outstanding change requests. Any information that you can provide to influence this assessment will help. Please provide the following where possible:

 

  • Impact on your application and/or your development.
  • The number of users affected.
  • The potential revenue impact to you.
  • The potential revenue impact to Autodesk.
  • Realistic timescale over which a fix would help you.
  • In the case of a request for a new feature or a feature enhancement, please also provide detailed Use cases for the workflows that this change would address.

 

This information is extremely important. Our engineering team have limited resources, and so must focus their efforts on the highest impact items. We do understand that this will cause you delays and affect your development planning, and we appreciate your cooperation and patience.

 

Best regards,

 

Jeremy



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

0 Likes
Message 10 of 15

Anonymous
Not applicable
Jeremy,

Thank you for your help by creating the issue. Just got an email of the support desk that the issue is now closed.

"Autodesk Support CaseNo:12169210: View.IsolateElementTemporary not isolating Element is closed."
0 Likes
Message 11 of 15

jeremytammik
Autodesk
Autodesk

Dear Michal,

 

Thank you for your update and appreciation.

 

Yes, I just closed your ADN case 12169210 [View.IsolateElementTemporary not isolating Element].

 

Whether it is open or closed makes no difference whatsoever as long as we are aware of its existence and case number.

 

You can reopen, update and add any new information you wish to it at any time you like regardless simply by adding notes to this thread.

 

The status of the ADN case in no way affects the internal development issue REVIT-99053 [View.IsolateElementTemporary not isolating Element -- 12169210].

 

The development team only care about the latter.

 

Best regards,

 

Jeremy



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

0 Likes
Message 12 of 15

Anonymous
Not applicable

So here is a revit project demonstrating the issue with embedded macros. I have created 3 test cases. You will have to manually uncomment them because it involves isolating elements and otherwise i would isolate the other test cases.

0 Likes
Message 13 of 15

jeremytammik
Autodesk
Autodesk

Dear Michal,

 

Thank you for your update and reproducible case.

 

I attached it to the internal development issue REVIT-99053 [View.IsolateElementTemporary not isolating Element -- 12169210].

 

It will be much appreciated  🙂

 

Can you please also explicitly specify the exact steps to reproduce, plus the observed versus the expected behaviour in each case?

 

Otherwise, the development team will be blindly fiddling with your code with no idea what for, what to expect, what to look for.

 

Thank you!

 

Best regards,

 

Jeremy



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

0 Likes
Message 14 of 15

Anonymous
Not applicable

I added comments in the code.

But here goes:


TESTCASE 1: WORKS AS EXPECTED (demonstration only, so you can see what is expected behavior)
Works as expected. We isolate a Element, and only that Element is shown in the View.

 

TESTCASE 2: WORKS AS EXPECTED (demonstration only, so you can see what is expected behavior)

Works as expected. We isolate a Model Group and the Model Group is only shown in the View.

 

TESTCASE 3: DOES NOT WORK AS EXPECTED

Not as Expected. We isolate a Model Group, returns a blank view. Expected is that we isolate ALL the

Elements (including the nested group elements) in the Model Group. That is the behavior we see when we Isolate a Model Group manually.

To see it manually. Select the Model Group (the lowest / last one), press the Glasses icon underneath in the Icons menu. And click Isolate Element. Now we see in the View

that everything in the model groups is isolated. That is the expected behavior. When we do it trough the API, we get a blank screen / blank View.

0 Likes
Message 15 of 15

jeremytammik
Autodesk
Autodesk

Dear Michal,

 

Brilliant, perfect, exactly what we need.

 

I added your descriptions to the internal development issue REVIT-99053 [View.IsolateElementTemporary not isolating Element -- 12169210].

 

Thank you!

 

Best regards,

 

Jeremy



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

0 Likes