What are you trying to do lzwang26? The OpenStudio Application does copy all the measures in your current model to a temporary directory when it is running the model. Any files in your measure's resources directory would also be copied into the resources directory in the temporary directory. You can also write output files from your measure to the generated_files directory, these will be copied back to the original directory after the run. Basically, you should not need to know the absolute path of the original measure, you should be able to do what you want to do with relative paths in the temporary directory.
Here are some code snippets that might be useful in your measure:
# get the current workflow being run
workflow = runner.workflow
# get the current workflow step being run
currentStep = workflow.currentStep.get
runner.registerInfo("currentStep = #{currentStep}")
# convert the current workflow to a measure step
currentMeasureStep = currentStep.to_MeasureStep.get
# can use the findMeasure method to find a measure by measure dir name
currentMeasurePath = workflow.findMeasure(currentMeasureStep.measureDirName).get
runner.registerInfo("currentMeasurePath = #{currentMeasurePath}")
# get the relative file paths searched for files in the current workflow
filePaths = workflow.filePaths
runner.registerInfo("filePaths = #{filePaths.join(', ')}")
# the first entry in the path is for generated output files the measure would write
File.open(File.join(filePaths[0].to_s, "output1.txt"), 'w') do |f|
f.puts "Output 1"
end
# get the absolute file paths searched for files in the current workflow
absoluteFilePaths = workflow.absoluteFilePaths
runner.registerInfo("absoluteFilePaths = #{absoluteFilePaths.join(', ')}")
# the first entry in the path is for generated output files the measure would write
File.open(File.join(absoluteFilePaths[0].to_s, "output2.txt"), 'w') do |f|
f.puts "Output 2"
end
# directory with the input osw file
oswDir = workflow.oswDir
runner.registerInfo("oswDir = #{oswDir}")
# relative directory with the osw file
rootDir = workflow.rootDir
runner.registerInfo("rootDir = #{rootDir}")
# absolute directory with the osw file
absoluteRootDir = workflow.absoluteRootDir
runner.registerInfo("absoluteRootDir = #{absoluteRootDir}")
# relative directory to the run directory
runDir = workflow.runDir
runner.registerInfo("runDir = #{runDir}")
# absolute directory to the run directory
absoluteRunDir = workflow.absoluteRunDir
runner.registerInfo("absoluteRunDir = #{absoluteRunDir}")
# relative path to the output osw file
outPath = workflow.outPath
runner.registerInfo("outPath = #{outPath}")
# absolute path to the output osw file
absoluteOutPath = workflow.absoluteOutPath
runner.registerInfo("absoluteOutPath = #{absoluteOutPath}")
# relative paths containing measures
measurePaths = workflow.measurePaths
runner.registerInfo("measurePaths = #{measurePaths.join(', ')}")