C# insert Blocks based on index generated from distances


I want to populate a target surface with a plane to plane transformation using provided blocks.Its an attractor system .

The code fails in step 4, when its about to transform using the corresponding block.
As far as I see the scale values are correct,also the remapping works correct.

My procedure is as following:

  1. //Get aim lenghts ,dividing the target surface
    2)// get the blocks, make a bBox measure the length of two sides(x and y) to be able to scale the block to
    3)// remapped the list to integers to be able to choose the block by index
    4)// insert the blocks using the integers from the remapped list to choose which

Thanks everybody, I hope its not too much lines or to unorganized for you to review.If you want I will truncate it.Thanks!

Have a nice day!

files: blockIndices.gh (8.5 KB)
blocktest.3dm (22.3 KB)

double xScaleFac = 1.0;
double yScaleFac = 1.0;
InstanceDefinition defIndex = null ;

  if (remapped[i] < defs[i].Index)
    xScaleFac = xScaleFactors[i];
    yScaleFac = yScaleFactors[i];
    defIndex = defs[i];

  if(defIndex != null){
    Transform scale = Transform.Scale(planes[i], xScaleFac, yScaleFac, 1.00);
    Transform move = Transform.PlaneToPlane(Plane.WorldXY, planes[i]);
    Transform compound = scale * move;
    RhinoDocument.Objects.AddInstanceObject(defIndex.Index, compound);
    Print("defIndex is null");

Thanks for spending time Dany,
I just got it myself, sorry for the not being clear and the monologue.

Have you considered using spacemorphs rather than scale,move,orient?

Hi @Michael_Pryor,
Thanks for mentioning it!
Yes I thought about it. I know your plug in is basically about it, could you provide a simple example in C# , that I could use as a start point? Would be really appreciated! Thanks!

I don’t actually use it but I know the box morph component uses space morphs from grasshoppers sdk. For my plugin I just use twisted boxes which are not an available type to use in the sdk so I had to use reflection on grasshoppers own libraries.


seems I will need a closer look/research on this, maybe open a new thread, look quite complex.

Well seems you just want to morph blocks onto a surface? Maybe you can just get away with splop.

I¨ll give it a try, looks great!