Skip to content

Commit d7cec16

Browse files
authored
add optional reload parameter
1 parent b9f410a commit d7cec16

2 files changed

Lines changed: 11 additions & 3 deletions

File tree

  • extensions/pyRevitTools.extension/pyRevit.tab/Project.panel/ptools.stack/Links.pulldown/Create Workset For Linked Element.pushbutton
  • pyrevitlib/pyrevit

extensions/pyRevitTools.extension/pyRevit.tab/Project.panel/ptools.stack/Links.pulldown/Create Workset For Linked Element.pushbutton/ws4links_config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,5 +76,5 @@ def name(self):
7676
)
7777
my_config.set_option("custom_prefix_dwg_value", custom_prefix_value)
7878

79-
script.save_config()
79+
script.save_config(reload=True)
8080
main()

pyrevitlib/pyrevit/script.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,12 +158,13 @@ def get_output():
158158
return output.get_output()
159159

160160

161-
def get_config(section=None):
161+
def get_config(section=None, reload=False):
162162
"""Create and return config section parser object for current script.
163163
164164
Args:
165165
section (str, optional): config section name. If not provided,
166166
it will default to the command name plus the 'config' suffix.
167+
reload (bool, optional): forces a reload, in case changes where made.
167168
168169
Returns:
169170
(pyrevit.coreutils.configparser.PyRevitConfigSectionParser):
@@ -173,21 +174,28 @@ def get_config(section=None):
173174
if not section:
174175
script_cfg_postfix = '_config'
175176
section = EXEC_PARAMS.command_name + script_cfg_postfix
177+
if reload:
178+
user_config.reload()
176179

177180
try:
178181
return user_config.get_section(section)
179182
except AttributeError:
180183
return user_config.add_section(section)
181184

182185

183-
def save_config():
186+
def save_config(reload=False):
184187
"""Save pyRevit config.
185188
186189
Scripts should call this to save any changes they have done to their
187190
config section object received from script.get_config() method.
191+
192+
Args:
193+
reload (bool, optional): forces a reload, in case a script uses newly set config.
188194
"""
189195
from pyrevit.userconfig import user_config
190196
user_config.save_changes()
197+
if reload:
198+
user_config.reload()
191199

192200

193201
def reset_config(section=None):

0 commit comments

Comments
 (0)