Ok, so i have some questions regarding the p/invoking of methods out of a dll:
Does this look right for dllimport if both DLLs exist in the same folder? I am using an example project to test with. Both projects work separately, now I just want to understand how i can call a method from managed to native.
class UstnNative { [DllImport("TextUpdateCpp.dll", CharSet = CharSet.Unicode)] private static extern int createALine(DPoint3d dPoint); public static void CreateLine() { createALine(new DPoint3d(0, 0, 0)); } }
Here's the cpp file method:
void createALine(DPoint3dCR basePt) { EditElementHandle eeh; DSegment3d seg; seg.Init(basePt, DPoint3d::From(basePt.x + g_1mu * 2, basePt.y + g_1mu)); ICurvePrimitivePtr pCurve = ICurvePrimitive::CreateLine(seg); DraftingElementSchema::ToElement(eeh, *pCurve, nullptr, ACTIVEMODEL->Is3d(), *ACTIVEMODEL); eeh.AddToModel(); }
Can I pass in the DPoint3d from GeometryNET.DPoint3d to native Bentley.DPoint3D? Or do i need to use doubles and create a new point in native?
Hi Viktor,
fortunately the consuming native dll in managed code is common NET Framework feature, so it is well and in detail described in Microsoft NET Framework documentation. And because it's is complex and often used feature, there are plenty of discussions and tutorials available.
I recommend to see e.g. general description and also description specifically about structures.
With regards,
Jan
Bentley Accredited Developer: iTwin Platform - AssociateLabyrinth Technology | dev.notes() | cad.point