Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Suggestion: render token add support for date and time #51

Closed
Zijian-Wang opened this issue May 30, 2023 · 3 comments
Closed

Feature Suggestion: render token add support for date and time #51

Zijian-Wang opened this issue May 30, 2023 · 3 comments
Labels
question Further information is requested

Comments

@Zijian-Wang
Copy link

Hi,

Thanks for making this plugin.

I tried to add globals like $MM to datetime.datetime.now().month.strftime("%m") but it turned out to be false when being evaluated, so instead of having the current month number, I would get NO-MM in the file name.

I tried to add import datetime in the python file but it doesn't change anything. Could you consider adding support for date time in presets?

I would suggest token naming be following:
"$YYYY": datetime.datetime.now().strftime("%Y"),
"$YY": datetime.datetime.now().strftime("%y"),
"$MM": datetime.datetime.now().strftime("%m"),
"$DD": datetime.datetime.now().strftime("%d"),
"$hh": datetime.datetime.now().strftime("%H"),
"$mm": datetime.datetime.now().strftime("%M"),
"$ss": datetime.datetime.now().strftime("%S"),

@p2or
Copy link
Owner

p2or commented May 30, 2023

Hi @Zijian-Wang,

you just forgot to import the datetime module in the first place, see the provided $TIME expression for reference. In this case you can use e.g. time or datetime modules:

  • $YYYY: exec("import time") or time.strftime("%Y")
  • $YYYY: exec("from datetime import datetime") or datetime.now().strftime('%Y')
  • $MM: exec("import time") or time.strftime("%m")
  • $MM: exec("from datetime import datetime") or datetime.now().strftime('%m')
  • ...
Screenshot 2023-05-30 at 18 59 46

Both expressions resolve to 2023 and 05 as expected and the actual logic should work for all your other requirements as well. Does this help?

Cheers,
Christian

@p2or p2or added the question Further information is requested label May 30, 2023
@Zijian-Wang
Copy link
Author

Tried it, and it worked as I expected. I'm pretty new to both python and blender and thank you so much for this detailed answer! Have a great week! 🥇 😄

@p2or
Copy link
Owner

p2or commented May 31, 2023

You're welcome, glad I could help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants