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.