There’s a button at the top of the C# code editor that looks like an eye. Click on it to insert the three relevant method overrides for custom previews. There are already plenty of examples out there as Giulio mentioned, but the basic idea is usually this:
- Define a bunch of class level variables that hold all your preview data. For example two lists, one of type
Line
and one of typeColor
. Also define aBoundingBox
field. - Override the
BeforeRunScript
method (the button with the red and green arrows will insert these overrides). - Inside the
BeforeRunScript
wipe your lists and set your bounding box toEmpty
. - Inside your
RunScript
method (which potentially gets called a lot during every solution) populate your lists and make sure your bounding box grows enough to always contain all the geometry you wish to draw. - From your
ClippingBox
property return the bounding box you’ve been updating. - If you are drawing curves/points/text then from within
DrawViewportWires
iterate over your Line and Color lists and draw them using the pipeline object available in theIGH_PreviewArgs
instance.