Selection Filters, Adjacency and the Good Universe

Today, let’s look at:

A Generic Selection Filter Implementation

Yesterday, I presented my new

JtPairPicker element pair selection utility class
.
It included a templated selection filter class.
I later realised that I could make use of that in several other places as well, replacing the existing explicit Wall, CurveElement and Pipe selection filters by a generic JtElementsOfClassSelectionFilter<T> one instead:


  /// <summary>
  /// Allow selection of elements of type T only.
  /// </summary>
  class JtElementsOfClassSelectionFilter<T>
    : ISelectionFilter where T : Element
  {
    public bool AllowElement( Element e )
    {
      return e is T;
    }
 
    public bool AllowReference( Reference r, XYZ p )
    {
      return true;
    }
  }

Pretty trivial, but still, it pleases me to replace three other classes with this single one.

It also took a moment to figure out how to correctly string together the sequence ... : ISelectionFilter where T : Element

As always, the most up to date version of The Building Coder samples is provided in
its GitHub repository,
and the version including the new JtElementsOfClassSelectionFilter class described above is

release 2015.0.116.3
.

Determining Adjacent Rooms and Spaces

Another question that regularly comes up is on determining the relationship between neighbouring rooms and spaces:

Question: I am looking at the acquisition of energetic data from Revit building models.
For a given room or space, I would like to obtain all the adjacent rooms and spaces on the same level and the ones directly above and below, together with their respective intersecting areas.

I was thinking of gathering all of them with their respective boundary faces, then searching for adjacencies and calculating potential neighbouring intersection areas in a second step. However, I am afraid that this could quickly get quite complicated and consequently slow.

Is there a quicker way to find adjacent rooms and spaces within a certain range? Could bounding box intersection filters help, for instance?

Answer: Congratulations on starting work on such an interesting problem.

You should definitely do some additional exploration from an end user point of view, asking product usage experts and application engineers.

As far as I know, some of this kind of data is available from the Revit BIM with no programming required, e.g. via the gbXML file.

Please also take a deep look at the tools and results provided by the

BPA team
for
building performance analysis.

As far as I know, Dynamo also provides a good entry point for that.

I would be surprised – and impressed – if you are aiming to implement anything – in the beginning stages or your exploration, in any case – that has not already been addressed by the BPA and Dynamo communities.

Finally, from the pure Revit API point of view, The Building Coder provides a topic list 5.2 on

2D Booleans and Adjacent Areas
that I just updated for you and lists some previous discussions and explorations in this area.

Arno Gruen on the Good Universe

Almost the only regular journalistic media production that I enjoy reading is
Das Magazin,
a Saturday supplement included with several major Swiss daily newspapers.
I love it.

The last issue,
nr. 45, November 8, 2014
(PDF),
included an interview with
Arno Gruen,
Ueber das Boese.

It ends on such a nice optimistic note that I would like to share my translation from German of it with you:

<!–

Darf ich Ihnen noch die Gretchenfrage stellen: Wie haben Sies mit der Religion?

Ich habe nichts gegen religiöse Gefühle. Mich stören Religionen, die selber eine Machtstruktur sind, mit dem Zweck, andere Menschen zu beherrschen und ihr Denken zu verformen.

Ist das nicht bei allen Religionen so?

Nein. Als C. G. Jung in Amerika war, traf er auf Puebloindianer, die jeden Morgen in Richtung eines Berges beteten. Der Häuptling sagte ihm: «Unsere Gebete helfen Gott, die Sonne über den Berg zu hieven.» Jung bemerkte dazu treffend, dass sich diese Menschen ihrem Gott ebenbürtig fühlen. Und das ist etwas ganz anderes, als wenn man zum Sklaven seiner Religion wird. Man muss Gott in sich selber finden, wie schon ein alter deutscher Mystiker sagte.

Und wie ist das nun bei Ihnen persönlich?

Ich denke, übrigens genau wie Einstein, dass die Welt nicht sinnlos ist. Das ist durchaus ein religiöses Gefühl.

Und worin besteht dieser Sinn?

Die Welt ist nicht zufällig. Sie ist so gebaut, dass es eine Entwicklung in Richtung des Guten gibt.

Here is my translation of this:

–>

May I ask you a final crucial question: what is your stand on religion?   — I have nothing against religious feelings. I am not in favour of religions maintaining a power structure with the purpose of controlling people and distorting their thinking.

Aren’t all religions like that?   — No. In America, C.G. Jung met some Pueblo Indians who prayed every morning towards a neighbouring mountain. The chief told him, “Our prayers help God heave the sun over the mountain.” Jung aptly commented that these people felt equal to their God. That is something completely different from becoming a slave of one’s religion. You have to find God in yourself, as already stated by many mystics in the past.

And how is it for you personally?   — I agree with Einstein that the universe is not without meaning. That is quite a religious feeling.

And what is that meaning?   — The world is not random. It is constructed to encourage development of the good.


Comments

2 responses to “Selection Filters, Adjacency and the Good Universe”

  1. Hello, Jeremy!
    I have not found the place to ask a question. Google search did not help me.
    Explain me, please, if possible, how it works – VG/Filters/Filter Rules – I mean criteria operator specifically for Workset – how must “is greater than” work? Wthat is the logic? (first letter or order or smth else)
    Im trying to find a description of this process in API – and failed. Thank you!

  2. Dear Andrey,
    When searching for answers to questions like this, it makes sense to explore the behaviour through the standard Revit product user interface first.
    The API normally does change anything significant, just provide programmatic access to the underlying UI functionality.
    I hope you have got this resolved by now?
    Cheers, Jeremy.

Leave a Reply to AndreyCancel reply

Discover more from Autodesk Developer Blog

Subscribe now to keep reading and get access to the full archive.

Continue reading