Hi everyone,
First of all, I am using Rhino5(64-bit) on Windows 7.
To give some background on the problem I am having, I have rewritten a VBScript using Python for Rhino (personal preferences, I would like to stick to python for the ‘simple’ scripts I am doing), which allows the user to select surfaces, which are then exported in a .csv file where we can find (SurfaceName, SurfaceID, SurfaceLayerName, SurfaceArea, SurfaceAreaCentroid[X], SurfaceAreaCentroid[Y], SurfaceAreaCentroid[Z], SurfaceNormalVector[X], SurfaceNormalVector[Y], SurfaceNormalVector[Z]), each line corresponding to one of the surfaces exported.
Now, my issue is that when I run both codes, which are very similar and rely on the exact same rhino commands, on a rhino model of a stadium (which is split in 1500 small surfaces), the VBScript takes 1min30 while the PythonScript takes 5min to produce the same result.
I did many versions of the python code where I have been optimising string concatenation and writing operations, but in the end it was not very relevant because when I study the time taken by the commands in the for loop, it appears that the bottleneck is when I extract the Area and the AreaCentroid of the surface (each taking around 2min30, so both together are nearly 100% of execution time). But both the VBScrip and the Python script use the methods SurfaceArea() and SurfaceAreaCentroid().
for strSurfaceID in arrSurfaceIDs:
(...some other code here...)
arrSurfaceArea = rs.SurfaceArea(strSurfaceID)
arrSurfaceCentroid = rs.SurfaceAreaCentroid(strSurfaceID)
(...some other code here...)
So, in conclusion, I’m wondering why those exact same commands are executed faster by VB than Python.
Many thanks for your attention, I look forward to discuss this.
Regards,
Damien