first thing one notices is that once any animation includes shapestrings the speed drops a factor 10-100, it is impossible not to notice the drop in speed, and it does not feel proportional to the expected needed computations.
another thing has been that it seemingly randomly bugs out with occ-errors on not creating face
have struggled with this quite a bit, with up until now just lived with it
the only real workaround so far has been to just run it an pray that one do not really notice it in the animation, which happened from time to time, but more often than not the errors just added up to a completely useless animation, as when the rendered string is just complete garbage of non-ascii chars
never really could wrap my head around the errors,
for one gui-updates were troublesome, especially with delays included,
this is regardless that the code is littered with .recompute and .updateGui in desperate attempts to circumvent untimely updates.
that kind of hinted to event que not being flushed, so started to litter the code with
QCoreApplication.processEvents as well, subjectively this seemed to help a bit, but not fixing it.
installed a different version (from 0.20.0 libpack win to 0.20.2 conda win // libpack - the .zip would not unzip...),
and voila, errors where gone , for a while before they one again appeared
noticed that the stream of errors looked a bit different,
some error types appeared to not be there any more, the error left was
Code: Select all
/Mod/Draft/draftobjects/shapestring.py, line 67, in execute
CharList = Part.makeWireString(obj.String,obj.FontFile,obj.Size,obj.Tracking)
<class 'Part.OCCError'>: Font file not found ../tmp/FCT1C08.tmp
why would it look for a font-file with file-ending .tmp,
especially when the object property has a full path to a real (existing and reachable) .ttf file?
yepp, the font-path is in object, which one would assume avoids any heuristics in finding fonts, while error speaks differently
briefly glanced at the shapestring py code, but could not spot any passages that creates cache-files,
so suppose some c voodoo is needed either in fc-part or occt somewhere
or the cache writing is qt or os driven, that would be a curved ball...
to me it is a mystery where this cache is created...
to complete the story,
the cache-location had accumulated some 40 Gb of duplicated font files
font file is 1.6Mb, so there were close to 30k copies there
that seems a bit unnecessary to do...
if it would not have been for size and timestamp of tmp-file,
probably never would have made the connection that it was copied font files.
yepp, have been running the animation a couple of times, but not 30k times,
one run is maybe 3k steps, but i have for sure ran it more than 10 times,
i.e. nothing obvious sticking out why it would 30k cache copies
as one can see it is also in the root of a temp-folder,
would be nicer if it was in a folder identifying it as a fc-cache...
if a shapestring creation/edit randomly results in a copy of font-file to disk,
that can be a suspect to why animation speed drops, or it drives speed variations
anyhow, for now have hard-coded the font-path in shapestring.py
and it appears to get rid of the errors, while at the same time making it slower...
in the last error free run, it did not put massive amounts of copies in the tmp-location, only one.
clearly this is an illusive story, but the font-copies were real,
could of course have been written by another application, but it is a bit too much of a coincidence imho
so somewhere there is a cache writing triggered under some conditions,
that it is looking in the cache instead of provided path ought to be some peculiar logic somewhere...
an attempt to mvp that may or may not trigger the issue,
it sums up the operations done though.
have not been able to get the errors with this code (yet?),
at least it gives an idea of the slowdown in speed.
maybe one stumbles into an error with longer looping
or the whole thing is a mind ghost and never happened...
since most work happens in c, unclear (to me) why code below hogs down the computer to the extent it does...
Code: Select all
from string import ascii_uppercase
from random import choices
import Draft
def center(doc, obj):
doc.recompute()
bb = obj.Shape.BoundBox
obj.Placement.Base.x = - bb.XLength / 2
doc.recompute()
Gui.updateGui()
## '' works on some boxes, others not, probably pref-settings...
## full path will always work, one supposes
font = ''
doc = App.newDocument('stringtest')
obj = Draft.makeShapeString('abc' * 6, font)
center(doc, obj)
obji = Draft.makeShapeString('1', font)
doc.recompute()
obji.Placement.Base.y = obj.Size * 4
center(doc, obji)
Gui.Selection.clearSelection()
Gui.ActiveDocument.ActiveView.fitAll()
for c in ascii_uppercase * 2:
obji.String = f'{ord(c) - 64}'
center(doc, obji)
obj.String = ''.join(choices(ascii_uppercase, k=15))
center(doc, obj)