Hi, all!
My task create FreeCAD document containing about 500000-1000000 simple objects (2D rectangles, 2D circles, polylines)
I wrote simple test script to insert rectangles to FreeCAD document.
When I try insert about 10000 rectangles, i get wery low performance. It takes wery long time to complete.
for x in range(0,10000):
print("creating element no: %d"%(x))
pl = FreeCAD.Placement()
pl.Base = FreeCAD.Vector(x*10,0,0)
rec = Draft.makeRectangle(length=5,height=2,placement=pl,face=False,support=None)
#wery slow for loop
##save document fast
FreeCAD.getDocument("Unnamed").saveAs("test_freecad.fcstd")
There is possibility to write faster code?
** I try to do this way
AAD = FreeCAD.ActiveDocument
for x in range(0,10000):
c = Part.makeCircle(5)
c.Placement.Base = FreeCAD.Vector(x*10,0,0)
shapeobj = AAD.addObject("Part::Feature","circle"+str(x))
shapeobj.Shape = c
**
This code work much faster, but all objects has Visibility = False
and shapeobj.ViewObject.Visibility = True raise Exception because shapeobj.ViewObject seems Null
Second question:
When i open document with 10000 rectangles, FreeCAD frozen for along time (about 1 minute on my laptop with Core i7 and 32GB ram). So question - it is not possible to view document with 1000000 simple objects?
Regards, Sergey.
FreeCAD slow performance on create many objects
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Be nice to others! Respect the FreeCAD code of conduct!
Re: FreeCAD slow performance on create many objects
It is definitly impossible if if you create a document object for every object. Just imaging 1 million objects in your tree, what shall be the purpose of that?
What should work is to add all those geometries into one shape. My machine, 6 year old notebook, manages 250000, so a new machine should be able to do a million:
What should work is to add all those geometries into one shape. My machine, 6 year old notebook, manages 250000, so a new machine should be able to do a million:
Code: Select all
shapes = [];
for x in range(0,500):
for y in range(0,500):
c = Part.makeCircle(5)
c.Placement.Base = FreeCAD.Vector(x*10,y*10,0)
shapes.append(c)
p = Part.makeCompound(shapes)
Part.show(p)
Re: FreeCAD slow performance on create many objects
oh, and make sure your default deviation setting is not too small (mine is 0.5) as this would kill your visualization speed easily
Re: FreeCAD slow performance on create many objects
Indeed this is a main limitation of FreeCAD. You must manage the number of document objects. Unlike apps like AutoCAD, here each object is a powerful and complex entity, and therefore their max number is not infinite.
Re: FreeCAD slow performance on create many objects
Hi, all!
Thank You for reply.
This way with one Document Object is working. Now I can view about 500 000 -700 000 circles in one shape without problem. On a 1000 0000 circles i have some periodical freezes on 20 sec but can view document.
I run script directly as python script on a server and object document has property Visibility = False
Can set it to True?
FreeCADGui.getDocument("Untitled").getObject("Shape").Visibility = True - not working in a script.
Thank You for reply.
This way with one Document Object is working. Now I can view about 500 000 -700 000 circles in one shape without problem. On a 1000 0000 circles i have some periodical freezes on 20 sec but can view document.
I run script directly as python script on a server and object document has property Visibility = False
Can set it to True?
FreeCADGui.getDocument("Untitled").getObject("Shape").Visibility = True - not working in a script.