TheSwamp
Code Red => .NET => Topic started by: itcad on November 07, 2008, 08:47:51 AM
-
Which is the correct syntax to P/Invoke the acedGrRead function, specially the third argument?
This code is wrong:
[DllImport("acad.exe", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)]
extern static public int acedGrRead(int track, int type, double[] output);
public void LAcedGrRead()
{
int track = 1, type = new int();
double[] output = new double[3];
while (track > 0)
{
acedGrRead(track, type, output);
if (type == 3) track = 0
}
}
Who can tell me the right code?
-
Which is the correct syntax to P/Invoke the acedGrRead function, specially the third argument?
This code is wrong:
[DllImport("acad.exe", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)]
extern static public int acedGrRead(int track, int type, double[] output);
public void LAcedGrRead()
{
int track = 1, type = new int();
double[] output = new double[3];
while (track > 0)
{
acedGrRead(track, type, output);
if (type == 3) track = 0
}
}
Who can tell me the right code?
There's really no need to use acedGrRead() in ObjectARX these days.
That's a legacy API that does not work (because it disables all kinds
of things like use of menus and so forth), and that's why You shouldn't
use it to start with.
To arrive at the same functionality, you add a handler to the Editor's
PointMonitor event just before you call it's GetPoint() method, and
remove the handler after the GetPoint() call returns.
In the handler, you can get the cursor location, draw temporary graphics,
query the objects in the aperture/pickbox, and do other things that you
can't easily do via acedGrRead().
-
Which is the correct syntax to P/Invoke the acedGrRead function, specially the third argument?
This code is wrong:
[DllImport("acad.exe", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)]
extern static public int acedGrRead(int track, int type, double[] output);
public void LAcedGrRead()
{
int track = 1, type = new int();
double[] output = new double[3];
while (track > 0)
{
acedGrRead(track, type, output);
if (type == 3) track = 0
}
}
Who can tell me the right code?
There's really no need to use acedGrRead() in ObjectARX these days.
That's a legacy API that does not work (because it disables all kinds
of things like use of menus and so forth), and that's why You shouldn't
use it to start with.
To arrive at the same functionality, you add a handler to the Editor's
PointMonitor event just before you call it's GetPoint() method, and
remove the handler after the GetPoint() call returns.
In the handler, you can get the cursor location, draw temporary graphics,
query the objects in the aperture/pickbox, and do other things that you
can't easily do via acedGrRead().
It hasn,t the Editor's PointMonitor in autocad2005,so I need use acedGrRead.
-
Which is the correct syntax to P/Invoke the acedGrRead function, specially the third argument?
This code is wrong:
[DllImport("acad.exe", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)]
extern static public int acedGrRead(int track, int type, double[] output);
public void LAcedGrRead()
{
int track = 1, type = new int();
double[] output = new double[3];
while (track > 0)
{
acedGrRead(track, type, output);
if (type == 3) track = 0
}
}
Who can tell me the right code?
There's really no need to use acedGrRead() in ObjectARX these days.
That's a legacy API that does not work (because it disables all kinds
of things like use of menus and so forth), and that's why You shouldn't
use it to start with.
To arrive at the same functionality, you add a handler to the Editor's
PointMonitor event just before you call it's GetPoint() method, and
remove the handler after the GetPoint() call returns.
In the handler, you can get the cursor location, draw temporary graphics,
query the objects in the aperture/pickbox, and do other things that you
can't easily do via acedGrRead().
It hasn,t the Editor's PointMonitor in autocad2005,so I need use acedGrRead.
I think this is what you need:
public class Class1
{
[DllImport( "acad.exe", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode )]
public extern static int acedGrRead( int track, out int code, IntPtr result );
public static void Example()
{
int track = 1;
int code = 0;
IntPtr p = IntPtr.Zero;
acedGrRead( track, out code, p );
if( p != IntPtr.Zero )
{
using( ResultBuffer buffer = ResultBuffer.Create( p, true ) )
{
// Here, the coordinate result is in buffer, if
// the code output parameter indicates that a
// coordinate result was returned
}
}
}
}
-
Which is the correct syntax to P/Invoke the acedGrRead function, specially the third argument?
This code is wrong:
[DllImport("acad.exe", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)]
extern static public int acedGrRead(int track, int type, double[] output);
public void LAcedGrRead()
{
int track = 1, type = new int();
double[] output = new double[3];
while (track > 0)
{
acedGrRead(track, type, output);
if (type == 3) track = 0
}
}
Who can tell me the right code?
There's really no need to use acedGrRead() in ObjectARX these days.
That's a legacy API that does not work (because it disables all kinds
of things like use of menus and so forth), and that's why You shouldn't
use it to start with.
To arrive at the same functionality, you add a handler to the Editor's
PointMonitor event just before you call it's GetPoint() method, and
remove the handler after the GetPoint() call returns.
In the handler, you can get the cursor location, draw temporary graphics,
query the objects in the aperture/pickbox, and do other things that you
can't easily do via acedGrRead().
It hasn,t the Editor's PointMonitor in autocad2005,so I need use acedGrRead.
I think this is what you need:
public class Class1
{
[DllImport( "acad.exe", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode )]
public extern static int acedGrRead( int track, out int code, IntPtr result );
public static void Example()
{
int track = 1;
int code = 0;
IntPtr p = IntPtr.Zero;
acedGrRead( track, out code, p );
if( p != IntPtr.Zero )
{
using( ResultBuffer buffer = ResultBuffer.Create( p, true ) )
{
// Here, the coordinate result is in buffer, if
// the code output parameter indicates that a
// coordinate result was returned
}
}
}
}
I try to use your code,but it's wrong.
please try again.
-
public static void Example()
{
int track = 1;
int code = 0;
ResultBuffer buffer = new ResultBuffer(
new TypedValue[] { new TypedValue( 5009, Point3d.Origin ) } );
acedGrRead( track, out code, buffer.UnmanagedObject );
if( code == 5 )
{
TypedValue[] values = buffer.AsArray();
Console.Write( values[0].Value );
}
}
-
Has anyone ever tried using C++/CLI /CLR:Pure on 05?
-
Has anyone ever tried using C++/CLI /CLR:Pure on 05?
I haven't tried much of anything on '05.
It's ancient history here.