Author Topic: LSharp v2  (Read 17884 times)

0 Members and 1 Guest are viewing this topic.

sinc

  • Guest
Re: LSharp v2
« Reply #30 on: December 05, 2008, 11:01:07 AM »
Yeah, I use Dotfuscator.  Some of the obfuscators are garbage, but Dotfuscator seems to do a pretty good job.  At least, I tried to crack it, and decided I MIGHT be able to do it, but I could tell it would take a lot more work than I felt like doing, or if there's some easy way to do it, it takes someone who knows a lot more about Microsoft stuff than I to manage it.  And that's a good enough protection level for my software.

There's also stuff that compiles your .NET code into an executable file, much like when you compile C++.  They say that thing gives you even more security, but I haven't tried it myself.

It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8659
  • AKA Daniel
Re: LSharp v2
« Reply #31 on: December 05, 2008, 11:30:35 AM »

Why is that? Microsoft released a bunch of new MFC goodies for VS9 && C++ is getting lots of TLC, with C++0x -> lambda expressions, regex , smart pointers etc. great stuff.


Just that Microsoft really seems to be going .NET these days, and the CLI stuff is SO much cleaner than MFC.

True

I used C++/CLI on this project here. 
http://www.theswamp.org/index.php?topic=23943.msg315006#msg315006

Since most forms/Dialogs only need a few types I.e Strings , it’s easy enough to create a couple of wrappers.

It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8659
  • AKA Daniel
Re: LSharp v2
« Reply #32 on: December 07, 2008, 12:43:39 AM »
Well I was able to attach the L# runtime to AutoCAD in a better way. A single instance of the runtime and environment is started on load, this stores the global/local vars and L# functions. Also I can now define a function in L# and  call it from lisp.

I.e.

Code: [Select]
;;;mytest.lsp
(reference "C:\\Program Files\\AutoCAD 2007\\acmgd.dll")
(reference "C:\\Program Files\\AutoCAD 2007\\acdbmgd.dll")

(using "Autodesk.AutoCAD.GraphicsInterface")
(using "Autodesk.AutoCAD.Runtime")
(using "Autodesk.AutoCAD.Windows")
(using "Autodesk.AutoCAD.Geometry")
(using "Autodesk.AutoCAD.EditorInput")
(using "Autodesk.AutoCAD.LayerManager")
(using "Autodesk.AutoCAD.ApplicationServices")
(using "Autodesk.AutoCAD.DatabaseServices")

(def mytest ()
  (prn (Autodesk.AutoCAD.ApplicationServices.Application.GetSystemVariable "date"))
)

And

