- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello,
I feel that 'acedEvaluateLisp' does not work when used in console mode
Do you have a solution.?
Script:
(command "netload" "d:/dev/test/bin/debug/test.dll")
cmdtest
(eval a)
(princ "\nFin du traitement")
Sample Test.dll:
///
using System;
using System.Collections.Generic;
using System.Windows.Forms;
using System.Text;
using System.Runtime.InteropServices;
using Autodesk.AutoCAD.Runtime;
using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.Windows;
using Autodesk.AutoCAD.Geometry;
using Autodesk.AutoCAD.EditorInput;
using Autodesk.AutoCAD.Interop;
namespace Test
{
/// <summary>
/// Classe générale des outils AutoCAD
/// </summary>
public class Test : IExtensionApplication
{
/// <summary>
/// Init
/// </summary>
/// <returns></returns>
public void Initialize()
{
try
{
}
catch (System.Exception ex)
{
//LaMethodeDeLog(this.GetType(), System.Reflection.MethodBase.GetCurrentMethod().Name, ex);
MessageBox.Show(ex.Message);
}
finally
{
}
}
/// <summary>
/// Init
/// </summary>
/// <returns></returns>
public void Terminate()
{
try
{
}
catch (System.Exception ex)
{
}
finally
{
}
}
/// <summary>
/// Gabarit Commande AutoCAD
/// </summary>
/// <returns></returns>
[Autodesk.AutoCAD.Runtime.CommandMethod("testapp", "cmdtest", Autodesk.AutoCAD.Runtime.CommandFlags.Transparent)]
public void cmdtest()
{
try
{
string Strlisp = "(setq a 10)";
ResultBuffer res = AcadEvalLisp(Strlisp);
}
catch (System.Exception ex)
{
MessageBox.Show(ex.Message);
}
finally
{
}
}
#region Fonction externe AcedInvoke
// Type of resbuf element
const int RTNONE = 5000; /* No result */
const int RTREAL = 5001; /* Real number */
const int RTPOINT = 5002; /* 2D point X and Y only */
const int RTSHORT = 5003; /* Short integer */
const int RTANG = 5004; /* Angle */
const int RTSTR = 5005; /* String */
const int RTENAME = 5006; /* Entity name */
const int RTPICKS = 5007; /* Pick set */
const int RTORINT = 5008; /* Orientation */
const int RT3DPOINT = 5009; /* 3D point - X, Y, and Z */
const int RTLONG = 5010; /* Long integer */
const int RTVOID = 5014; /* Blank symbol */
const int RTLB = 5016; /* list begin */
const int RTLE = 5017; /* list end */
const int RTDOTE = 5018; /* dotted pair */
const int RTNIL = 5019; /* nil */
const int RTDXF0 = 5020; /* DXF code 0 for ads_buildlist only */
const int RTT = 5021; /* T atom */
const int RTRESBUF = 5023; /* resbuf */
const int RTMODELESS = 5027; /* interrupted by modeless dialog */
// Error return code
const int RTNORM = 5100; /* Request succeeded */
const int RTERROR = -5001; // Some other error
const int RTCAN = -5002; // User cancelled request -- Ctl-C
const int RTREJ = -5003; // AutoCAD rejected request -- invalid
const int RTFAIL = -5004; // Link failure -- Lisp probably died
const int RTKWORD = -5005; // Keyword returned from getxxx() routine
const int RTINPUTTRUNCATED = -5008; // Input didn't all fit in the buffer
[System.Security.SuppressUnmanagedCodeSecurity]
[DllImport("accore.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl, EntryPoint = "?acedEvaluateLisp@@YAHPEB_WAEAPEAUresbuf@@@Z")]
extern public static int acedEvaluateLisp(string lispLine, out IntPtr result);
/// <summary>
/// Evalue une fonction Lisp
/// </summary>
/// <param name="arg">string: Argument de la fonction</param>
/// <returns>ResultBuffer : resultat de buffer</returns>
static public ResultBuffer AcadEvalLisp(string arg)
{
IntPtr rb = IntPtr.Zero;
acedEvaluateLisp(arg, out rb);
if (rb != IntPtr.Zero)
{
try
{
ResultBuffer rbb = DisposableWrapper.Create(typeof(ResultBuffer), rb, true) as ResultBuffer;
return rbb;
}
catch
{
return null;
}
}
return null;
}
#endregion
}
}
///
Solved! Go to Solution.