Use plug-in command Api in c#

hi everyone
how ?use plug-in command Api in c#
in python is practical work

import rhinoscriptsyntax as rs
import ghpythonlib.components as gh
from Rhino.Geometry import *
a=gh.Pufferfish.UnsplitExtrudeSurface(c,v)
b=gh.Pufferfish.SplitKinkySurface(a)[0]

in C#???

For example, I want to use the SplitKinkySurface command from the pufferfish plugin in C # how?
@Michael_Pryor
@Mahdiyar
use plugin.gh (6.0 KB)

Hi
try this:

using rd = Rhino.NodeInCode;
 var com = rd.Components.FindComponent("Pufferfish.UnsplitExtrudeSurface");
  
  object[] args = new object[]{P,D};
    string[] warnings;
    if(com != null)
    {
      var results = com.Evaluate(args, false, out warnings);
      A = results[0];
    }


use Plugin.gh (7.6 KB)

2 Likes

Thank you @603419608 Your solution was great. I tried to define Component Extrude as a Custum Addition Code, so that I do not have to repeat this sophisticated operation in Code every time, but Error did you know where is the bug of this Code?

  private void RunScript(GeometryBase @Base, Vector3d Direction, ref object Extrusion)
  {
  Extrusion=ext(Base,Direction);
  }

  // <Custom additional code> 
dynamic ext(GeometryBase B, Vector3d D)
{var com = rd.Components.FindComponent("Extrude");
  object[] args = new object[]{B,D};
  string[] warnings;
  if(com != null)
  {
    var results = com.Evaluate(args, true, out warnings);
    var Extr = results[0];
    return Extr;
  }
}


use Components.gh (8.7 KB)

dynamic ext(GeometryBase B, Vector3d D)
{var com = rd.Components.FindComponent("Extrude");
  object[] args = new object[]{B,D};
  string[] warnings;
  if(com != null)
  {
    var results = com.Evaluate(args, true, out warnings);
    var Extr = results[0];
    return Extr;
  }
  return null; // You have to output something when com is null.
}
1 Like