Twitter Updates

March 21, 2012

Melbourne Day Two

On the second day of the Revit API training here in Melbourne, we addressed a number of further interesting issues, both basic and beyond.
Our sample code ended up demonstrating the following functionality:

I also received interesting comments on a previous post on finding the
Revit parent window that
is worthwhile sharing here.

After the training, I went for a quick climb with Rob at
Hardrock,
marvelling at yet another grading system.

Here in Australia I went for the easy grades 16 to 18.
No idea what they compare to in European or American grading systems.

After that, I had a sandwich in the
Siglo roof-top
bar on 161 Spring Street above
the
Melbourne Supper Club in
the same house.
These two places share an extremely sympathetic anonymous entrance, a simple brown wooden door with no sign whatsoever.
If no-one told you they are there, you would never find them.

The next step we looked at is identification of all unique vertices in the geometry.
For this, we need to somehow implement a fuzzy method to distinguish between points that really are different, but detect that points that are nearly the same should in fact be treated as identical.
We can achieve this by implementing an XYZ equality comparer, e.g. like this:

As an almost-equal tolerance we are using a rather large value, because Revit uses this pretty rough number in several places itself, e.g. to limit the limit the
minimum line length.

You must be careful to also define a hash code that does not return different values for points that you wish to compare equal, or every single point will be considered different, possibly even when a point is compared with itself.
In this case we are using our two-decimal string representation to define a hash code, so many points that are considered different by the comparison operator will actually generate the same hash code.
In a perfect world, the hash code generator would be a bit more appropriately chosen to match the equality comparison precision.

We can easily implement a short and sweet method to extract all the unique corner vertices of the solid geometry by using the vertices themselves as keys in a dictionary based on our equality comparer like this:

The dictionary returned includes a count of how many times each vertex was encountered.

This is something very important that I have looked at numerous times in the past.
I already presented the fundamentals for handling this when looking at
nested instance geometry,
which also implements a GetVertices method similar to the above,
and reused it for
toposurface point classification and
accessing the
top faces of
a sloped wall.

Extensible Storage

Here is the documentation and sample code from my Autodesk University 2011
class and
lab on
this topic, which says it all:

TrackBack

Comments

Melbourne Day Two

On the second day of the Revit API training here in Melbourne, we addressed a number of further interesting issues, both basic and beyond.
Our sample code ended up demonstrating the following functionality:

I also received interesting comments on a previous post on finding the
Revit parent window that
is worthwhile sharing here.

After the training, I went for a quick climb with Rob at
Hardrock,
marvelling at yet another grading system.

Here in Australia I went for the easy grades 16 to 18.
No idea what they compare to in European or American grading systems.

After that, I had a sandwich in the
Siglo roof-top
bar on 161 Spring Street above
the
Melbourne Supper Club in
the same house.
These two places share an extremely sympathetic anonymous entrance, a simple brown wooden door with no sign whatsoever.
If no-one told you they are there, you would never find them.

The next step we looked at is identification of all unique vertices in the geometry.
For this, we need to somehow implement a fuzzy method to distinguish between points that really are different, but detect that points that are nearly the same should in fact be treated as identical.
We can achieve this by implementing an XYZ equality comparer, e.g. like this:

As an almost-equal tolerance we are using a rather large value, because Revit uses this pretty rough number in several places itself, e.g. to limit the limit the
minimum line length.

You must be careful to also define a hash code that does not return different values for points that you wish to compare equal, or every single point will be considered different, possibly even when a point is compared with itself.
In this case we are using our two-decimal string representation to define a hash code, so many points that are considered different by the comparison operator will actually generate the same hash code.
In a perfect world, the hash code generator would be a bit more appropriately chosen to match the equality comparison precision.

We can easily implement a short and sweet method to extract all the unique corner vertices of the solid geometry by using the vertices themselves as keys in a dictionary based on our equality comparer like this:

The dictionary returned includes a count of how many times each vertex was encountered.

This is something very important that I have looked at numerous times in the past.
I already presented the fundamentals for handling this when looking at
nested instance geometry,
which also implements a GetVertices method similar to the above,
and reused it for
toposurface point classification and
accessing the
top faces of
a sloped wall.

Extensible Storage

Here is the documentation and sample code from my Autodesk University 2011
class and
lab on
this topic, which says it all: