Based on the "FindSurfaceArea" sample macro I was able to get something working, there's probably a better way which I'd still be interested in.
The ViewCone I'm using for the arrow tip i.e. has an issue when it is pointing up/downwards, see the "missing" red tip at the beginning of the clip.

you need a few imports
from System import Guid, Byte, Array
clr.AddReference("Trimble.Vce.GraphicsEngine2D")
from Trimble.Vce.GraphicsEngine import OverlayBag
clr.AddReference("Trimble.Vce.UI.UIManager")
from Trimble.Vce.UI.UIManager import TrimbleOffice
clr.AddReference ("Trimble.Vce.UI.Controls")
from Trimble.Vce.UI.Controls import DisplayWindow
in __init__ you need
self.ViewOverlay = Guid.NewGuid()
self.overlayBag = OverlayBag(self.ViewOverlay)
The overlay gets a unique ID everytime you run the macro, so you must make sure you dispose properly of it when you are done. Otherwise it will be persistent on the screen and you'd need to restart TBC.
add the following wherever you'd reach the end of the macro, i.e. the end of of OkClicked and CancelClicked
TrimbleOffice.TheOffice.MainWindow.AppViewManager.RemoveOverlayGeometry(self.ViewOverlay)
And for the case that the user just closes the project while the macro hasn't been closed the following routine that seems to be called automatically by TBC.
def Dispose(self, thisCmd, disposing):
TrimbleOffice.TheOffice.MainWindow.AppViewManager.RemoveOverlayGeometry(self.ViewOverlay)
And the code for my three arrows
def drawoverlay(self, ps1, ps2, ps3):
# ps1 - origin, ps2 - point on x-axis, ps3 - point on y-axis
TrimbleOffice.TheOffice.MainWindow.AppViewManager.RemoveOverlayGeometry(self.ViewOverlay)
self.overlayBag = OverlayBag(self.ViewOverlay)
xaxis = Vector3D(ps1, ps2)
yaxis = Vector3D(ps1, ps3)
zaxis = Vector3D.CrossProduct(xaxis, yaxis)[0]
# make the overlay arrows a uniform length - the longest axis that has been defined by the user
if xaxis.Length > yaxis.Length:
yaxis.Length = xaxis.Length
zaxis.Length = xaxis.Length
else:
xaxis.Length = yaxis.Length
zaxis.Length = yaxis.Length
#self.overlayBag.AddViewCone(ps1, ps2, double length, double radius, int color, byte opacity)
conelength = xaxis.Length / 5 # make the cone a decent size
self.overlayBag.AddLine(ps1 + xaxis, ps1, 255, 5)
self.overlayBag.AddViewCone(ps1 + xaxis, ps1, conelength, conelength / 5, 255, Byte.Parse("255"))
self.overlayBag.AddLine(ps1 + yaxis, ps1, 65280, 5)
self.overlayBag.AddViewCone(ps1 + yaxis, ps1, conelength, conelength / 5, 65280, Byte.Parse("255"))
self.overlayBag.AddLine(ps1 + zaxis, ps1, 16711680, 5)
self.overlayBag.AddViewCone(ps1 + zaxis, ps1, conelength, conelength / 5, 16711680, Byte.Parse("255"))
# if it only needs to be visible in all Planview then remove the Hoops3DViewGUID
array = Array[Guid]([DisplayWindow.Hoops3DViewGUID, DisplayWindow.HoopsPlanViewGUID])
TrimbleOffice.TheOffice.MainWindow.AppViewManager.AddOverlayGeometry(array, self.overlayBag)
return
------------------------------
Ronny Schneider
------------------------------