Author Topic: How to run lisp program except for SendStringToExcecute?  (Read 14353 times)

0 Members and 1 Guest are viewing this topic.

It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8690
  • AKA Daniel
Re: How to run lisp program except for SendStringToExcecute?
« Reply #15 on: May 29, 2010, 09:18:15 AM »
Yep, I went through all those, it's a transition phase that lispers go though  :laugh:

Peter Jamtgaard

  • Guest
Re: How to run lisp program except for SendStringToExcecute?
« Reply #16 on: May 29, 2010, 10:34:22 AM »
I have several others too, and multiple variations on some of them.

I found a lot of other cool things that I am still working on.

Does .NET have a function for (vlax-product-key)?

Peter

gile

  • Gator
  • Posts: 2507
  • Marseille, France
Re: How to run lisp program except for SendStringToExcecute?
« Reply #17 on: May 29, 2010, 12:00:45 PM »
Hi,

I don't know any equivalent to (vlax-product-key), but it's quite easy to build

Code: [Select]
private string GetProductKey()
{
    string result = "HKEY_CURRENT_USER\\Software\\Autodesk\\AutoCAD\\";
    result += (string)Registry.GetValue(result, "CurVer", "");
    return result + "\\" + (string)Registry.GetValue(result, "CurVer", "");
}
Speaking English as a French Frog

It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8690
  • AKA Daniel
Re: How to run lisp program except for SendStringToExcecute?
« Reply #18 on: May 29, 2010, 12:05:02 PM »
HostApplicationServices.Current.RegistryProductRootKey


Peter Jamtgaard

  • Guest
Re: How to run lisp program except for SendStringToExcecute?
« Reply #19 on: June 01, 2010, 05:57:52 PM »
acedEvaluateLISP arx entry point example

Peter

Code: [Select]
Imports Autodesk.AutoCAD.DatabaseServices
Imports Autodesk.AutoCAD.Runtime
Imports System.Runtime.InteropServices 'for DllImport()
Imports System.Security

Public Class vbvlClass
    ' Use P/Invoke for acedEvaluateLISP
    <System.Security.SuppressUnmanagedCodeSecurity(), DllImport("acad.exe", _
    CharSet:=CharSet.Unicode, CallingConvention:=CallingConvention.Cdecl, EntryPoint:="?acedEvaluateLisp@@YAHPB_WAAPAUresbuf@@@Z")> _
    Private Shared Function acedEvaluateLISP(ByVal strLISPExpression As String, ByRef intHandle As IntPtr) As Integer
    End Function
    '______________________________________________________________________________________________________________________
    '
    ' Overload of the EvaluateLISPExpression function to accept ResultBuffer as Argument
    '______________________________________________________________________________________________________________________

    <LispFunction("EvaluateLisp")> _
    Public Shared Function EvaluateLispExpression(ByVal rbfLISPExpression As ResultBuffer) As ResultBuffer
        Dim rbfReturn As New ResultBuffer
        Dim arrLispExpression As TypedValue() = rbfLISPExpression.AsArray
        Return EvaluateLispExpression(arrLispExpression(0).Value.ToString)
    End Function

    Public Shared Function EvaluateLispExpression(ByVal strLISPExpression As String) As ResultBuffer
        Dim rbfObject As IntPtr = IntPtr.Zero
        Dim rbfReturn As New ResultBuffer
        Try
            acedEvaluateLISP(strLISPExpression, rbfObject)
            If (rbfObject <> IntPtr.Zero) Then
                rbfReturn = CType(DisposableWrapper.Create(GetType(ResultBuffer), rbfObject, True), ResultBuffer)
                Return rbfReturn
            Else
                rbfReturn.Add(New TypedValue(&H138D, "Error"))
            End If
        Catch ex As System.Exception
            rbfReturn.Add(New TypedValue(&H138D, "Catch Error"))
            Return rbfReturn
        End Try
        Return Nothing
    End Function
End Class

It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8690
  • AKA Daniel
Re: How to run lisp program except for SendStringToExcecute?
« Reply #20 on: June 01, 2010, 08:14:26 PM »
instead of returning "Catch Error" you ought to return ex.messsage
it will give the user an idea what went wrong

Peter Jamtgaard

  • Guest
Re: How to run lisp program except for SendStringToExcecute?
« Reply #21 on: June 01, 2010, 09:52:46 PM »
OK