BlackStartx / PyCharm-Blender-Plugin

A PyCharm Plugin that simplify the development of Blender Add-On inside the PyCharm IDE.
MIT License
142 stars 13 forks source link

Environment Variables #13

Closed denis-roy closed 11 months ago

denis-roy commented 1 year ago

Good day @BlackStartx

First of all, I just found your plugin and want to say a big heartfelt thank you for it! 💯

Blender can use a number of environment variables and in my current setup, I must use the following two: BLENDER_USER_CONFIG BLENDER_USER_SCRIPTS

I'm wondering if there is a way within your plugin for me to set these up before the instances are started?

For normal Blender launching, I have a batch file that SETs them before executing Blender and while, for a regular Python program, I would normally do it through PyCharm's run configurations, I tried starting Blender with the --python C:\Users\User\AppData\Local\Temp\BlendCharm\pycharm_connector.py -- argument as an external tool in the run config but it didn't work ¯\(ツ)

Another potential way... Could it be even possible to use the standard run configuration settings to set the ENV variable and then to trigger your plugin?

Thanks again :)

BlackStartx commented 1 year ago

Hi Denis~ First of all sorry so much for the delay of the reply, and thanks so much for the words~ ♥

By the way yeah, starting Blender with PyCharm's run configurations only start the client socket (pycharm_connector.py) but doesn't start the server one, thus it's not working~

I will have to implement a way to allow the user to define environment variables, right now you have 0 power of customization over the configuration. (This project started as a personal project for fun, it was not expecting configurable stuff :c)

Meanwhile a possible workarround I'm tinking may be to manually add them to the Windows system variables~

image

This is a LOT dirty, but it will do the trick as long as they are not required to change too much.

On the other end you may change and set them directly in the script on the %LocalAppData%\Temp\BlendCharm path, but keep in mind that the file will be regenerated on PyCharm restart.

I definitely have to do something to make this easier.

Sorry so much for the troubles, I hope the workarround may do the trick meanwhile an easier method will be developed~ ♥

denis-roy commented 1 year ago

sorry for the delay of the reply

No worries at all, I was away for the long Easter weekend and even then, your reply is actually the fastest reply to a GitHub issue I ever had :) ahah

meanwhile ... (usage of) Windows system variables

Unfortunately it is not practical to use Windows' system as I need to set different script variables for the different Blender versions I use and test addon code against

(possibility to) set them directly in the (temporary) script on the %LocalAppData%\Temp\BlendCharm

Oh! Cool, I will have a look and evaluate if I could use that as a workaround, thank you for the tip 👍

Sorry so much for the troubles

No trouble at all, I can live with the actual plugin state and...

this project started as a personal project for fun

... I understand and I'm definitely happy you graciously shared it with the world! I cannot offer code contributions at the moment as I am not familiar with Java but I would definitely offer a donation as it is a real time saver :]

BlackStartx commented 1 year ago

Hi again Denis~

I want to publish a new release soon adding the option to handle environment variables.

But first... Sorry even more for the delay this time :c I'm not good with Swing UI, and this caused some delays.

By the way, the idea is to add them in the Blender configuration window, so you may have different runnable configurations (eventually using the same Blender executable) with different environment variables.

I do think this would do the trick perfectly, do you have any suggestion?

Thanks once again~ 🌸

BlackStartx commented 1 year ago

I've managed to implement a table containing the list (key, value) of the defined enviroment variables.

The only things that still triggers me is that random white aurea around the table:

image

I've tried a lot of stuff (setBorder(null), etc...) but I can't get rid of it .-.

Anyway, at runtime the enviroment variable can be read by:

image

Once I've defeated the white aurea I'll publish a release!

Sorry that this took 3 weeks~ ^-^'

denis-roy commented 1 year ago

Good day @BlackStartx

I did not see those last few weeks fly by me, but I can see you were hard at work! This will be incredibly useful, once again thank you!

💯 / 💯

BlackStartx commented 1 year ago

Hi, small update for why it's taking longer than a day...

I want to implement a collapsable group in my dialog like the one here:

image

It will have the "Optional Settings" label and it will contains all the extra... well, optional settings.

This way new user will not see too many stuff if they just want to setup the Blender Executable~ The problem is that I'm unable to find the JComponent for it and I'm starting to hate Swing even more! :D

Anyway, In the meanwhile I'll publish here the two beta version that support the enviroment variables but have the ugly UI, so if you don't mind and wish to experiment with it you can do it~ :3 ✨

Blend-Charm.2023.1-Beta.Community.Edition.zip Blend-Charm.2023.1-Beta.Professional.Edition.zip

They should be stable, and the data of the enviroments will be kept on the final release as well (unless I REALLY need to change stuff, but probably not)

denis-roy commented 1 year ago

Thank you, that is very cool! I will try to experiment a bit with it during the coming weekend!

denis-roy commented 1 year ago

Did a little testing and it does works wonderfully so far! 🤩

Thank you!