TextNote Rotation, Forge DevCon, TensorFlow and Keras

The Forge DevCon developer conference has been happily united with Autodesk University, text note rotation is easy, and I continued my deep learning exploration for implementing a Revit API question answering system:

Forge DevCon at AU

A match made in heaven: the Forge DevCon developer conference has been happily united with Autodesk University

A lot of synergy is gained connecting the two.

Forge DevCon at AU

The last DevCon in 2016 was held in San Francisco and was a great success.

We plan to make it bigger and better still this year, and moving it to Las Vegas for 2017 will help.

It will take place on November 13-14, i.e., Monday and Tuesday of the Autodesk University week.

In previous years, these were the days on which we hosted the DevDay and DevLab conference and open house support hackathon for application developers.

This is a good thing.

Somewhat selfishly, it means less travel for those of us coming across from Europe.

It will also make AU a more compelling, developer-centric event.

Now nobody has to choose between DevCon and DevDays + AU. It’s all together in one place.

Setting TextNote Rotation

Rotating a text note is very easy, both during creation and when modifying existing elements.

One little complication for existing add-ins is introduced by fact that the approach changed with the TextNote API overhaul in Revit 2016:

Question: In Revit 2015, I used the method:

  TextNote text = doc.Create.NewTextNote( 
    view, origin, baseVec, upVec, lineWidth,
    TextAlignFlags.TEF_ALIGN_CENTER 
    | TextAlignFlags.TEF_ALIGN_MIDDLE,
    strText );

for creating a text note.

As this method has been replaced with TextNote.Create, I can create a text note using:

  TextNote text = TextNote.Create( doc, 
    view.Id,  origin, strText, texttypeID );

But how do I set its rotation when creating it?

Also, how do I change the rotation of existing text notes?

Answer: To rotate the TextNote as it is placed, one of the overloads for TextNote.Create uses TextNoteOptions and its Rotation option:

  TextNoteOptions tno = new TextNoteOptions();
  tno.Rotation = 0.5 * Math.PI; // in Radians
  tno.TypeId = texttypeID; // need to include text type

  TextNote text = TextNote.Create( doc, 
    view.Id, origin, strText, tno );

Response: This is how I managed to create the rotated text aligned with existing curve based elements:

  // get the curve of the element
  Curve curve = ( (LocationCurve) elem.Location )
    .Curve;

  // get start and end point of pipe
  XYZ PipeEnd = curve.GetEndPoint( 1 );
  XYZ PipeStart = curve.GetEndPoint( 0 );

  // get vector representing the pipe
  XYZ v = PipeEnd - PipeStart;

  double angle = Math.Atan2( v.Y, v.X );

  var testOptions = new TextNoteOptions()
  {
    HorizontalAlignment = HorizontalTextAlignment.Center,
    Rotation = angle,
    TypeId = texttypeID
  };

  var text = TextNote.Create( doc, view.Id,
    origin, strText, testOptions );

Rotate text

TensorFlow and Keras

Continuing my superficial browsing of various open source possibilities on which to base a question answering system for the Revit API add-in programming, I now bumped into TensorFlow (web site, GitHub repo).

It converts the learning matter to vectors and computes similarities, learning best matches by assigning weight using various algorithms.

Here are a bunch of interesting TensorFlow tutorial and other related texts that I would all like to work through in greater depth anon:

They also led to further papers and the Keras system built on top of it:

I decided to install these packages, which led to an interesting problem that took a while to sort out and seems worthwhile documenting for future reference.

Updating Restricted Python Packages

TensorFlow and Keras are Python based.

Installation is very straightforward and easy.

TensorFlow requires several other base packages: six, funcsigs, pbr, mock, numpy, protobuf.

Unfortunately, on my system, some of these were out of date and the system refused to allow me to update them.

For instance, calling $ pip install tensorflow led to a conflict due to the existence of prior versions of six and numpy.

After some research, I determined that I could resolve the issues by simply deleting the associated files.

Unfortunately, this is not permitted by the system, as described in the question on why chown reports operation not permitted on OS X.

The short description of the solution for this is given there:

System Integrity Protection (rootless) ... boot into Recovery Mode (Cmd-R), run csrutil disable, then restart; to reenable, use csrutil enable.

It is explained in greater detail in the StackOverflow question on restricted folder and files in OS X El Capitan:

To temporarily disable SIP (System Integrity Protection):

On my system, the problematic packages live in the folder

You can examine their restricted status using ls:

$ ls -lhdO num*
drwxr-xr-x  36 root  wheel  restricted             1.2K May 25  2016 numpy
-rw-r--r--   1 root  wheel  restricted,compressed  1.6K Aug  1  2015 numpy-1.8.0rc1-py2.7.egg-info

By temporarily disabling SIP, I was finally able to move them out of the way and continue normal installation:

$ sudo -H pip install tensorflow

With TensorFlow in place, I successfully ran the standard Python install in the keras folder and immediately executed one of its interesting examples:

/a/src/deep_learning $ cd kears
/a/src/deep_learning/keras $ sudo python setup.py install
/a/src/deep_learning/keras $ cd examples
/a/src/deep_learning/keras/examples $ python babi_rnn.py

Keras is up and running now.

What shall I do next?

Here are two descriptions of successful experiments implementing minimal question answering systems with it that I am taking a deeper look at:

Time for me to get going putting together some Revit API related tests?

Rules of Machine Learning

By the way, before doing anything else, I and everybody else interested in machine learning ought to read and ponder Martin Zinkevich's 43 Rules of Machine Learning, split up into useful consecutive phases:

To quote Martin:

The document is arranged in four parts:

It is strongly geared towards ranking.