Hello,
I'm programming a macro that creates meshes among other things. But it can take a lot of time to get a mesh with a high resolution so I got the idea to create a mesh, write it temoprary down to the temporary folder and if you restart the macro, it looks for the time of last modification on an object and if it isn't modified since the last start of the macro, the macro can use the mesh from the temporary folder.
With search in the python console and Google I found nothing in this direction.
Is there any solution or is that not intended?
regards
usbhub
How to get last time of modification of object?
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Be nice to others! Respect the FreeCAD code of conduct!
-
- Posts: 656
- Joined: Tue May 19, 2015 1:11 am
Re: How to get last time of modification of object?
os.path has a method for checking modification time.
Is that what you’re looking for?
Writing to and reading from the hard drive is incredibly “slow” : are you sure this will save any time?
How long does the mesh operation take?
What do you mean by “restart the macro”? Can the user arbitrarily make changes and re-trigger the mesh operation? If so, how will a cache help?
Is that what you’re looking for?
Writing to and reading from the hard drive is incredibly “slow” : are you sure this will save any time?
How long does the mesh operation take?
What do you mean by “restart the macro”? Can the user arbitrarily make changes and re-trigger the mesh operation? If so, how will a cache help?
Re: How to get last time of modification of object?
No, I think, there's a misapprehension. I dont't want to check the time of the file, I want to check the time of the object in FreeCAD (e.g a cube).ezzieyguywuf wrote: ↑Sun Dec 01, 2019 1:35 am os.path has a method for checking modification time.
Is that what you’re looking for?
Yes, this will save a lot of time, I think. The mesh operation can take about 10 minutes for complex object with a lot of roundings. My macro is for rendering, so it needs a pretty high resolution.Writing to and reading from the hard drive is incredibly “slow” : are you sure this will save any time?
How long does the mesh operation take?
Yes, the user can restart the macro if he want to do another rendering. But often only one little object is changed and every object, the unchanged objects too, have to be "remeshed".What do you mean by “restart the macro”? Can the user arbitrarily make changes and re-trigger the mesh operation? If so, how will a cache help?
-
- Posts: 656
- Joined: Tue May 19, 2015 1:11 am
Re: How to get last time of modification of object?
If this is the case, I don't think necessarily checking "time" is what you want here. For example, consider the following pseudocode:
Code: Select all
toMesh = getAllObjectsInCurrentDocument()
myMeshInfo = {}
for item in toMesh:
processItem = True
if item.name in myMeshInfo.keys():
oldObj = myMeshInf[item.name]
if oldObj == item:
processItem = False
if processItem:
processNewItemInRenderFunction(item)
myMeshInfo[item.name] = item
Granted, this approach will double the amount of RAM needed for a given model, but it may be worth it for the improved cycle time of the render operation?
Re: How to get last time of modification of object?
The higher RAM need is not a problem I think. But I don't understand your pseudo code.ezzieyguywuf wrote: ↑Tue Dec 03, 2019 8:21 pmIn other words, any time you go to do your "mesh" stuff, store a copy of each item that you are meshing. Now, whenever you go to re-mesh, you can first check if the item has actually changed or not.Code: Select all
toMesh = getAllObjectsInCurrentDocument() myMeshInfo = {} for item in toMesh: processItem = True if item.name in myMeshInfo.keys(): oldObj = myMeshInf[item.name] if oldObj == item: processItem = False if processItem: processNewItemInRenderFunction(item) myMeshInfo[item.name] = item
Granted, this approach will double the amount of RAM needed for a given model, but it may be worth it for the improved cycle time of the render operation?
But I find another option, I think:
A shape has the method isEqual() and I think, I can use this for check for equality.
But thank you very much!!!
Re: How to get last time of modification of object?
Could you share your solution in that case?
Alone you go faster. Together we go farther
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
Re: How to get last time of modification of object?
I will, but actually I have not so much time for implementing this feature. But when it is finished, I will share my solution.