I’m here with another DLA related question, I am trying to now generate a DLAsystem using ghPython, previously I learned how to do it in 2d and now im trying to create it in 3d, I followed an example and have gotten to this far, but I could not figure out what is the problem now. for example, when the Run is set to Ture, I get the error message that states " ExpireSolution() takes exactly 2 arguments(1 given)", why is that? isn’t it only take one bool argument?
This code snippet is not needed when iterating the GHPython component with a timer, since it basically does the same:
if iRun:
gk.IGH_DocumentObject.ExpireSolution(True)
It also needs to be used in a callback function together with other stuff.
Other than that there were lots of variable name misspellings and forgotten self.s. You need to pay attention to this!
It seems to work now, however you need to optimize your code to make it run faster. It’s rather slow at the moment.
You do lots of distance calculations, which by nature are slow because square root calculations are involved. If possible, I’d only look up the squared distance and compare it to a squared reference value.
For closest point searching, you should also implement some sort of faster and more efficient algorithm than looking up all distances every time. You can use space partioning algorithms (i.e. octree, rtree). Both are available in RhinoCommon, I believe.
The performance gain will be immense.
For classes that are only containers of utility functions, you can declare their methods as static. This means that you don’t have to instantiate a class object only to call one of its methods, but you can call the method right away. I’ve already changed this!
It’s also debatable, whether it is necessary to make a Particle class to merely store a point and a vector. You could for instance use a dictionary instead, where vectors are mapped to points or vis versa.