Worksessions - Relative paths

G’day Everyone,

Is there a way to use relative paths for worksessions?

Caveat, I may be being dense, but can’t see it at hand.


@mary, can you chime in here?

Found this but it doesn’t help me in this case because the original files are still present.

Short version of the saga is that I copied a directory from the server to my machine and started working locally on a worksession. Because the server was still accessible the worksession could still access the individual files on the server. It didn’t need to find the files by any other method. So the files I thought I was working on were old and when I copied back to the server they over-wrote the “unknowningly” modified files. Luckily it wasn’t a massive amount of work.

So, if I’m reading the above link correctly, there is no way to override that file finding process and just use a worksession files relative path?

Hi Nick,
Great job locating the document on file finding.
Thanks for starting this discussion.

Rhino 5 works hard to do the work on finding files.
So to make it look for the new files on the local drive do the following.

  1. Detach from the network drive or rename it.
  2. Copy the parent file (the one doing the linking) or the RWS (WorkSession) file into the local
    folder that contains the referenced files.
  3. Open the DWG or RWS file in Rhino. When Rhino can not find the network
    drive, it will look in the current folder and automatically attach the files from the local
  4. Save the file.
  5. Move it parent file or RWS back to the original location.

On the wish list for Rhino 6 is the option to modify locations of multiple file at one time. Right now you can go in to BlockManager, pick on your block and select Properties in Block Manager. There you can browser to another location. Worksession does not allow you to edit the path, just Detach and Reattach.

It would be very helpful multiple files to relocation a selection of blocks to another drive or folder for both block and Worksession attachments. If we had this, you could open the file. Start BlockManager or the Worksession command, select all the files that you wanted to remap to a new folder, and browse to the local drive.
Would this have worked for you? Or what do you suggest?

Kind regards,
Mary Fugier


G’day Mary,

Thanks for the response. I feel like a bit of a dill though. It is so easy to rebuild a worksession file from scratch that I am embarrassed to have even asked the question. In my defence I rarely use worksessions. Am I correct in assuming that even the layer states will come back correctly because the worksession file does not store layer states?


It’s a good question. we use workseeion almost everyday in our team.
For now it seems no way to get worksession’s files path,even use code.
So I write a rhp plug in, to get the path when we attach the file, and store it into the main model.
thus, I can read the path by select a ref object.
Write code

    If e.CommandEnglishName = "Worksession" Then
                If e.CommandResult = Result.Success Then
                    Dim comlinestrs As String = RhinoApp.CommandHistoryWindowText
                    Dim regstr As String = "\s([^\s]+\.(3dm|dwg))\s"
                    Dim arrcomline As List(Of String) = Regex.Split(comlinestrs, "\n").ToList

                    For i As Integer = arrcomline.Count - 1 To 0 Step -1
                        If Regex.IsMatch(arrcomline(i), regstr) Then
                            Dim ma As Match = Regex.Match(arrcomline(i), regstr)
                            If ma.Groups.Count < 1 Then Continue For
                            Dim pathstr As String = ma.Groups(1).Value
                            Dim doc As RhinoDoc = RhinoDoc.ActiveDoc, Keystr As String = "RWSPaths"
                            Dim Mlistpath As String = doc.Strings.GetValue(Keystr)
                            Dim listps As List(Of String) = Mlistpath.Split(CChar("|")).ToList
                            If Not listps.Contains(pathstr) Then
                                If Mlistpath = "" Then
                                    Mlistpath = pathstr
                                    Mlistpath = Mlistpath & "|" & pathstr
                                End If
                                doc.Strings.SetString(Keystr, Mlistpath)
                            End If
                            Exit For
                        End If
                End If
            ElseIf e.CommandEnglishName = "WorksessionSetActiveModel" Then '设置启动模型的时候传递
                Dim listps As List(Of String) = tansRwsFiles.Split(CChar("|")).ToList

                Dim doc As RhinoDoc = RhinoDoc.ActiveDoc
                Dim Keystr As String = "RWSPaths"
                Dim Mlistpath As String = doc.Strings.GetValue(Keystr)
                Dim listps1 As List(Of String) = Mlistpath.Split(CChar("|")).ToList

                For Each pathstr As String In listps
                    If Not listps1.Contains(pathstr) Then
                        If Mlistpath = "" Then
                            Mlistpath = pathstr
                            Mlistpath = Mlistpath & "|" & pathstr
                        End If
                    End If
                doc.Strings.SetString(Keystr, Mlistpath)
            End If

Read code:

      Dim rwsstrs As String = RhinoDoc.ActiveDoc.Strings.GetValue("RWSPaths")
            If rwsstrs = "" Then Return Result.Failure
            Dim listrwspath As List(Of String) = rwsstrs.Split(CChar("|")).ToList
            If listrwspath.Count = 0 Then Return Result.Failure
            Dim Mobjref As Rhino.DocObjects.ObjRef = go.Object(0)

            Dim Mobj As Rhino.DocObjects.RhinoObject = Mobjref.[Object]()
            If Mobj Is Nothing Then
                Return Result.Failure
            ElseIf Not Mobj.IsReference Then '如果是非引用物件
                Dim pathss As String = RhinoDoc.ActiveDoc.Path
                RhinoApp.WriteLine("Select objects Layer are {0} have been Send to Clibboard", pathss)
                If Not opbl.CurrentValue Then
                End If
                Return Result.Success
            End If
            Dim lindex As Integer = Mobj.Attributes.LayerIndex
            Dim mylayer As Layer = RhinoDoc.ActiveDoc.Layers(lindex)
            ' sbtext.AppendLine(mylayer.FullPath)
            Dim fupath As String = Regex.Split(mylayer.FullPath, "::").First
            '  Dim mytest As String = sbtext.ToString
            For Each pstr As String In listrwspath
                Dim pstrs As List(Of String) = pstr.Split(CChar("\")).ToList
                If pstrs.Last = fupath Then

                    RhinoApp.WriteLine("Select objects Layer are {0} have been Send to Clibboard", pstr)
                    If Not opbl.CurrentValue Then
                    End If
                    Return Result.Success
                End If

Hi @huaxiamengqing1,

In Rhino 5, you can use RhinoScript’s WorkSessionModelNames and related methods:

In Rhino 6, you can use this new Worksession class:

– Dale