Lots of exciting news for today, like every day, once again on the pure Revit API, connecting the desktop and the cloud, and Autodesk Forge:
The aim of isolating an element in a newly created view was discussed by Tuuletin, Revitalizer, Scott Wilson, FirstJet and Michal-sk in the Revit API discussion forum and resolved by an interesting workaround discovered by Michael Morris, Principal Engineer of the Revit development team.
This is another example in the series of situations with a special need to regenerate and handling transactions and transaction groups:
Question: My isolation of an element in a newly created view does not work.
I do the following:
els = System.Collections.Generic.List(ElementId)
.view = ViewSection.CreateSection(doc, viewFamilyTypeId, BoundingBox)
.els
: view.IsolateElementsTemporary(els)
.If I open this view, the isolation mode is on (light blue frame is on), but nothing from els
is isolated. The other view parameters (via get_Parameter
) are accessible and writeable.
On the other hand, view.IsolateCategoriesTemporary()
works fine!
What's the problem?
Answer: Perhaps you need a call to document.Regenerate
or uiDocument.RefreshActiveView
?
Response: No, this doesn't help.
More peculiarity: the 'reverse' method, View.HideElements
, works perfectly!
Now, I see no other way to solve my task.
The first collector will include any element in model (including links).
The second collector will include elements to be isolated.
The third collector consists of the first collector with the excluded second collector.
Then, I just hide any element I don't want to be isolated by means of the third collector.
Seems like a very bad way to evade this bug...
Answer: Are the elements actually visible in the view if you don't enable the isolate?
Response: Yes, they are visible.
I create a new view (so, any graphic settings are set to default — all elements are visible), then I want to isolate some elements in this created view...
I have stopped seeking the solution. Maybe it is just a lack of the Revit 2015 API. Hope, this will be fixed in later versions.
Question 2: I would like to re-open this issue. It is still happening in Revit 2017. I have created a simple test case with macros embedded to show it in isolate_element_in_new_view.rvt:
testOne
macro shows that we can isolate a element in the view.testTwo
macro duplicates the Level 1 floorplan view and tries to isolate a Element. But the element is not isolated, unexpected behaviour.Answer: I escalated this thread to an ADN case 12169975 [Isolate elements on a newly created view] and created an internal development issue REVIT-99069 [Isolate elements on a newly created view -- 12169975] for the development team to take a closer look. They say:
I can reproduce this issue. When just 1 transaction is used to create the new view and also to isolate the element, then the isolate element fails.
However, I can get the desired behaviour using two separate transactions as follows:
Is this an acceptable workaround?
Note: I also tried the attached file and macros in our internal development release cannot reproduce the behaviour there.
I tested macro test 2
which uses just 1 transaction to create the new view and isolate the wall, and when the screen updates the single wall is really and truly isolated in the new view.
So the workaround described above will not be needed forever.
Also, it appears the real issue here is that isolate element only works in the active view. For example, edit macro testOne
to NOT activate floor plan Level 1. In the UI, open views Level 1 and Level 2 side by side, but make Level 2 be the active view. Run macro testOne
. Notice that Level 1 view is not updated and the wall is not isolated.
So you need to activate the view before doing IsolateElementTemporary
.
In fact, this appears to be needed for all uses of IsolateElementTemporary
, regardless of if the view is newly created or not.
Response: Thanks for the work around.
I tried two transactions myself as well before, but it didn't work then.
The trick is, as you guys described, to set the active view to the new created view.
Here is the working snippet for those interested:
public void testTwo( UIDocument uidoc ) { Document doc = uidoc.Document; View newView; using( Transaction t = new Transaction( doc ) ) { t.Start( "Trans" ); // Get Floorplan for Level1 and copy its // properties for ouw newly to create ViewPlan. View existingView = doc.GetElement( new ElementId( 312 ) ) as View; // Create new Floorplan. newView = doc.GetElement( existingView.Duplicate( ViewDuplicateOption.Duplicate ) ) as View; t.Commit(); // Important to set new view as active view. uidoc.ActiveView = newView; t.Start( "Trans 2" ); // Try to isolate a Wall. Fails. newView.IsolateElementTemporary( new ElementId( 317443 ) ); t.Commit(); } // Change the View to the new View. uidoc.ActiveView = newView; }
It somewhat sucks having to commit twice and therefore having to regenerate twice. But the workaround is solid and does the job. Thanks guys!
Many thanks indeed to everybody involved in this exploration, especially to Michael for his in-depth research and effective workaround!
An example of the many daily requests I receive and try to solve as efficiently and publicly as possible.
I am sorry that I cannot answer each issue in private and thank you for your understanding!
Question: I am conducting research related to Autodesk Forge and how we can collaborate with it.
I have several questions with regard to Forge.
Can we arrange a Skype conversation?
Answer: I avoid one-on-one conversations where possible, since most questions I encounter are of general interest to a large number of people.
Could you please first of all consult the existing online documentation, and then formulate your questions you have in writing?
With your concrete questions in hand, I will happily take them up with you personally or direct you to one of my colleagues.
Thank you for your understanding!
Response: I have already checked the websites. Here are my questions:
Answer: Thank you very much for your pertinent questions.
I discussed them with my colleagues, and we put together the following answers for you:
SVF
for 3D and F2D
for 2D views.
The render format depends on the input format and its extension (obj
, glTF
, etc.).
Different formats may interact slightly differently in the viewer regarding selection, metadata, etc.
The viewer is primarily intended to read the single file format (what we generically refer to as SVF for both 2D and 3D models).
The Model Derivative API allows you to convert all other formats into SVF.
The viewer is not intended to be a standalone multi-format viewer – it is intended to be used in conjunction with the Model Derivative API.I hope this helps.
On popular request, here are the various upcoming events at which I will be presenting on the topics of freeing your BIM data and Connecting the desktop and the cloud with a live roomedit3dv3 demonstration:
I hope to be able to meet you in person at one of these.
I completed the roomedit3dv3 project and published a demo recording to show it in action.
One response via twitter includes another request for a non-public answer, which I am sorry to say I am unable to satisfy:
Question: Would you be willing to demo this remotely via web, maybe 45 mins...?
Answer: I would love to if I had the time to spare.
Unfortunately, I am rather busy trying to answer as many questions as possible for the whole community.
Therefore, I always prefer to discuss everything I do in public and enable the entire community to contribute and share when possible.
Here are the most effective ways to see the demo live and explore it in further depth yourself:
As I keep saying all too often now, please ask all your questions in public, e.g., Revit API related ones in the Revit API discussion forum and all Forge related issues on StackOverflow.
I completed an initial version of the handout document for my presentation on connecting the desktop and the cloud at the RTC Revit Technology Conference Europe in Porto the week after next.
Here is the complete PDF handout document s1_4_hand_connect_desktop_cloud_jtammik.pdf.
For your convenience, I extracted this sneak preview of the class description and table of contents:
Class Description: We discuss the opportunities and advantages offered by accessing and interacting with BIM from the cloud, using both open source and Autodesk Forge web services and cloud-based APIs. We show how they can be accessed and used from any desktop application, including your Revit custom add-in. This provides access to powerful functionality to design, visualise, collaborate, make and use BIM and other CAD data. I present a Forge overview and my suite of examples connecting the desktop and the cloud, culminating in the newest 3D Forge round-trip real-time room editor.
Table of Contents:
I hope this is of interest and use to you!
Now I am really looking forward to a week's vacation before RTC!