Hi all,
I want to creating custom component with variable number of inputs, but after searching the forum, none on this. I tried to implement in ghpython, but seems the input number is not as that in C#:
Ps: don’t learn python if you are just learning to program, it has terrible programing practices, go for C++ or C# or even the Java version that processing uses (forgot the name of it).
haha I 've saw your this nice answer days before and downloaded the clean sample!
Thanks a lot for your prompt reply. In fact I’m working on research and the main practice is on matlab and python(for data exchange and visualization), that’s why I haven’t any knowledge on C#. So for primary modify of data structure, the ghpython is enough, until now… The C# learning curve is sooo…
So @piac can this function work on ghpython? Is there some more deep tutorial on python beyond this?
By the look of the link, it should be possible, you just have to translate my example to python. Well I would still suggest for you to do your data structure stuff in C# though. If you get stuck down the road you can always post in the Dev group and we can help.
Probably Giulio developed that workflow specially thinking on how to help Butterfly and Honeybee compile the plugin in a more robust way.
@rawitscher-torres Thank you so much for your patience. The only thing is I have no knowledge in C#, so I installed the Visual studio, and try my best typping things like the C# example, and many question rises:
def CanInsertParameter(self,side,idx):
if side==self.GH_ParameterSide.Input:
return 1
else:
return 0
and no Error message, but after compiling, still can’t add variable input.
Definitly know there must be some silly operation, forgive me
I do know that if I don’t compile the script, this component can run very well regardless of efficiency. But so curious of all this amazing function.
I think to upload my script is necessary.This is a tiny component to ‘juxtapose’ trees and remain their structure, which is very helpful for my data processing. TreeAdding.gh (4.3 KB)
Make sure your JuxtaposeTree class implements the IGH_VariableParameterComponent interface
After that try compiling again using the robust method, and see if you can add variable inputs.
If it still wont work, I am afraid one of the python developers at McNeel will have to help you on this one, since I am not a big python user.
In C#, the component class inherits GH_Component and IGH_VariableParameterComponent.
While you can do that in python:
class JuxtaposeTree(component,[VariableParameterComponent])
I do not know what the [VariableParameterComponent] would refer to to get it to work.
Going into component base, you only get the following:
from GhPython.Assemblies import DotNetCompiledComponent as dotnetcompiledcomponent
from GhPython.Assemblies import ExecutingComponent as executingcomponent
For which the only reference is a 6 year old repository and seems to be missing the code.
So I don’t think we have any way of implementing the interface.
You are soooo nice! Now it’s time for me to learn line by line carefully! And thank you @rawitscher-torres. Now can wait for the great python developers’ explain how the python method. Hope they have spare time developing WIP