How to convert several file (.igs) to (.wrl)

Hello everyboby,

All the time, i need to convert several file (.igs) to (.wrl), and i waste a lot of time, it’s possible to convert all file in one time, and how to do it ? or more efficiently.

Actually i need to open the file on rhino5.0 and save it as (.wrl). "so long when you have many files.

Thank in advance.

Quentin

yes this is possible with a script for example (simplified example, not much error checking…meshing part probably needs adjustment to your needs):

import Rhino
import rhinoscriptsyntax as rs
import scriptcontext as sc
import System

def readDirectory(filter="*.igs"):
    folder = rs.BrowseForFolder("Select folder to process")
    if folder == None:
      return None
      
    #get files to process
    filelist =[]
    filelist = System.IO.Directory.GetFiles(folder,filter, System.IO.SearchOption.AllDirectories)
    return filelist

def saveWrl():
    filelist = readDirectory()
    if filelist == None:
        return
    for filepath in filelist:
        sc.doc.Modified = False
        rs.Command('_-Open "{}" _Enter'.format(filepath))
        rs.Command("_SelAll")
        rs.Command("_ExtractRenderMesh")
        rs.Command("_Delete")
        filepath = filepath.replace(".igs",".wrl")
        rs.Command('-_Export "{}" _Enter'.format(filepath) )
rs.EnableRedraw(False)        
saveWrl()
rs.EnableRedraw(True) 
2 Likes

Thank you !! you respond so quickly !!!
I tried it, i wasn’t thinking it’s possible to code on rhinoceros.
You find this on internet ? or you know how to code ?

Thank you so mutch.

Quentin

I composed it from other scripts I had in my archives, because most of the time working with files follows the same kind of patterns. I’m by no means an expert programmer, there are far more experienced programmers on this forum, but I know enough for making these kind of simple things.
If you want to learn using python on Rhino, a good start is https://www.rhino3d.com/download/IronPython/5.0/RhinoPython101

1 Like

It is also possible without Rhino with CrossManager.

Hi, which version of Python do I need to install on my PC in order to use your script above…?

Thanks!

Hello - IronPython installs with Rhino - the script should just work.

-Pascal

Thank you @pascal.
I have Rhino7 installed on Windows 10. I took the script above and saved it as RhinoScript1.py and then tried to run it in command line … and got following error :frowning:
ImportError: No module named Rhino

Hello - can you please run the SystemInfo command in Rhino and copy/paste the entire output here?

-Pascal

Rhino 7 SR7 2021-6-9 (Rhino 7, 7.7.21160.05001, Git hash:master @ d2161989109d5dacba531310b5d345ce6f4da9f6)
License type: Evaluation, build 2021-06-09
License details: Cloud Zoo
Expires on: 2021-10-12

Windows 10.0.19042 SR0.0 or greater (Physical RAM: 16Gb)

Computer platform: LAPTOP - Plugged in [100% battery remaining]

Hybrid graphics configuration.
Primary display: Intel(R) UHD Graphics (Intel) Memory: 1GB, Driver date: 4-7-2021 (M-D-Y).
> Integrated graphics device with 3 adapter port(s)
- Windows Main Display is laptop’s integrated screen or built-in port
- Secondary monitor attached to adapter port #1
Primary OpenGL: NVIDIA Quadro P520 (NVidia) Memory: 2GB, Driver date: 4-5-2021 (M-D-Y). OpenGL Ver: 4.6.0 NVIDIA 462.30
> Integrated accelerated graphics device (shares primary device ports)
- Video pass-through to primary display device

OpenGL Settings
Safe mode: Off
Use accelerated hardware modes: On
Redraw scene when viewports are exposed: On
Graphics level being used: OpenGL 4.6 (primary GPU’s maximum)

Anti-alias mode: 4x
Mip Map Filtering: Linear
Anisotropic Filtering Mode: High

Vendor Name: NVIDIA Corporation
Render version: 4.6
Shading Language: 4.60 NVIDIA
Driver Date: 4-5-2021
Driver Version: 27.21.14.6230
Maximum Texture size: 32768 x 32768
Z-Buffer depth: 24 bits
Maximum Viewport size: 32768 x 32768
Total Video Memory: 2 GB

Rhino plugins that do not ship with Rhino

Rhino plugins that ship with Rhino
C:\Program Files\Rhino 7\Plug-ins\Commands.rhp “Commands” 7.7.21160.5001
C:\Program Files\Rhino 7\Plug-ins\WebBrowser.rhp “WebBrowser”
C:\Program Files\Rhino 7\Plug-ins\rdk.rhp “Renderer Development Kit”
C:\Program Files\Rhino 7\Plug-ins\RhinoScript.rhp “RhinoScript”
C:\Program Files\Rhino 7\Plug-ins\IdleProcessor.rhp “IdleProcessor”
C:\Program Files\Rhino 7\Plug-ins\RhinoRenderCycles.rhp “Rhino Render” 7.7.21160.5001
C:\Program Files\Rhino 7\Plug-ins\rdk_etoui.rhp “RDK_EtoUI” 7.7.21160.5001
C:\Program Files\Rhino 7\Plug-ins\rdk_ui.rhp “Renderer Development Kit UI”
C:\Program Files\Rhino 7\Plug-ins\NamedSnapshots.rhp “Snapshots”
C:\Program Files\Rhino 7\Plug-ins\Alerter.rhp “Alerter”
C:\Program Files\Rhino 7\Plug-ins\RhinoCycles.rhp “RhinoCycles” 7.7.21160.5001
C:\Program Files\Rhino 7\Plug-ins\Toolbars\Toolbars.rhp “Toolbars” 7.7.21160.5001
C:\Program Files\Rhino 7\Plug-ins\3dxrhino.rhp “3Dconnexion 3D Mouse”
C:\Program Files\Rhino 7\Plug-ins\Displacement.rhp “Displacement”

Hello - that all looks reasonable to me - can you run EditPythonScript in Rhino and get the script editor? If so, can you type or copy/paste

import Rhino

at the top of a new script and then click the green arrow to run the script - do you get the same error message?

-Pascal

I did what you asked me to.
It worked and did not show me any error.

@alberte
Maybe you tried to run the script through

RunScript

Instead of

RunPythonScript?

Question:
How can I run the above conversion script in command line, without any UI screens?
What are the steps please ?