Help for (offsets Brep+MergeCoplanarFaces)

help for (offsets BreMergeCoplanarFaces)

offsetbrep+Mergecoplaner srf.gh (13.7 KB)

  private void RunScript(Brep X, double distance, bool solid, bool round, bool Merge, ref object A, ref object B, ref object C, ref object brep, ref object Result )
  {
    Brep[] blends;
    Brep[] walls;
    Brep Brep;
    Brep = X;
    if (null != X){
      Brep[] offset = Brep.CreateOffsetBrep(Brep, distance, solid, round, Rhino.RhinoDoc.ActiveDoc.ModelAbsoluteTolerance, out blends, out walls);
      if(Merge == true){
        brep = offset.MergeCoplanarFaces(RhinoDocument.ModelAbsoluteTolerance);
        Result = brep;
        brep = offset;}
      A = blends;
      B = walls;
      C = offset;}


@Mahdiyar

Your offset variable is an array, not a Brep.

Maybe something like this:

Brep[] offset = Brep.CreateOffsetBrep...
if (null != offset && offset.Length > 0)
{
  brep = offset[0].MergeCoplanarFaces...

ā€“ Dale

1 Like

thanks
With your tips I managed to write this code

  private void RunScript(Brep Polysrf, double distance, bool solid, bool round, bool Bothside, bool MergeAllFace, ref object A, ref object B, ref object brep, ref object Result )
  {


    Brep[] blends = null;
    Brep[] walls = null;
    Brep[] b;



    if (null != Polysrf ){
      if (false != Bothside ){

        b = offset(Polysrf, distance * (-1), false, round, Rhino.RhinoDoc.ActiveDoc.ModelAbsoluteTolerance, blends, walls);

        b = offset(b[0], distance * (2), true, round, Rhino.RhinoDoc.ActiveDoc.ModelAbsoluteTolerance, blends, walls);
        brep = b;}
      else
      {
        b = offset(Polysrf, distance, solid, round, Rhino.RhinoDoc.ActiveDoc.ModelAbsoluteTolerance, blends, walls);
        brep = b;}

      if(MergeAllFace == true )
      { brep = b[0].MergeCoplanarFaces(Rhino.RhinoDoc.ActiveDoc.ModelAbsoluteTolerance);
        Result = brep;
        brep = b[0];
      }
      A = blends;
      B = walls;}




  }

  // <Custom additional code> 
  Brep[] offset(Brep B, double d, bool s, bool r, double tol, Brep[] ble, Brep[] wa)
  {return   Brep.CreateOffsetBrep(B, d, s, r, tol, out ble, out wa);}