### Script slowly adds "Geometry" objects

Posted:

**Tue Jul 21, 2020 6:09 am**Hello, please help me. the script slowly adds "Geometry" objects.

the first dozens of objects are added quickly, then the addition is very slow.

how do I speed this up?

x=0

y=0

z=20

numOfElementsByX=27

numOfElementsByY=15

countByX=0

countByY=0

distByX=0.3

distByY=0.3

distByZ=0.3

for i in range(1,30000):

newSphere = scene.addSphere(0)

newSphere.setParameter("Scale", Vector.new(0.3,0.3,0.3))

newSphere.setParameter("Dynamics", "Active rigid body")

newSphere.setParameter("Mass", 0.001)

newSphere.setParameter("Elasticity", 0.0)

newSphere.setParameter("Color", Vector.new(255,255,255))

newSphere.setParameter("Collision geometry", "Sphere")

newSphere.setParameter("Object friction", 0.2)

newSphere.setParameter("Position", Vector.new(x+countByX*distByX,y+countByY*distByY,z))

countByX+=1

Group01.add(newSphere.name)

if (countByX == numOfElementsByX):

countByX=0

countByY+=1

if (countByY == numOfElementsByY):

countByX=0

countByY=0

z+=distByZ

Win 7 x64 i3, 16 Gb, HDD, RF10

the first dozens of objects are added quickly, then the addition is very slow.

how do I speed this up?

x=0

y=0

z=20

numOfElementsByX=27

numOfElementsByY=15

countByX=0

countByY=0

distByX=0.3

distByY=0.3

distByZ=0.3

for i in range(1,30000):

newSphere = scene.addSphere(0)

newSphere.setParameter("Scale", Vector.new(0.3,0.3,0.3))

newSphere.setParameter("Dynamics", "Active rigid body")

newSphere.setParameter("Mass", 0.001)

newSphere.setParameter("Elasticity", 0.0)

newSphere.setParameter("Color", Vector.new(255,255,255))

newSphere.setParameter("Collision geometry", "Sphere")

newSphere.setParameter("Object friction", 0.2)

newSphere.setParameter("Position", Vector.new(x+countByX*distByX,y+countByY*distByY,z))

countByX+=1

Group01.add(newSphere.name)

if (countByX == numOfElementsByX):

countByX=0

countByY+=1

if (countByY == numOfElementsByY):

countByX=0

countByY=0

z+=distByZ

Win 7 x64 i3, 16 Gb, HDD, RF10