Brep data from c# to native c++

Hi guys,

My codes are all written in native c++. Now I have to use c# codes to write grasshopper component. Could I pass Brep data from c# to native c++? Has anyone written such codes before?
What can I think of is:
a. pass the pointer (not sure whether it is possible).
b. pass the guide, and in native c#, I can get the global pointer CRhinoCommandContext, so I could find the brep user has selected.
c. write the brep data to a file, reload the data inside native c++.

Not sure which approach is a good one, could anyone please help? Any tips will be appreciated.

thank you.

Regards
Eric

Hi @smartunfold,

The Rhino.Runtime.Interop class has some helper functions that can get a pointer you can pass from C# to C++.

Brep brep = ...

# Get unsafe const pointer
IntPtr const_ptr_brep = Rhino.Runtime.Interop.NativeGeometryConstPointer(brep);

// Call unsafe method:
bool rc = UnsafeNativeMethod.MyBrepFunc(const_ptr_brep);

– Dale

thank you.