Hi friends,
I'm working with MicroStation v8i (SELECT series 3) v08.11.09.578, with VBA
I need to use the MDL function mdlPattern_area in C#. This function has a cellName parameter of type Long.In VBA this value is obtained with the function strPtr("myCell"),for C # I have been recommended to use P/Invoke but I do not know how to do it
DECLARATION
[DllImport("stdmdlbltin.dll", CallingConvention = CallingConvention.Cdecl)] public static extern int mdlPattern_area(ref long patternEdPP, long solid, long holes, long cell, long cellName, double scale, double angle, double rowSpacing, double columnSpacing, int view, long searchForHoles, ref BCOM.Point3d originPoint);
IMPLEMENTATION
BCOM.Point3d[] points = new BCOM.Point3d[5]; points[0].X = 440453.86; points[0].Y = 4639314.61; points[0].Z = 297.66; points[1].X = points[0].X + 20; points[1].Y = points[0].Y; points[1].Z = 297.66; points[2].X = points[0].X + 20; points[2].Y = points[0].Y + 20; points[2].Z = 297.66; points[3].X = points[0].X; points[3].Y = points[0].Y + 20; points[3].Z = 297.66; points[4].X = points[0].X; points[4].Y = points[0].Y; points[4].Z = 297.66; BCOM.ShapeElement myShape1; myShape1 = app.CreateShapeElement1(null, points); string cellName = "MYPATTERN"; long pHatch = 0; long status = mdl.mdlPattern_area(ref pHatch, myShape1.MdlElementDescrP(false), 0, 0, ¿¿cellName??, 1, 0, 0, 0, 0, 0, ref points[0]); if (SUCCESS != status) { }
Please, can someone help me?
Kala
kala mit tat said:I have been recommended to use P/Invoke but I do not know how to do it
Have you looked on a web site that deals with Microsoft .NET for information about P/Invoke? For example, here's a tutorial about P/Invoke.
Regards, Jon Summers LA Solutions
Hi Kala,
kala mit tat said:for C # I have been recommended to use P/Invoke but I do not know how to do it
at first, you have to read Microsoft documentation. See marshalling "type conversion table" I linked earlier.
Also see my anser in your earlier post.
With regards,
Jan
Bentley Accredited Developer: iTwin Platform - AssociateLabyrinth Technology | dev.notes() | cad.point
Answer Verified By: Robert Hook
thanks Jan, the problem has been solved, I was using LONG instead of INT in the parameters of the MDL function
thank you too Jon
Regards