Author Topic: LispFunction and DIESEL  (Read 4319 times)

0 Members and 1 Guest are viewing this topic.

MaksimS

  • Guest
LispFunction and DIESEL
« on: May 28, 2007, 09:43:40 AM »
Dear all,

Any ideas on how to pass resulting value of my LispFunction to DIESEL? I'd like to show a menu item (using CUI) depending on the LispFunction result.

Regards,
Maksim Sestic

MaksimS

  • Guest
Re: LispFunction and DIESEL
« Reply #1 on: May 29, 2007, 05:54:26 AM »
:-) Let me be more specific - here's a function that reads/stores given Short to some shared class variable (TestValue). If there's a value passed down to MyValue function via Lisp, then TestValue carries it down the session. Otherwise, it just returns current TestValue. Here it goes:

Code: [Select]
<LispFunction("MyValue")> _
    Public Shared Function MyValue(ByVal resBuf As ResultBuffer) As Object
        Dim m_Result As New ResultBuffer

        If resBuf IsNot Nothing Then
            Dim m_TypedValue() As TypedValue = resBuf.AsArray
            Dim m_Value As Short = CShort(m_TypedValue(0).Value)

            If TestValue <> m_Value Then
                TestValue = m_Value
            End If
        End If

        m_Result.Add(New TypedValue(5003, TestValue))

        Return m_Result
    End Function

Now, it's possible to control menu item appearance via DIESEL, e.g.:

Code: [Select]
$(if,(MyValue),~)Test Item
$(if,$(and,1,$(eval,MyValue)),!.)Test item

Alas, I can't make it work using MyValue Lisp function - somehow DIESEL doesn't evaluate it right. Any ideas on what am I doing wrong here? :-) Maybe the best solution is to somehow promote my LispFunction to system variable accessible via getvar, but I have no clue if this is possible at all.

Regards,
Maksim Sestic
« Last Edit: May 29, 2007, 07:09:14 AM by MaksimS »

TonyT

  • Guest
Re: LispFunction and DIESEL
« Reply #2 on: May 29, 2007, 10:17:27 PM »
Not sure what give you the impression that it
can, but DIESEL can't evaluate LISP expressions.

It can evaluate system variables that can be set
by LISP or any other API, but that's about it for
DIESEL extensibility.

:-) Let me be more specific - here's a function that reads/stores given Short to some shared class variable (TestValue). If there's a value passed down to MyValue function via Lisp, then TestValue carries it down the session. Otherwise, it just returns current TestValue. Here it goes:

Code: [Select]
<LispFunction("MyValue")> _
    Public Shared Function MyValue(ByVal resBuf As ResultBuffer) As Object
        Dim m_Result As New ResultBuffer

        If resBuf IsNot Nothing Then
            Dim m_TypedValue() As TypedValue = resBuf.AsArray
            Dim m_Value As Short = CShort(m_TypedValue(0).Value)

            If TestValue <> m_Value Then
                TestValue = m_Value
            End If
        End If

        m_Result.Add(New TypedValue(5003, TestValue))

        Return m_Result
    End Function

Now, it's possible to control menu item appearance via DIESEL, e.g.:

Code: [Select]
$(if,(MyValue),~)Test Item
$(if,$(and,1,$(eval,MyValue)),!.)Test item

Alas, I can't make it work using MyValue Lisp function - somehow DIESEL doesn't evaluate it right. Any ideas on what am I doing wrong here? :-) Maybe the best solution is to somehow promote my LispFunction to system variable accessible via getvar, but I have no clue if this is possible at all.

Regards,
Maksim Sestic

MaksimS

  • Guest
Re: LispFunction and DIESEL
« Reply #3 on: May 30, 2007, 03:33:28 AM »
I understand, I was just hoping for DIESEL to automagically evaluate it somehow :-)

Tony, is there a way to trick ACAD by "artificially" promoting a value to ACAD's system/environment variable accessible via getvar/getenv?

Regards,
Maksim Sestic

Not sure what give you the impression that it
can, but DIESEL can't evaluate LISP expressions.

It can evaluate system variables that can be set
by LISP or any other API, but that's about it for
DIESEL extensibility.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: LispFunction and DIESEL
« Reply #4 on: May 30, 2007, 06:10:32 AM »

USERI1 to USERI5 ,
USERR1 to USERR5 ,
USERS1 to USERS5 ,  are System Vars. Have you tried to use those ?

access with
Autodesk.AutoCAD.ApplicationServices.Application.GetSystemVariable(string name);
Autodesk.AutoCAD.ApplicationServices.Application.SetSystemVariable(string name,  object value);

may be worth playing with.

... there's nothing magical or artificial about it though, sorry :-(

kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

MaksimS

  • Guest
Re: LispFunction and DIESEL
« Reply #5 on: May 30, 2007, 06:35:40 AM »
Hi Kerry,

I'm aware of ACAD's user variables, still I'm trying not to interfere with them since many applications use them here and there as either permanent or temporary data store. For DIESEL to evaluate one of USERx sysvars I'd need to reserve many of them exclusively, throughout the session.

Controlling menu appearance using DIESEL looks so lightweight, compared to bunch of events I'd need to implement to perform equal effect.

Regards,
Maksim Sestic


USERI1 to USERI5 ,
USERR1 to USERR5 ,
USERS1 to USERS5 ,  are System Vars. Have you tried to use those ?

access with
Autodesk.AutoCAD.ApplicationServices.Application.GetSystemVariable(string name);
Autodesk.AutoCAD.ApplicationServices.Application.SetSystemVariable(string name,  object value);

may be worth playing with.

... there's nothing magical or artificial about it though, sorry :-(