Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from ghpythonlib.componentbase import dotnetcompiledcomponent as component
- import Grasshopper, GhPython
- import System
- import Rhino
- import rhinoscriptsyntax as rs
- class SortPointEx(component):
- def __new__(cls):
- instance = Grasshopper.Kernel.GH_Component.__new__(cls,
- "Python", "SortPointEx", """GhPython provides a Python script component""", "Extra", "test")
- return instance
- def get_ComponentGuid(self):
- return System.Guid("GUID")
- def SetUpParam(self, p, name, nickname, description):
- p.Name = name
- p.NickName = nickname
- p.Description = description
- p.Optional = True
- def RegisterInputParams(self, pManager):
- p = Grasshopper.Kernel.Parameters.Param_Point()
- self.SetUpParam(p, "Points", "Points", "Script variable Python")
- p.Access = Grasshopper.Kernel.GH_ParamAccess.list
- self.Params.Input.Add(p)
- p = Grasshopper.Kernel.Parameters.Param_Integer()
- self.SetUpParam(p, "SortType", "SortType", "Script input SortType.")
- p.Access = Grasshopper.Kernel.GH_ParamAccess.item
- self.Params.Input.Add(p)
- def RegisterOutputParams(self, pManager):
- p = Grasshopper.Kernel.Parameters.Param_GenericObject()
- self.SetUpParam(p, "P", "P", "Script output P.")
- self.Params.Output.Add(p)
- p = Grasshopper.Kernel.Parameters.Param_GenericObject()
- self.SetUpParam(p, "I", "I", "Script output I.")
- self.Params.Output.Add(p)
- def SolveInstance(self, DA):
- p0 = self.marshal.GetInput(DA, 0)
- p1 = self.marshal.GetInput(DA, 1)
- result = self.RunScript(p0, p1)
- if result is not None:
- if not hasattr(result, '__getitem__'):
- self.marshal.SetOutput(result, DA, 0, True)
- else:
- self.marshal.SetOutput(result[0], DA, 0, True)
- self.marshal.SetOutput(result[1], DA, 1, True)
- def get_Internal_Icon_24x24(self):
- o = "アイコン"
- return System.Drawing.Bitmap(System.IO.MemoryStream(System.Convert.FromBase64String(o)))
- def RunScript(self, Points, SortType):
- #点をソートする処理
- # return outputs if you have them; here I try it for you:
- return (P, I)
- import SortPath as sp
- class DisplaySortResult(component):
- def __new__(cls):
- instance = Grasshopper.Kernel.GH_Component.__new__(cls,
- "SortResDis", "DisplaySortResult", """GhPython provides a Python script component""", "Extra", "test")
- return instance
- def get_ComponentGuid(self):
- return System.Guid("GUID")
- def SetUpParam(self, p, name, nickname, description):
- p.Name = name
- p.NickName = nickname
- p.Description = description
- p.Optional = True
- def RegisterInputParams(self, pManager):
- p = Grasshopper.Kernel.Parameters.Param_Point()
- self.SetUpParam(p, "Points", "Points", "Script variable Python")
- p.Access = Grasshopper.Kernel.GH_ParamAccess.list
- self.Params.Input.Add(p)
- p = Grasshopper.Kernel.Parameters.Param_GenericObject()
- self.SetUpParam(p, "Reset", "Reset", "Script input Reset.")
- p.Access = Grasshopper.Kernel.GH_ParamAccess.item
- self.Params.Input.Add(p)
- p = Grasshopper.Kernel.Parameters.Param_Integer()
- self.SetUpParam(p, "Speed", "Speed", "Script input Speed.")
- p.Access = Grasshopper.Kernel.GH_ParamAccess.item
- self.Params.Input.Add(p)
- def RegisterOutputParams(self, pManager):
- p = Grasshopper.Kernel.Parameters.Param_GenericObject()
- self.SetUpParam(p, "T", "T", "Script output T.")
- self.Params.Output.Add(p)
- p = Grasshopper.Kernel.Parameters.Param_GenericObject()
- self.SetUpParam(p, "C", "C", "Script output C.")
- self.Params.Output.Add(p)
- p = Grasshopper.Kernel.Parameters.Param_GenericObject()
- self.SetUpParam(p, "P", "P", "Script output P.")
- self.Params.Output.Add(p)
- p = Grasshopper.Kernel.Parameters.Param_GenericObject()
- self.SetUpParam(p, "Pl", "Pl", "Script output Pl.")
- self.Params.Output.Add(p)
- def SolveInstance(self, DA):
- p0 = self.marshal.GetInput(DA, 0)
- p1 = self.marshal.GetInput(DA, 1)
- p2 = self.marshal.GetInput(DA, 2)
- result = self.RunScript(p0, p1, p2)
- if result is not None:
- if not hasattr(result, '__getitem__'):
- self.marshal.SetOutput(result, DA, 0, True)
- else:
- self.marshal.SetOutput(result[0], DA, 0, True)
- self.marshal.SetOutput(result[1], DA, 1, True)
- self.marshal.SetOutput(result[2], DA, 2, True)
- self.marshal.SetOutput(result[3], DA, 3, True)
- def get_Internal_Icon_24x24(self):
- o = "アイコン2"
- return System.Drawing.Bitmap(System.IO.MemoryStream(System.Convert.FromBase64String(o)))
- def __init__(self):
- self.createPl = sp.SortPath()
- def RunScript(self, Points, Reset, Speed):
- #ソートされたパスを描画する処理
- # return outputs if you have them; here I try it for you:
- return (T, C, P, Pl)
- class AssemblyInfo(GhPython.Assemblies.PythonAssemblyInfo):
- def get_AssemblyName(self):
- return "SortPointsEx"
- def get_AssemblyDescription(self):
- return """"""
- def get_AssemblyVersion(self):
- return "0.1"
- def get_AuthorName(self):
- return ""
- def get_Id(self):
- return System.Guid("GUID")
Add Comment
Please, Sign In to add comment