Hi, I’m trying to optimize some code i’m working with. One thing i see is that RhinoObject.CommitChanges() takes a lot of time and calling it multiple times for multi objects result in a bottleneck. Is there any way to call it one single time for a list of objects?
How many objects are you changing? Can you provide some sample code, that we can run here, that you think is slow?
Sorry for the late replay. I was preparing the example code to give it to you and I found that commit changes in the end doesnt take all that time, once i was only doing a foreach with commit changes. So I’m investigating a bit more. I’ll update you once i found out more about the issue.
I was able to execute the same code (it’s only a foreach with transform + commit changes) from a script outside of the spaghetti code… it runs fast enough. So i delegated the execution of the code to a rhino script. I guess the issue is that I’m running that code from a different thread or something. So i tried to use RhinoApp.MainApplicationWindow.Invoke (now deprecated but i dont see alternatives) to make it run from the main thread but still it’s slow. I guess I’ll just keep the script.
just in case someone jumps here for RhinoApp.MainApplicationWindow.Invoke
It is now deprecated and should be used RhinoApp.InvokeOnUiThread now