New Dot NET v2.0 (Bottle Tutorial) assembly libraries for OpenCASCADE v6.2

Updated .NET assembly for OpenCASCADE v6.2 including example code for the Bottle Tutorial.

Download from:-

http://www.myxyz.co.uk/Downloads/Development/MakeBottle.zip

Just unzip the files and run the RegAll.bat file to register the OpenCASCADE COM module.

The OpenCASCADE COM module could also be used in other RAD type Development Environments, i.e. Visual Basic.

Jonathan

Gerhard Hofmann's picture

Hello Jonathan,

since we both offer our ".NET wrappers" here, I would like to get in contact with you. I am curious about the technologies you use, the motivation, the projects you are working on with OpenCascade, your experience with OpenCascade, etc. Just fel free to mail me at g-hof-mann[at]so-fa.de (omit the "-" characters).

best regards
Gerhard

Hesham Nasif's picture

Dear Gerhard
First of all i would like to express my thanks to you at early time help. I almost finish one application using OCC, it is not commericial but rather it is help for creating some geometrical model for other code. I wanted to ask you a question, and i am willing your answer as usual. How can i put my code into other machine does not have OCC on it
Best. My E-mail address has been changed to that one
Hesham

zhangbing's picture

Cool! Thank you!!!

zhangbing's picture

Hi, Jonathan
I convert the C# code to VB(VS2005), but there is an error about the function "MakeCompound" when debuging, it says that "Method not found: 'Void OpenCASCADEXLib.IBRep_Builder.MakeCompound(OpenCASCADEXLib.TopoDS_Compound ByRef)'.", what can I do?

Thank you!

Jonathan Hill's picture

Hi zhangbin,

Would it be possible for you to send me the VB code or project, just to save myself converting the code again and I'll let you know what I find.

Best Regards
Jonathan

zhangbing's picture

How can I get your EMAIL?

zhangbing's picture

Hello, Jonathan
Please give me your EMail,I can send the code to you. Thank you!

Jonathan Hill's picture

Hi zhangbing

JonathanHilljonpcdemoncouk

Jonathan

Jonathan Hill's picture

Hi zhangbing,

I'm trying to send an attachment to your e-mail address, but it just fails to deliver.

Jonathan

zhangbing's picture

Hi Jonathan,

I've received your e-mail, I try to debug again, it works perfect!

Thanks for your help!

Best regards

Axel Stenkamp's picture

Hello,

first thank you for publishing the MakeBottle example.

I am new to OpenCascade coding and found your wrapper to my favourite language C#.
Now i tried to read and show a step file using your sourcecode.

Here is my approach:

OpenCASCADE52.ModelingData.TKBRep.TopoDS.Interfaces.IShape topoDS_shape;

OpenCASCADE.ModelingData.TKBRep.TopTools.HSequenceOfShape sequenceofShape = new OpenCASCADE.ModelingData.TKBRep.TopTools.HSequenceOfShape();

