Work fine but don’t find all inputs and outputs
Maybe suggestion of @nathanletwory will separate them all and find different cases
This is the definition if someone want add more features like input/output names; wires, different input/output cases …
component in rhino.gh (17.5 KB)
These input params implement Grasshopper.Kernel.IGH_Param. The following works:
import Grasshopper as gh
import GhPython
import rhinoscriptsyntax as rs
ghObjects = ghenv.Component.OnPingDocument().Objects
points = []
bndsPt = []
bndsH = []
bndsW = []
names = []
name = []
input = []
output = []
for obj in ghObjects:
pivotX = obj.Attributes.Pivot.X
pivotY = obj.Attributes.Pivot.Y
pvt = rs.CreatePoint(pivotX,-pivotY)
points.append(pvt)
bndX = obj.Attributes.Bounds.X
bndY = obj.Attributes.Bounds.Y
bndPt = rs.CreatePoint(bndX,-bndY)
bndsPt.append(bndPt)
bndW = obj.Attributes.Bounds.Width
bndH = obj.Attributes.Bounds.Height
bndsW.append(bndW)
bndsH.append(-bndH)
name = obj.NickName
names.append(name)
if gh.Kernel.IGH_Component in list(type(obj).__bases__):
input.append(obj.Params.Input.Count)
output.append(obj.Params.Output.Count)
elif gh.Kernel.IGH_Param in list(type(obj).__bases__):
input.append(0)
output.append(1)
else:
input.append(0)
output.append(0)
Pivots = points
Corners = bndsPt
X = bndsW
Y = bndsH
names = names
import Rhino.Geometry as rg
import Grasshopper as gh
objects = ghenv.Component.OnPingDocument().Objects;
names = []
grips = []
bounds = []
plane = rg.Plane.WorldXY
for obj in objects:
names.append(obj.Name)
bound = obj.Attributes.Bounds
plane.Origin = rg.Point3d(bound.X, -bound.Y, 0)
bounds.append(rg.Rectangle3d(plane, rg.Interval(0, bound.Width), rg.Interval(0, -bound.Height)))
if gh.Kernel.IGH_Component in list(type(obj).__bases__):
for input in obj.Params.Input:
grip = input.Attributes.Pivot
grips.append(rg.Circle(rg.Point3d(bound.X, -grip.Y, 0),2.0))
for output in obj.Params.Output:
grip = output.Attributes.Pivot
grips.append(rg.Circle(rg.Point3d(bound.X+bound.Width, -grip.Y, 0),2.0))
else:
if obj.Attributes.HasInputGrip:
grip = obj.Attributes.InputGrip
grips.append(rg.Circle(rg.Point3d(grip.X, -grip.Y, 0),2.0))
if obj.Attributes.HasOutputGrip:
grip = obj.Attributes.OutputGrip
grips.append(rg.Circle(rg.Point3d(grip.X, -grip.Y, 0),2.0))
ComponentParameters.gh (16.6 KB)
Is there a way to find the exact coordinates of grips targets?
Method used by @Mahdiyar give Bounds or Pivots but the points are not above output points;
i tried to separate inputs/outputs and find closest point to the target but i stop here.
I think there is a simple way from input parameters
ComponentParameters (4).gh (26.8 KB)
I think this work
rs.CreatePoint(tar.X+tar.Width,-tar.Y-(tar.Height/2))
Is it possible to extract icons of components? I want use them as textures
I tried python component but the script don’t detect the inputs
Yeah, each IGH_DocumentObject has an Icon property which returns a 24x24 pixel System.Drawing.Bitmap. Or it might return null in some cases, so check for that.
Thank you , i will check it
I will try with icons later.
This is an update; rs.AddInterpCurve give exactly the same wires as in grasshopper
ComponentParameters final_up.gh (9.9 KB)
I use the solution of @Mahdiyar to get icons and move down the black areas but i have two problems.
1- the script bake points autmatically
2- one mesh is null (item 20)
ComponentParameters final_re2.gh (18.0 KB)
UPDATE:
It work fine now, i don’t know what was the problem with baking
Thank you @Mahdiyar
New update without icons because of the low image quality
ComponentParameters final_newup.gh (11.4 KB)