Site Tools


Differences

This shows you the differences between two versions of the page.

Link to this comparison view

developer:scriptsamples:multilistbox [2015/09/14] (current)
Line 1: Line 1:
 +====== Selecting Multiple Files ======
 +====== RhinoScript ======
 +> **Summary:​** //​Demonstrates how to use RhinoScript'​s MultiListBox function to select multiple files.//
 +
 +The following example [[developer:​rhinoscript|RhinoScript]] code demonstrates how to use the **MultiListBox** function to display a list of file names to select.
 +
 +
 +<code vb>
 + Sub Test
 +   Dim sFolder
 +   ​sFolder = Rhino.BrowseForFolder( , "​Select folder with 3DM files" )
 +   If VarType( sFolder ) <> vbString Then Exit Sub
 +
 +   Dim oFSO
 +   Set oFSO = CreateObject( "​Scripting.FileSystemObject"​ ) 
 +
 +   Dim oFolder
 +   Set oFolder = oFSO.GetFolder( sFolder )
 +
 +   Dim oFile, aFiles(), nCount
 +   ​nCount = 0
 +   For Each oFile In oFolder.Files
 +     ReDim Preserve aFiles(nCount)
 +     ​aFiles(nCount) = oFile.Name
 +     ​nCount = nCount + 1
 +   Next
 +
 +   If nCount = 0 Then 
 +     ​Rhino.Print "​Selected folder contained no 3DM files."​
 +     Exit Sub
 +   End If
 +
 +   Dim aSelected, sSelected
 +   ​aSelected = Rhino.MultiListBox(aFiles,​ oFolder.Path)
 +   If IsArray(aSelected) Then
 +     For Each sSelected In aSelected
 +       ​Rhino.Print sSelected
 +     Next
 +   End If
 +
 + End Sub
 +
 +</​code>​
 +
 +
 +{{tag>​Developer RhinoScript}}
  
developer/scriptsamples/multilistbox.txt ยท Last modified: 2015/09/14 (external edit)