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)
transaction.Commit()

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
.


Comments

2 responses to “Display a Geometry Debugging Point in the Model”

  1. Hi Jeremy,
    in fact, the text does not give an answer how to display a single point at all.
    What I mean is that there is no AcDbPoint3d equivalent in the Revit world, and it cannot be workarounded by drawing ModelCurves since there is a minimum length for creating them.
    As far as I know, even using the AVF, you cannot draw single points. But even if that is possible:
    For debugging purposes, it would be useful to have a selectable object, but since AVF objects are not selectable (excepting the legend, I think), you could not check any XYZ values using RevitLookup, for example.
    Cheers,
    Rudolf

  2. Dear Rudolf,
    Right, I should have said marker, not point.
    You could use AVF and a self-defined font to draw the XYZ information :-)
    Or you could use my self-defined tooltip to display it:
    http://thebuildingcoder.typepad.com/blog/2012/10/uiview-windows-coordinates-referenceintersector-and-my-own-tooltip.html
    Cheers, Jeremy.

Leave a Reply to Jeremy TammikCancel reply

Discover more from Autodesk Developer Blog

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

Continue reading