I thought maybe if i could grab the second line of the log that states the full path has opened successfully and copy and paste that. But i haven’t found any Rhino commands to be able to script that.
Could you give me a quick example of what you’re saying?
This is what i have so far. Just missing that filename!
Option Explicit
Sub Location
On Error Resume Next
Dim FileLocation
FileLocation = FileName
End Sub
Function FileName
Dim strPath, arrPoint
StrPath = Rhino.WorkingFolder & Rhino.DocumentName
If IsNull (Rhino.DocumentName) Then
arrPoint = Rhino.GetPoint("Pick Insertion Point")
IsArray (arrPoint)
Rhino.AddText strPath & "Main STP File", arrPoint, 5,,1
Else
End If
arrPoint = Rhino.GetPoint ("Pick Insertion Point")
IsArray(arrPoint)
Rhino.AddText strPath, arrPoint, 5,,1
MsgBox "Disclaimer: If this is an Untitled Rhino file. Your directory will be WRONG until you save it!", vbOkOnly
End Function
Hi Joseph - if you open your Step file with some code like this
Call Main()
Sub Main()
Dim OpenFile: OpenFile = Rhino.OpenFileName()
If isNull(OpenFile) Then
Exit Sub
End If
Rhino.Command("Open " & chr(34) & OpenFile & chr(34) & " Enter")
If Rhino.LastCommandResult() = 0 Then
Rhino.SetDocumentUserText "FileIOpened", OpenFile
Else
Exit Sub
End If
Rhino.Print("The file I opened is " & Rhino.GetDocumentUserText("FileIOpened"))
End Sub
In your later script you can retrieve the file name with Rhino.GetDocumentUserText(“FileIOpened”)
Hi Joseph - I was thinking that when you open your file, run a script like what I have above on a special file opening button or alias instead of the normal Open or Import commands. Is that what you mean?
(Call Main()
Sub Main()
Dim OpenFile: OpenFile = Rhino.OpenFileName()
If isNull(OpenFile) Then
Exit Sub
End If
Rhino.Command("Open " & chr(34) & OpenFile & chr(34) & " Enter")
If Rhino.LastCommandResult() = 0 Then
Rhino.SetDocumentUserText "FileIOpened", OpenFile
Else
Exit Sub
End If
Rhino.Print("The file I opened is " & Rhino.GetDocumentUserText("FileIOpened"))
Hi Joseph - chr(34) is the " character so that the path is surrounded in double-quotes.
If the Rhino command line hits a space in a string like a file path and there are no double-quotes, then it will assume that space is ‘Enter’ and stop there. The Enter at the end is like hitting Enter after hand typing in the path.
Hi Joseph - you can check with a function like this:
Call Main()
Function IsSaved ()
Dim x: x = Rhino.DocumentName()
If isNull(x) Then
IsSaved = False
Exit Function
Else
IsSaved = True
End If
End Function
Sub Main()
Rhino.Print IsSaved()
End Sub