How to convert IGS or IGES file to WRL using C# console/WinForm app on VS 2019

Dear all,

I’ve just installed the latest Rhino V7.0 on Windows 10.
I have an evaluation license for 90 days.
I want to write a simple Console or Winform app with C#, that can can be used to convert IGS, IGES or STP file into WRL.
I’ve added the Rhino PLUGIN to VS2019, and also in my project I installed the Nuget package of RhinoCommon.

I wrote simple code as follows:

  const string IGS_FILE_NAME = @"D:\Tempo\Work\FilesConverter\Samples\NSH230A01_igs.igs";
  bool isAlreadyOpen;
  RhinoDoc rhinoDoc = RhinoDoc.Open(IGS_FILE_NAME, out isAlreadyOpen);

And I always get the following error ! :(((

System.IO.FileNotFoundException: ‘Could not load file or assembly ‘RhinoCommon, Version=7.4.21078.1000, Culture=neutral, PublicKeyToken=552281e97c755530’ or one of its dependencies. The system cannot find the file specified.’
PLEASE HELP.

Thank you!

Hi @alberte,

RhinoCommon is only available inside of a running Rhino.

For your project, you might want to look at our Rhino.Inside technology. Here you can host Rhino inside of a .NET console application.

Here is a sample that “converts” 3dm files into png files. Perhaps you can adapt this to your need.

– Dale

Dear Dale,

I did exactly as you recommended me to do, and even copied the source code from the ConvertSample, mentioned above, to my Console application.
However, it did not work … :frowning: I keep getting the following error …

Unable to load DLL ‘RhinoLibrary’: The specified module could not be found. (Exception from HRESULT: 0x8007007E)

Any help please … ?

Thanks in advance,
Albert

Hi @alberte,

The attached simple example works here using Visual Studio 2019 and Rhino 7.8.

convert_iges.zip (3.1 KB)

– Dale

Dear Dale,

Thank you so much for that. It works very well!!
Now I have to use it and create a similar one to convert from STEP to WRL, and from PRT to WRL.

Dear @dale,

Thanks again!
I tried to use the same solution above to convert from STP (STEP) to WRL. It didn’t work… I get the following on the screen:

Reading D:\Tempo\Work\FilesConverter\Samples\STP\1531M84G12_2_HPT ROTOR.stp…
ST-DEVELOPER
System Release v16.5

               Copyright (c) 1991-2015 by STEP Tools Inc.
                          All Rights Reserved

               -----------------------------------------

And then an infinite loop of lines like follows:

ROSE: warning: Cannot typecast object of type: ‘plane’ to ‘conical_surface’

Any idea please? THANKS!

Hi @alberte,

Does your STEP file open just using Rhino’s Open command? Can you forward me your STEP file? You can set send me a private message if you prefer.

– Dale

Well, actually that was a very problematic file that does not get open at all…
But following are 2 files to check:
30G6201_C.stp (10.0 MB)
30G7301_A.stp (9.0 MB)

Thanks in advance!

Hi @alberte,

The two STEP files you posted seem to open in Rhino 7 without issue. What am I missing?

– Dale

Dear @dale,

That is right! In Rhino7 those STEP files are open without any problem.
But, I wanted to convert them to WRL format. Therefore, I used the convert_igs solution that you sent me recently. The conversion worked and WRL file was created. However, I received following message on screen all the time:

                                ST-DEVELOPER
                                  System Release v16.5
               Copyright (c) 1991-2015 by STEP Tools Inc.
                          All Rights Reserved

               -----------------------------------------

And then an infinite loop of lines like follows:

ROSE: warning: Cannot typecast object of type: ‘plane’ to ‘conical_surface’

Thanks,
Albert

Hi @alberte,

What your seeing is just console output from the STEP file writer. You dont’ see this when you run Rhino because there is no console output device.

If you don’t want to see these messages, you might consider redirecting console output using Console.SetOut.

– Dale

– Dale

Alright then, thanks a lot :slight_smile:

Dear @dale ,

Is there any way to convert PRT (Unigraphics) file to WRL format, using Rhino7 - Inside?
I’ve tried the above solution that you provided me for converting IGES to WRL, but it did not work.

Thanks,
Albert

Hi @alberte,

Rhino does not open Unigraphics files without the assistance of a 3rd party file import plug-in. Here are a couple of vendors who provide solutions.

https://www.datakit.com/en/

– Dale