Jump to content

Automatically Recalculate doesn't work


---
 Share

Recommended Posts

Hello everyone,

I have some templates that are not working properly with a script. The script part is as follows: 

for g in n_stages:
	gom.script.sys.show_stage (stage=gom.app.project.stages[0])
	gom.script.sys.recalculate_all_elements_automatically (enable=True)
	gom.script.sys.copy_to_clipboard (elements=gom.ElementSelection ({'category': ['key', 'elements', 'part', gom.app.project.parts[0], 'explorer_category', 'actual_part']}))
	gom.script.sys.paste_from_clipboard (destination=gom.ElementSelection ({'category': ['key', 'elements', 'part', gom.app.project.parts[0], 'explorer_category', 'actual_part']}))
	gom.script.sys.delete_stage (stages=gom.StageSelection (first=gom.app.project.stages[0], last=gom.app.project.stages[0]))

where n_stages is a range (from 0 to 3 in this case), and when I reach the automatic recalculation, it only works on stage 0 and not on the others. I am attaching an image for reference. This issue only occurs on some templates while it works fine on others. Am I doing something wrong?

Thank you very much for your help!

CopyQ.qludkD.png

Link to comment
Share on other sites

Hi,

hard to answer you question, but may this hint helps you: from a script you have to trigger the commands for 'recalculate_project' or 'recalculate_element'.
The command that you have recorded only sets the interactive automatic recalc button to 'Enabled'. This button is evaluated after each finished interactive command and triggers a special recalculate only on visible elements. If a script runs this button is not evaluated at all.

Hope this helps?!

Regards,

Bernd

Link to comment
Share on other sites

Thanx Bernd,

Indeed, I'm checking that automatic recalculation is enabled, for safety, because it would be enough to enable it before executing the for loop, I agree. However, regardless of this, the command gom.script.sys.show_stage (stage=gom.app.project.stages[0]) should enable automatic recalculation, but this does not happen. I solved it by replacing automatic recalculation with gom.script.sys.recalculate_project (with_reports=False), but obviously this slows down the program. Am I perhaps doing something wrong? I thought of adding an if condition to check whether the displayed stage is calculated or not (true or false), but I couldn't find any command that would work for my case. If I knew which command to use, I could implement it and in this way "slow down" only those templates that do not work properly.

Link to comment
Share on other sites

Your expectation is "wrong". Executing a script means that you trigger all needed commands for the "correct" execution. The Auto-Recalc check is not executed during a script execution. It could be that setting the Auto-Recalc option to 'On' will call a recalc only once  if the the Auto-Recalc option was "No" before but I'm not sure.

Better option: You have to trigger at which timestamps you like to recalculate your project. Recalculate project only recalculates elements which are not calculated yet or only in the stages that are not calculated properly.

 

Link to comment
Share on other sites

The fact is that this recalculation works in some templates and not in others. However, it's not important, what matters is that I manage to fix the problem. I didn't understand your response well: I think the problem is that my script copies stage[0], pastes it into the clipboard, and deletes it, so that stage[1] becomes stage[0]. When deleting a stage, the software needs to recalculate, and in some templates, the command .show_stage[0] is sufficient if automatic recalculation is enabled, while in other templates it's not enough. To anticipate your question: I chose this option because deleting the stage frees up RAM and resolves some crash problems.

Link to comment
Share on other sites

Data/particular project related questions couldn't be answered, you have to contact your local contact person and if you have a professional support contract. The Forum is meant to give you some hints but we can't offer a complete anaylsis of your, e.g. I don't understand why you are working with stage projects, if you want to delete the stages again and again. May be there are other approaches which would work out of the box?

If your RAM is not big enough you have to work with one template (with one hidden stage) and import one mesh with the replace option and recalculate everything, export your reports and/or store your calculated project and repeat this for each mesh.

Link to comment
Share on other sites

 Share

×
×
  • Create New...