Syncrosim › Forums › SyncroSim – General Questions and Answers › Working with SyncroSim folders using the rsyncrosim package
Tagged: Folders, rsyncrosim
- This topic has 0 replies, 1 voice, and was last updated 1 year, 2 months ago by
Leonardo Frid.
-
AuthorPosts
-
December 30, 2021 at 9:38 pm #20794
Leonardo Frid
KeymasterA user recently asked about creating and managing SyncroSim library folders using the rsyncrosim package for R. Currently there are no functions for doing this with the rsyncrosim package. However, it is possible to do this via command line calls. The following shows a simple example that creates a folder in a library and places a scenario within that folder:
#Load R libraries
library(rsyncrosim)# Connect to a SyncroSim Library -----------------------------------------------
# Load session
mySession <- session()# Load ST-Sim non-spatial example Library
myLibrary <- ssimLibrary(name = "folderDemo.ssim",
session = mySession,
package = "stsim",
template = "non-spatial-example")# View current Scenarios in the Library
scenarioDataframe <- scenario(myLibrary)
scenarioDataframe#Make a console call to create a new example folder----------------------------
# Find the Parent Project ID to create a folder within this Project
pid <- scenarioDataframe$projectId[1]# Write the console command
command <- paste0("\"", filepath(mySession), "/SyncroSim.Console.Exe\"",
" --create --folder --lib=", filepath(myLibrary),
" --name=example --tpid=", pid)# View the console command
print(command)# Invoke a system command
sysOut <- system(command, intern=TRUE)
print(sysOut)# Grab the folder ID as a variable
folderId <- strsplit(sysOut, ": ")[[1]][2]
print(folderId)# Make a console call to move a Scenario to the folder--------------------------
# Pick the first Scenario in the Library to move
sid <- scenarioDataframe$scenarioId[1]# Write the console command; tfid is the folder ID flag
command <- paste0("\"", filepath(mySession), "/SyncroSim.Console.Exe\"",
" --move --scenario --lib=", filepath(myLibrary), " --sid=",
sid, " --tfid=", folderId, " --tpid=", pid)# View the console command
print(command)# Invoke a system command
sysOut <- system(command, intern=TRUE)# If you open folderDemo.ssim in the SyncroSim UI, there should now be an
# "example" folder within the Definitions Project, containing the first scenario
-
AuthorPosts
- You must be logged in to reply to this topic.