Code: [Select]
(L#EvalString"(mytest)")

I still need to map the functions in AutoCAD, so in the future I can just call (mytest) and I need to work on returning the correct type


It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8659
  • AKA Daniel
Re: LSharp v2
« Reply #33 on: December 07, 2008, 09:18:29 AM »
I am thinking about using the decorator L#: to define a L# function that is callable from Autolisp. Thoughts? 
How about command function? For now I think command functions will need to wrapped in an Autolisp function..I.e.

Code: [Select]
(defun c:doit()
 (L#:doit)
)

It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8659
  • AKA Daniel
Re: LSharp v2
« Reply #34 on: December 08, 2008, 02:18:07 AM »
Cewl, I was able to map L# functions to AutoCAD. For example I can create a L# file that contains the following code.

Code: [Select]
(def L#DATE ()
  (prn (Autodesk.AutoCAD.ApplicationServices.Application.GetSystemVariable "date"))
)

(def L#CTAB ()
  (prn (Autodesk.AutoCAD.ApplicationServices.Application.GetSystemVariable "CTAB"))
)

(def L#CLAYER ()
  (prn (Autodesk.AutoCAD.ApplicationServices.Application.GetSystemVariable "CLAYER"))
)

Upon loading of the file, all the functions defined by “def” and decorated with L#, will be added to AutoCAD so L# functions can be called within AutoLisp.
I.e

Code: [Select]
(L#LOAD "C:\\test.lsp")

!L#CLAYER

(L#CLAYER)

;;
(defun doit()
 (L#CLAYER)
)

Next, I need to work on passing parameters and accessing global variables  :-o
BTY, the first time a L# function is loaded, Its compiled to MSIL and stored in L#’s environment,
when the function is called from Autolisp, it’s pretty snappy.



It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8659
  • AKA Daniel
Re: LSharp v2
« Reply #35 on: December 08, 2008, 11:03:25 AM »
We have parameters (some)

Code: [Select]
;;;L#
(def L#MBOX (msg title)
  (prn (MessageBox.Show msg title))
)

Code: [Select]
;;;AutoLisp
(L#MBOX "This is a message from AutoLisp" "We Have Parameters")


pkohut

  • Guest
Re: LSharp v2
« Reply #36 on: December 08, 2008, 11:09:01 AM »
What about error handling?  What happens if 2 ints are passed to L#MBOX ?

We have parameters (some)

Code: [Select]
;;;L#
(def L#MBOX (msg title)
  (prn (MessageBox.Show msg title))
)

Code: [Select]
;;;AutoLisp
(L#MBOX "This is a message from AutoLisp" "We Have Parameters")



It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8659
  • AKA Daniel
Re: LSharp v2
« Reply #37 on: December 08, 2008, 11:13:45 AM »
For now, I am throwing the exception messages back as a cons list.
I don’t think I will be able to do a stack trace.


It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8659
  • AKA Daniel
Re: LSharp v2
« Reply #38 on: December 08, 2008, 11:19:07 AM »
My problem is now with types.
Example  It won’t let me pass an integer as a System.Windows.Forms.MessageBoxButtons.YesNo. I have an email out to the author
on this.  :mrgreen:

pkohut

  • Guest
Re: LSharp v2
« Reply #39 on: December 08, 2008, 11:19:44 AM »
I see.

What about C# structs being passed back and forth?  Are they going
to be wrapped in resbufs?  Just thought of 1 more - how would functions
work that pass by reference?

Thanks,
Paul

It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8659
  • AKA Daniel
Re: LSharp v2
« Reply #40 on: December 08, 2008, 11:58:18 AM »
Good questions, and the answer is , I don’t know yet.

Obviously there will be many limitations, given the nature of Autolisp and the types it recognizes,.

In dealing with structs, I assume one would need to write a L# wrapper that would convert lisp parameter(s) or lisp list(s)
to a type that can be consumed by the struct’s constructor.
I.e send a list of 16 doubles to L#, than have L# convert the list to an array to fill a Matrix3d.. This is something I’ll need to try.

I have no idea how, or if it’s even possible to pass by reference in L#  :mrgreen:

Spike Wilbury

  • Guest
Re: LSharp v2
« Reply #41 on: December 08, 2008, 12:38:37 PM »
are you going to emulate what it is now in autolisp/vlisp or just something new that can be added ?

It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8659
  • AKA Daniel
Re: LSharp v2
« Reply #42 on: December 08, 2008, 12:46:04 PM »
are you going to emulate what it is now in autolisp/vlisp or just something new that can be added ?

 No, I am trying to make Vlisp interact with L# so they can be used together.

Spike Wilbury

  • Guest
Re: LSharp v2
« Reply #43 on: December 08, 2008, 01:02:18 PM »
are you going to emulate what it is now in autolisp/vlisp or just something new that can be added ?

 No, I am trying to make Vlisp interact with L# so they can be used together.

thanks Daniel...

wonder how are you going to handle: list's, mapcar's, lambda's and when they have or are made of different types and are deep nested, if end up using as arguments - waiting for see that.

It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8659
  • AKA Daniel
Re: LSharp v2
« Reply #44 on: December 08, 2008, 01:39:22 PM »
are you going to emulate what it is now in autolisp/vlisp or just something new that can be added ?

 No, I am trying to make Vlisp interact with L# so they can be used together.

thanks Daniel...

wonder how are you going to handle: list's, mapcar's, lambda's and when they have or are made of different types and are deep nested, if end up using as arguments - waiting for see that.

me too  :-D