I want to automate editing a json config file?
-
Hello, I wonder if you can help me?
I run a windows program that uses .json configuration files.I have used Notepad++ for years to edit Minecraft configs so I find it easy enough to do.
However, the program goes through regular updates, meaning that I have to find and edit the 1 line in a config every time to change a default setting.Some background info:
I run Bambu Studio as 3D modelling program, it has a default setting for the infill (the stuff inside the model that keeps it solid (ish) that is set to “grid”, this has several problems in that it can cause the print head to repeatedly knock onto already placed filament and either knock the model over or the head cover off.
To prevent this the rest of the 3D community tends to change this setting to “Gyroid” as this does not cross the same path with the filament head.The setting in the file C:\Users\Matt\AppData\Roaming\BambuStudio\system\BBL\process\fdm_process_common.json
is:
“sparse_infill_pattern”: “grid”,
And I manually change it to:
“sparse_infill_pattern”: “gyroid”,I know it’s only 1 line but I’d like to do some form of automation on this (and hopefully maybe later some other settings).
I was thinking maybe Notepad++ could run a script/plugin to do this?Any ideas please?
Thank you. -
It depends on how automatic you want it.
If you are willing to open Notepad++, open the file, and run a macro to do a replacement, that can be done with native Notepad++ (see below).
If you want to have notepad++ already open, but have it automatically open the file, you cannot do that in a macro; however, you could install a scripting plugin like PythonScript, and do something that automatically opens the file, runs the replacement, saves, and closes the file again.
If you choose to go the macro route, you can setup the Macro using the following sequence:
- Macro > Record Macro
- Search > Replace
FIND WHAT ="sparse_infill_pattern": "gyroid"
REPLACE WITH ="sparse_infill_pattern": "gyroid"
SEARCH MODE = Normal
REPLACE ALL - File > Save
- Macro > Stop Recording
- Macro > Save current recorded macro
- Give it a name, like
BambuGyroid
- Optionally, give it a keystroke that you can remember
- OK
- Give it a name, like
From now on, using Macro >
BambuGyroid
(or the keystroke you chose) will run that specific replacement and save.