0

i have a python plugin i'm trying to write some parts of in C# but adding no overlap 2D seems to confuse me.

in python it takes

model.AddNoOverlap2D(x_intervals,y_intervals)

in C# i tried but the function takes no arguments? so tried to run it over?

var help = model.AddNoOverlap2D();
            for (int i = 0; i < intervalVarListx.Count; i++)
            {
                help.AddRectangle(intervalVarListx[i], intervalVarListy[i]);             
            }

so how is the correct way to use it in C# ?

EDIT: i have added the full code, where it places my 2 boxes in top of each other. Can someone point me in the right direction of what i'm doing wrong here. as it seems like it is adding the no2DOverlap correctly.

EDIT2:

somehow the way i wrote it was the way that worked, must have missed somthing else

Laurent Perron
  • 8,594
  • 1
  • 8
  • 22
Sonny Hansen
  • 620
  • 1
  • 5
  • 18

1 Answers1

1

The C# API to add a no_overlap_2d constraint is this one.

In returns a NoOverlap2DConstraint with the following API.

In your code, do not use lists. Create the NoOverlap2D constraint before the loop, and add directly the rectangles to the constraint instead of to a list, then to the constraint.

Laurent Perron
  • 8,594
  • 1
  • 8
  • 22