C# Kangarro2 Custom Goal behaviour

Hi,
i am trying to learn kangaroo custom goals, i tried to modify the Daniel Pikers simple example but am getting this weird result as most poits are merging. I 'd like them to snap to middle of theirs CPs between 2 surfaces. (line 106)

Hi Vladimir, can you post your code to save me retyping it from your screenshot?

never mind - I just tried the same thing. It works fine, but maybe is not the result you expect, as there is nothing stopping the points all ending up in the same place. You might want to add some other constraints…
for instance - keeping them loosely fixed in X and Y:


midsrf.gh (10.8 KB)

(also, there’s no need to make a line and convert it to a nurbs curve just to get the midpt between 2 points - you can simply average the points directly)

Hi Daniel Thanks for help, i ll think more about what it does in meantime i got a wierd bug. i believe this code should produce same goals as Length(line) but it does not, it has same input and item access, numbers as float, and line as line.
import ghpythonlib.components as ghc.

a=ghc.Kangaroo2Component.LengthLine(l,d,s)

I’d advice against using ghpythonlib.components unless absolutely necessary (it’s most often a layer of indirection you do not need, might cause unexpected behaviours, and is very difficult to debug), and instead implement the KangarooSolver.dll directly in GHPython (like back in Smart Geometry 2016). Quick reminder here. This might result in the same behaviour, but at least Daniel can see what you’re doing ~1:1 with the compiled C# version.