vbScript Import Document


#1

Hi Folks,

I am trying to script-wrap the Import command through vbScript. Strange thing is, that when I call

Rhino.Command “-_Import C:\Files\test1.3dm”

the following question pops up in the command line:

“Import scaling: Keep ( DimensionNumbers ):”

(Even though the units of the file to import matches the currently open one, but this is actually irrelevant to this question, because the import should also work if the files do not have the same units).

I have not found a way to press enter or even choose one of the two options through vbScript, since the script interpreter basically still hangs in the execution of Rhino.Command.

Any help / ideas? Is it a bug? Is it a feature? Would make more sense to have the option as a regular option of the -Import command, right?

(Rhino 5 32bit)

Thanks!
Michael


#2

Hi Michael,

testing on x64 only, pressing Enter does work here to get past the scaling prompt. Does the snipped below work any better ?

strFile = "C:\Files\test1.3dm"
Rhino.Command "_-Import " & CHR(34) & strFile & CHR(34) & " _Enter"

Note that i´ve put the file name in quotes to prevent problems inherited from spaces in your file path.

c.


#3

Wow, I was so sure that I have tried this, among other things, yesterday… Well, life. Thank’s a lot for the solution. It works :slight_smile:

As a thank you here my Import wrapper, for others to use (and extend? I don’t know whether there will be other options popping up depending on the file type to import).


```vb
' \brief    Imports a Rhino Document with the given File Path. Wraps the Rhino Import Command.
'
' \author    Michael Eigensatz
'
' \param[in] filePath    File Path
' \param[in] bKeepModelSize    When running the -Import command, Rhino asks what to keep: ModelSize or DimensionNumbers. True will keep ModelSize.
' \param[in] bEcho    Boolean. The command echo mode.  True means command prompts are echoed.
'
' \return  True on success, Else False
Function ImportRhinoDocument(ByVal filePath, ByVal bKeepModelSize, ByVal bEcho)
  ImportRhinoDocument = False
  Dim strKeep
  If bKeepModelSize Then
    strKeep = "_Enter"
  Else
    strKeep = "_DimensionNumbers"
  End If
  Dim commandResult
  commandResult = Rhino.Command("-_Import " & CHR(34) & filePath & CHR(34) & " " & strKeep, bEcho)
  If IsNull(commandResult) Then
    ImportRhinoDocument = False
  Else
    ImportRhinoDocument = commandResult
  End If
End Function
```

Thanks again!
Michael


#4

Thanks Michael. One thing about the code formating (syntax highlight on discourse), in my reply it did not work until i edited the post one time. Then it showed the formating colors. There is one topic about it Link

c.


#5

Yep worked. Thanks for info.