Is there anyway to draw/add geometry and text through c# script in grasshopper without using output? I would be very thankful if you provide for me a short example.
it might help if you could tell us what you are trying to do.
Grasshopper’s logic is based on inputs and outputs. Not using them should be a well-thought-out decision.
If the purpose is display, you could use the CustomDisplay class:
or, look for examples of DisplayPipeline and DisplayConduit (mostly for compiled components and not for C# Scripts).
for Robert McNeel & Associates
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
Lineand one of type
Color. Also define a
- Override the
BeforeRunScriptmethod (the button with the red and green arrows will insert these overrides).
- Inside the
BeforeRunScriptwipe your lists and set your bounding box to
- Inside your
RunScriptmethod (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
ClippingBoxproperty return the bounding box you’ve been updating.
- If you are drawing curves/points/text then from within
DrawViewportWiresiterate over your Line and Color lists and draw them using the pipeline object available in the