You can use the modeler.script.session().getDefaultDirectory()
method to retrieve the default directory set in SPSS Modeler. Here's an example:
import modeler.api
default_directory = modeler.script.session().getDefaultDirectory()
print(f"Default Directory: {default_directory}")
This method returns the default directory as a string. It corresponds to the value set in the "Local Mode Set Default Directory" configuration in the SPSS Modeler application.
------------------------------
Youssef Sbai Idrissi
Software Engineer
------------------------------
Original Message:
Sent: Tue January 17, 2023 11:01 AM
From: Johan Peralta
Subject: Is the Local Mode set Default Directory exposed to the Python Modeler API
Hi Kadawa-san, thanks for your useful and informative response!
The SPSS Modeler client is parsing the session.prefs file, as it knows what the set Default Directory is.
I am wondering if the Default Directory value is available via a variable set by SPSS Modeler?
------------------------------
Johan Peralta
Original Message:
Sent: Fri January 13, 2023 04:38 AM
From: HAJIME KAWADA
Subject: Is the Local Mode set Default Directory exposed to the Python Modeler API
Hi,
I cannot find the Modeler API, either.
I change "Default Directory" before launching Modeler
1. session.prefs
DefaultWorkingDirectories=C\:\\Users\\dsuser01\\Documents
2. -directory parameter
start "" %MODELERPATH% -directory "%DEFDIR%"
I wrote something about this on the following article.(Sorry it is in Japanese)
https://qiita.com/kawada2017/items/3b3ef5d5e476159163ee
------------------------------
HAJIME KAWADA
Original Message:
Sent: Thu January 12, 2023 12:22 PM
From: Johan Peralta
Subject: Is the Local Mode set Default Directory exposed to the Python Modeler API
Hi, I found an example of how to the obtain the Server Directory:import modeler.apistream = modeler.script.stream()sourceNode = stream.findByID('')session = modeler.script.session()fileSystem = session.getServerFileSystem()parameter = stream.getParameterValue('VPATH')serverDirectory = fileSystem.getServerFile(parameter)files = fileSystem.getFiles(serverDirectory)for f in files:if f.isDirectory():print 'Directory:'
But have not been able to find a sample on how to the get the Set Directory on the client side.
Is the Local Mode set Default Directory exposed to the Python Modeler API?
Thanks.
------------------------------
Johan Peralta
------------------------------
#SPSSModeler