Simple example: Let’s say I have one polyline and each time I change it the script will create an offset of it.
Almost as grasshopper does it, but I don’t want to do it with gh, I want to have a pyscript always running in the background - so I won’t have to run it each time I change the polyline (it will always be running and offsetting live)
Is it possible? this could be useful for other things also.
Not a programmer… It’s probably possible to make a C++ plug-in that does that, but that’s out of my league. However, it would be possible to script the polyline creation and auto-offset at the same time - as long as you were willing to use a different command than ! _Polyline to make the polyline itself.
You would of course have to deal with all the fun stuff that comes with offsets, namely which side to offset and various failure situations…
It is possible. You’ll need to start your script in another thread, offsetting the curve and the hard part adding it to the Rhinodocument without crashing your Rhino instance. You also loose the reference to your thread once the script finishes. Therefore you need to store relevant references in the RH-Global sticky dictionary.
it is hard, because it is asynchron programming. Even an experienced programmer will have difiiculties with it. There is so much to think about, such as not running into a racing condition etc.
I’m currently not on a computer with Rhino installed, but as a first step you could read more about asynchron programming in (Iron)Python.
Ok, so if it’s that hard It’s clear that it’s not suitable for users…
Is there any other way to do it? As @Helvetosaur was mentioning above, to have a plugin that will call the scripts.
The plugin itself should be done in asynchronous programming i guess, but the scripts done by users will be done in simple py…
You don’t understand, what you described is asynchron. So it requires asynchron programming… This might be simpler from a non scripting environment, but it still requires advanced coding skills
If i would like to have a panel that constantly tells me how many control points the polyline has. without adding anything to the document.
Is this more easy?
well, you are right as well. Eventhough it is possible, it is something you shouldn’t do on scripting level unless you know what you are doing. So saying no is the better answer. And for those who know about, they simply don’t do these things in a scripting context…
just that listing to events is a nono on a scripting level and it becomes really hacky to unregister properly. If someone is not knowing much about it, this person will very likely run into very odd and hard to debug behaviour.
thinking about something less complicated: you can basicly implement all this in a while loop in python, where you first enter your points outside of the while loop, then create the polyline and offset inside the loop. since you are always refering to guids you should be able to modify the points and thus the polyline.
@rgr yes, I understand your point. but then the only thing i will be able to do is to play with the polyline
(the polyline was just an example to illustrate the problem, what i truly want is to have any other thing running on top. but i do understand that it is complicated)