Icon Access and Reference Plane in Family Instance

Today I highlight two of Fair59's numerous solutions in the Revit API forum, and also mention a joke I picked up in a Swedish cartoon:

Fadaesen on Racism versus Realism

As I recently mentioned, I visited Sweden in the beginning of August for a week's hiking.

Before getting to the Revit API stuff, let me share this little cartoon that I enjoyed in the train there.

The artist and author, Marja Nyberg, very kindly gave me permission to translate and reproduce it here:

Fadaesen on racism

Back to the Revit API, though...

Retrieving a Reference Plane Location in a Family Instance

Fair59 continues providing pretty advanced, tricky and just-about perfect solutions to many challenging questions in the Revit API discussion forum, such as for this thread on getting the position of a reference plane in a family instance:

Question: Is it possible to determine the position of a reference plane in a family instance that is not aligned with any mass or other object?

I need its direction and position.

I tried to use the ReferenceIntersector, but it does not detect this reference.

Answer: You could start out from the very informative and useful previous thread on retrieving the direction of a reference (reference plane or reference line).

That only determines the direction. However, from the dimension in the code, you could also find a point on the plane.

On the other side, here is an alternative approach:

You can create a sketch plane using the reference, then query the origin and normal from the geometry plane of the sketch plane.

  /// <summary>
  /// Retrieve origin and direction of the left
  /// reference plane within the given family instance.
  /// </summary>
  static bool GetFamilyInstanceReferencePlaneLocation(
    FamilyInstance fi,
    out XYZ origin,
    out XYZ normal )
  {
    bool found = false;
    origin = XYZ.Zero;
    normal = XYZ.Zero;

    Reference r = fi
      .GetReferences( FamilyInstanceReferenceType.Left )
      .FirstOrDefault();

    ifnull != r )
    {
      Document doc = fi.Document;

      usingTransaction t = new Transaction( doc ) )
      {
        t.Start( "Create Temporary Sketch Plane" );
        SketchPlane sk = SketchPlane.Create( doc, r );
        ifnull != sk )
        {
          Plane pl = sk.GetPlane();
          origin = pl.Origin;
          normal = pl.Normal;
          found = true;
        }
        t.RollBack();
      }
    }
    return found;
  }

Many thanks to Frank @Fair59 Aarssen for this effective solution, and his many other helpful answers, and also to Alexander @aignatovich Ignatovich, aka Александр Игнатович, for the blog post suggestion.

By the way, I added this method to The Building Coder samples, which heretofore lacked any example at all of using the relatively new family instance GetReferences method, in the module CmdDimensionInstanceOrigin.cs.

Accessing the Revit Ribbon Icons

Fair59 and Matt Taylor also recently provided another useful forum answer, in the two threads on Revit ribbon icons and pictograms and view icons in Revit:

Question: I would like to display icons instead of dumb text in my add-in ribbon user interface.

Does anybody where I can find the built-in Revit icons and pictograms?

Answer: You can quickly check to see what icons are available in any DLL by:

The built-in Revit icons are contained in the file Utility.dll in the same folder as Revit.exe.

Many thanks to Frank and Matt for helping to solve these two questions as well.