if (OpenCASCADE.IO.ImportExport.ReadSTEP(openFileDialog.FileName, sequenceofShape) == OpenCASCADE52.DataExchange.TKXSBase.IFSelect.Interfaces.ReturnStatus.IFSelect_RetDone)
{
for (int index = 0; index < sequenceofShape.Length; index++)
{
topoDS_shape = sequenceofShape.Indexer(index);
OpenCASCADE.Visualization.TKV3d.AIS.Shape AIS_shape = new OpenCASCADE.Visualization.TKV3d.AIS.Shape(topoDS_shape);

Effect:
Reading the step file works fine... but accessing the sequenceofShape via the Indexer causes an AccessViolationError.

Question:
How do i access sequenceofShape to get topoDS_Shape, which i again need to convert to OpenCASCADE.Visualization.TKV3d.AIS.Shape for the viewer?
TopTools_HSequenceOfShape Class Reference does not seem to be equal to your wrapper code.

Thanks for your help.
Axel

Jonathan Hill's picture

Hi Axel,

I've just had a quick look at the code. It looks like the problem is that OpenCASCADE uses 1-based and not zero-based indexing in the sequence type (I've hit this a few times now :-( when working with the OpenCASCADE libraries).

I've include the fix code below:-

/* for (int index = 0; index < sequenceofShape.Length; index++) */
for (int index = 1; index <= sequenceofShape.Length; index++)

You can check this by looking at the C++ CImportExport class under the OpenCASCADE samples folder.

All the rest of the code looks fine to me, all you need to add is the "Display" command (and maybe FitAll) and then your model should be shown in the view.
I also import .STEP & .IGES files and if you need any help, then just let me know and good luck.

If you do come across a problem or the fix doesn't fix your issue I can create a demo STEP reader solution and see if that works for you.

Best Regards
Jonathan

Axel Stenkamp's picture

Hello Jonathan,

and it worked perfectly using the new index start.

Thank you for the immediate help.
Best Regards,
Axel

Ernest Abbott's picture

Hi Jonathan,

Looking back at the code originally given I tried it out, but got a compilation error on

if (OpenCASCADE.IO.ImportExport.ReadSTEP(openFileDialog.FileName, sequenceofShape) == OpenCASCADE52.DataExchange.TKXSBase.IFSelect.Interfaces.ReturnStatus.IFSelect_RetDone)

The problem is with OpenCASCADE.IO. ... it doesn't seem to exist. I've look at a lot of classes and can't find It. I'm using OCC6.2 and C# Express.

I'm am still trying to find my way around OCC (without any training or support documentation). I'm trying a proof of concept system and need to do 3 main things:-1

1. Read a Step file and display its contents
2. Select and object from the displayed file
3. Read a list of supplied vertices to create an object.

I can do 3. in OpenGL and 1 & 2, using an IFC file in OpenGl. But finding my way around OCC is proving very slow. I'm working in a research department of Singapore University and my time is running out.

I'm not asking for code as such but the general outline or example of how to do the above.

juri's picture

Hi Jonathan,

is it possible to compute a BoundingBox over an AIS_Shape? How can i do that?

my old Code was like this:

if (!entireBody.IsNull())
{
AIS_Shape entireAIS_Shape(entireBody);

Bnd_Box bounding_box = entireAIS_Shape.BoundingBox();
bounding_box.Get(xmin, ymin, zmin, xmax, ymax, zmax);
}

thanks, best regards, juri

Jonathan Hill's picture

Hi Juri

private void TestBoundingBox(OpenCASCADE52.Visualization.TKV3d.AIS.Interfaces.IShape shape)
{
IBox box = new Box();

box.Gap = 0.0;

if( shape != null )
BRepBndLib.Add(shape.TopoDSShape, ref box);

double xMin = 0;
double yMin = 0;
double zMin = 0;
double xMax = 0;
double yMax = 0;
double zMax = 0;

box.Get(ref xMin, ref yMin, ref zMin, ref xMax, ref yMax, ref zMax);
}

See if that works OK for you.

Best Regards
Jonathan

juri's picture

Hello Jonathan,

thank you very much for your suggestion. It works!
But i have some more questions. It was possible to create a box on a definied position like

BRepPrimAPI_MakeBox(gp_Pnt, x, y, z)

but i can´t find it now. I have only one possibility MakeBox(x, y, z).

And what about AIS_Trihedron. I cant find this class now???

Best regards,
Juri

Jonathan Hill's picture

Hi Juri,

Sorry for not replying, I've not had chance to check up on the forum for a while.

Do you still need feedback on your query?

Jonathan

YU XINGSHENG's picture

First thanks for your wrapper
I am a C# programer and new to OpenCascade coding,Now i am making a FEM software,want to display some text in the context like billboard,I just found the OpenCASCADE.Visualization.TKV3d.Prs3d.TextAspect,where I can found the Graphic2d_Text and create it use TextAspect,
In addition,the function Context.DisplayedObjects(ref IListOfInteractive list)'parameter 'IListOfInteractive',which class that implement the interface i use to create the parameter?is it ListOfInteractive?I create it,but I failed!

thank you very much!

Jonathan Hill's picture

Hi YU XINGSHENG,

I can look into adding support for the Graphic2d_Text class for you, could you tell me which methods and properties you would require, (this sometimes means including support for many of the other classes as well so it may take some time).

I'll also look at the ListOfInteractive parameter for you to.

Best Regards
Jonathan

YU XINGSHENG's picture

thanks for your kind works,I just want display some attributes such as the Node's and the Element's index,So,the text's properties best contain font(true type of SHX that supporting chiness),height,color,scale,etc.
otherwise,If you can add a 'Tag' property in the Shape class,so i can add the object which the shape represent to the Vertex,Edge,Face,Solid,etc.I want fetch the finite Element Object from the selected objects.
thanks very much again!

Robert Hill's picture

Hi Jonathon,

I had the same problem as someone else. I downloaded your zip file but after installation I tried to run it and got an error message that the MakeCompound method was not found. Thus, the bottle was not able to generate.

Any idea how I can correct this? I was just using the C# solution.

I was able to tinker with your solution and get some basic items to draw. I'm definitely interested in learning more about OpenCASCADE but I also want to use it in a C# solution.

Any feedback you can give is appreciated.

Thanks, R. Hill

Jonathan Hill's picture

Hi Robert,

I’ve updated the MakeBottle sample and you can download it from:- (watch out for the case sensitive path)

http://www.myxyz.co.uk/Downloads/Development/

Let me know if it works for you.

Jonathan

Claudio Benghi's picture

Hi Jonathan,

I've tried to intall this Feb 3rd version of Makebottle on different computers but apparently they all report a problem when registering OpenCASCADEX.dll in the system.

I've tried on 2 winxp pro systems both with .Net35 installed or not (during the setup .net35 is downloaded and installed).

I also tried to add the library to a solution references but again an error is thrown.

Fortunately I had a backup of the previous version so I'm continuing the development with your helpfil wrapper, but couldn't test the latest features.
Are there any pre-requisites I'm missing?

Thanks,
Claudio

Claudio Benghi's picture

Hello All,
I previously reported an error during the setup of the latest MakeBottle.
The error is thrown if VC++2008 redistributable files are not installed on the machine.
You can download it from MS website:
http://www.microsoft.com/downloads/details.aspx?familyid=9B2DA534-3E03-4...
Best, Claudio

Ernest Abbott's picture

I've downloaded the version dated 17th Feb 2008. I have encountered a couple of problems.

1. The compiled version makebottle.exe cancels with an "attempt to read or write to protected memory". I have a screen shot of the failing message, including some of the exception text, if it is of any help.

2. I've opened the source file using C# express 2005. There seems to be a missing module "InteractiveCADViewControl.cs". So I'm not able to compile the program.

regards

Ernest Abbott

Michael Hill's picture

I'm having the same problem. Is there an older version I could look at instead?

Claudio Benghi's picture

Micheal, Earnest,

Jonathan is probably working on a more advanced control, but the 17 Feb version can run if you replace the missing class with a "CADViewControl".

Best,
Claudio

Jonathan Hill's picture

Hi Ernest/Michael

I 've uploaded a MS-Visual 2005 'MakeBottle' for you try out.

http://www.myxyz.co.uk/Downloads/Development/MakeBottle_2005.zip

Let me know if your have any problems.

Best Regards.
Jonathan

Robert Hill's picture

Hi Jonathan,

Thanks for all your great work on your wrapper. I've been experimenting and have run into a problem. I am trying to select an object to modify it. When I try to run the following code:

OpenCASCADE.Visualization.TKV3d.AIS.Shape tempShape;
tempShape = (OpenCASCADE.Visualization.TKV3d.AIS.Shape)viewControl.Context.SelectedInteractive;

I get an InvalidCastException error message that it is unable to cast the object. It seems that this should work. Can you tell me if I am doing something wrong?

Another question I had is: do you implement any of the OCAF package in your wrapper?

Best regards,
Robert

Stephen Leary's picture

Download link is not working anymore.

Does anyone have a copy posted anywhere?

Stephen

Jonathan Hill's picture

Hi Stephen,

I’ve updated the MakeBottle sample and you can download it from:- (watch out for the case sensitive path)

http://www.myxyz.co.uk/Downloads/Development/

Also, I've included an AISSelect.zip sample.

Jonathan

Guido van Hilst not specified's picture

Hi Jonathan,
I cant get the download from :http://www.myxyz.co.uk/Downloads/Development/

Can you please update the download link?

Many thanks,

Guido

vv's picture

Hi
Same here, where can we find a wrapper to download?
10x

Rajendra's picture

Sorry couldnot download from the link..:(
Like to see the code.
thank you

Artem Chernetzov's picture

Couldn't find a Shape.Location property... How to locate shapes with wrapper?
And more complex task: I try to create composite solid from solids (like assembly from parts in Solid Works), so:
1) How create solid from shape? (I create cylinder with MakeCylinder.Shape)...
2) How create for example cone solid, that locate at the top of cylinder? (like cap), and this must be different parts, not one solid body... And how rotate solids?...
3) How enable wireframe view? :) In original tutorial: button "Hidden ON"
Thanks

Guido van Hilst not specified's picture

Hi

I have made atomated wrappers c# wrappers for all of occ;

And also added lot of extension methods, to make it real easy to use OCC in c#

You can have a example here

MakeBotlle

FaceNormals example

Cheers Guido​