Programming Archive

How to stop components from automatically displaying results in Grasshopper

When you run a component in Grasshopper, if there are outputs associated to it, the outputs will be visualised in Rhino without you needing to do much. This is part of the ‘preview’ feature of a component, but sometimes, you might not want the users to automatically see the output. For example, if you have

How to pass custom data between Grasshopper components

Grasshopper is designed to work with components that handle specific functions, rather than components which try to do an ‘all-in-one’ approach. When designing your own custom Grasshopper components, there might be a need to pass custom data along the wires between components. This is easy enough to do when you know how, but getting to

How to obtain the minimum and maximum values from a list in Grasshopper

Sometimes you need to know what the minimum and the maximum values are in a list or from a collection of lists. In Grasshopper, there are min and max components which will take two values and return the minimum and maximum respectively, but there isn’t a component for finding the min/max values within a list

VBA – Sending keyboard commands

In previous posts (here and here) we’ve looked at keyboard listeners with a view to have our program listen for keyboard presses from the user and act upon them. In this post, we’re going to have a look at the opposite, whereby our program sends a key command to the operating system for another program

How to convert OpenCV cv::mat to System Bitmap to System ImageSource

OpenCV is an open source computer vision library which can be used for a wide variety of things such as face recognition, people detection, motion tracking, video editing and image manipulation. For my undergraduate project, I made use of the OpenCV libraries to create a facial recognition system. It used a webcam to detect ID

How to access geometry Guids in Grasshopper components

This month has been a nice month for software development in my research, working on creating new analysis for healthcare design. The majority of it has been relatively straight forward (except the interpolation issue) working in C++ to produce the analysis. However, to move towards a tool which can be used in industry, I have

C++ Error LNK2005 – item already defined in file.obj

Linker errors (LNK) can be a bit more difficult to solve than standard C errors if you don’t know how to read the error output. This is added to by the fact that you can’t double-click the error and be taken to the line causing the problem (if using Visual Studio anyway), so being able

Interpolating data points to produce colour maps – code examples

For a lot of the work I do in my research, I need to produce colour maps which can visualise data in a user-friendly way while still getting across the necessary elements of the analysis performed. In my current area of research, looking at wayfinding tools to analyse healthcare building design for natural wayfinding, I’m

Obtaining the angle between two vectors for 360 degrees

This previous post demonstrated how to obtain the angle between two vectors from three geometric points, providing an angle between 0-180 degrees. However, there may be times when you need the angle between 0-360 degrees instead, as I did earlier this week. As such, this post aims to complete the previous with the solution for

Calculating angle between two vectors from geometric points – code solution

Calculating the angle between two vectors is a fairly easy solution to find online – there are plenty of maths help websites which will take you through step by step how to work out the angle, however, not many sites will provide you with the necessary programming code to put this into your software. As