Get Attached Document Path from Worksession in Rhino5 c# API

Hi

@dale @pascal Is it possible to get attached document file paths in Rhino 5 using C# API?

-@Sarath

Hi @Sarath_Kithiyon,

You can attached documents by scripting the Worksession command using RhinoApp.RunScript.

– Dale

Hi Dale, I have the same issue. I’m trying to find the attached document paths from an existing Worksession.

Hi @dale

The script is not working for the following scenario,
1.Open new template
2. Attach another 3dm file
3. Save the active model and worksession
4. Then run script

Sub GetAttachedDocPath()

	Dim fileName	
	fileName = Rhino.WorkSessionFileName
	If IsNull(fileName) Then
		Rhino.Print "WorkSession Not Saved"	
		Exit Sub
	End If
	Rhino.Print fileName
    
	Dim arrModelPaths, strPath	
	arrModelPaths = Rhino.WorkSessionModelNames	
	If IsNull(arrModelPaths) Then
		Rhino.Print "No Attchment"
		Exit Sub
	End If		
	
	For Each strPath In arrModelPaths		
		Rhino.Print strPath
	Next
End Sub

Hi @Sarath_Kithiyon,

Following your instructions, the script works as expected. What am I missing?

– Dale

Hi, @dale,

After step 4,

  1. Again open a new template and attach another 3dm file.
  2. Save work session and model.
  3. Then run the script.

It always returns "WorkSession Not Saved"

Note: Once close the model and open again it works.

Hi @Sarath_Kithiyon,

Sorry, I can still not repeat what you are report. I am using Rhino 6, by the way. Have you tested with this version? Otherwise, I’ll need some files and perhaps a video.

That said, even if this doesn’t work correctly in Rhino 5, it won’t be fixed…

– Dale