Hi, everyone, I want to use this function: mdlKISolid_makeSweptBody in my C#/Addin project. It is an undisclosed function, its declaration in my pure mdl project is below:
extern int mdlKISolid_makeSweptBody(KIBODY **ppBody, /* <= swept body */KIBODY *pProfile, /* => either wire or sheet */KIBODY *pPath, /* => must be wire */KIVERTEX *pPathStart, /* => path starting vertex */KIVERTEX *pStart, /* => for twist and scale control */KIVERTEX *pEnd, /* => for twist and scale control */double startTwist, /* => twist angle at start in radian */double endTwist, /* => twist angle at end in radian */double startScale, /* => scale at start */double endScale, /* => scale at end */int topologyForm, /* => 0: minimal, 1: column, 2: grid */BoolInt normalAlignment, /* => TRUE: normal, FALSE: parallel */BoolInt simplify /* => TRUE: yes, FALSE: no */);
When I call this function in my pure mdl project , it works very well. In my C# project , althrough it works, it is not controllable, for the second parameter of the countdown.
The declaration of this function in my C#/Addins project is like this:
[DllImport("kisolid.dll")] public static extern int mdlKISolid_makeSweptBody(ref int bodyPP, int profileP, int pathP, object pPathStart, object pStart, object pEnd, double startTwist, double endTwist, double startScale, double endScale, short topologyForm, bool normalAlignment, bool simplify);
In my dgn file, there are two elements, the Curve element represents the path, the Ellipse element represents the profile,
The result processed by my pure mdl project is like this:
But the result in my C# project is like this:
I know that I should give a wrong declaration for this function in my C# project, result in the second parameter of the countdown doesn't work.
My pure mdl project is below, whick contains the dgn file.
TestSweepCurveProblem.rar
Anyone who can help me?
Hi,
it's nice to know it works now :-)
Just one technical note: To process pointer as int (which is Int32 at C# 32bit code) should probably work fine, but in fact is not correct. The clean / right approach is to use System.IntPtr, because this is data type depending on architecture, so it's implemented automatically correctly at background (and in the case of 32bit C# it will be int again I guess ;-)
With regards,
Jan
Bentley Accredited Developer: iTwin Platform - AssociateLabyrinth Technology | dev.notes() | cad.point
Hi, everyone, I solved the problem, this function should be declared like this:
[DllImport("kisolid.dll")] public static extern int mdlKISolid_makeSweptBody(ref int bodyPP, int profileP, int pathP, int pPathStart, int pStart, int pEnd, double startTwist, double endTwist, double startScale, double endScale, int topologyForm, int normalAlignment, int simplify);
Thanks to Jan slegr again!
study forever
Thanks to Jan Slegr, I will try again!
my feeling is that your definition how data types should be marshalled is not correct. Check this article and compare it with how MDL data types are declared. E.g. KIBODY* should be probably System.IntPtr, BoolInt is int, so it should be marshalled as int, also normal int should not be marshalled as short, but int etc.