Display a Geometry Debugging Point in the Model

Here are some pointers from a conversation I had with Daren Thomas on how to display a reference point in the model for debugging purposes that may be on general interest.

Question: I am playing around with the FindReferencesWithContextByDirection method and would like to display the references found as coloured blobs or something in the model.

How can I achieve this, please?

This question could also be simplified into: how to create an easily visible dot at a 3D point in the model?

Can such a "dot" exist on its own or must it be drawn onto a face? How?

I never really got into actually creating geometry in Revit.

Answer by Daren: I figured it out on my own now:

I can create a SketchPlane and draw a ModelCurve on it.

Given two points a and b, this RevitPythonShell code will create a green line between them in the 3D view:

  transaction = Transaction(doc)
  transaction.Start('draw a line')
  c = XYZ(0, 0, 0)
  v0 = XYZ(a.X - b.X, a.Y - b.Y, a.Z - b.Z)
  v1 = XYZ(a.X - c.X, a.Y - c.Y, a.Z - c.Z)
  plane = Plane(v0.CrossProduct(v1), a)
  sketchPlane = doc.Create.NewSketchPlane(plane)
  line = doc.Application.Create.NewLineBound(a, b)
  doc.Create.NewModelCurve(line, sketchPlane)

Answer by Jeremy: Yes, model lines is probably the simplest way to go.

You need model curves in 3D, and can use detail curves in a 2D view.

The Creator class included in The Building Code samples includes several usage examples implemented in C#. It was used to graphically highlight geometry in numerous previous posts, and last updated to display the boundaries of a slab.

All it does is package what you describe above nicely, though.

For more complex geometry and transient display, you can also use the analysis visualisation framework AVF. It could be used to draw a full 3D sphere as a marker, if you prefer, as I showed when displaying Apollonian spheres using AVF.