Author Topic: IronScheme - Stable  (Read 2212 times)

0 Members and 1 Guest are viewing this topic.

MickD

  • King Gator
  • Posts: 3619
  • (x-in)->[process]->(y-out) ... simples!
IronScheme - Stable
« on: April 01, 2015, 03:53:00 AM »
Hi All,
A previous thread had been created some time ago about IronScheme and as I had time today I thought I'd see where it was up to.
IronScheme now has a 'stable' release, a bit of documentation and some examples one of which I have used to create a simple REPL embedded in Bricscad.
Doc's are still thin but I will have a play around and see what I come up with.

This simple example is from this page -> http://ironscheme.codeplex.com/wikipage?title=EmbedIronScheme&referringTitle=Documentation
with the difference being that once I created the project I changed properties to Class Library instead of Application and deleted the App class file, ref'd in the Bricscad lib's and created a Commands class.

Code - C#: [Select]
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using System.Windows;
  7. using System.Windows.Controls;
  8. using System.Windows.Data;
  9. using System.Windows.Documents;
  10. using System.Windows.Input;
  11. using System.Windows.Media;
  12. using System.Windows.Media.Imaging;
  13. using System.Windows.Navigation;
  14. using System.Windows.Shapes;
  15.  
  16. using IronScheme;
  17. using Teigha.Runtime;
  18. using Bricscad.ApplicationServices;
  19.  
  20. namespace ISCad1
  21. {
  22.     public class Commands
  23.     {
  24.         [CommandMethod("ISCHEME")]
  25.         public void ironScheme()
  26.         {
  27.             MainWindow form = new MainWindow();
  28.             form.Show();
  29.         }
  30.     }
  31.  
  32.     public class SchemeHandler
  33.     {
  34.         public object Evaluate(string input)
  35.         {
  36.             return input.Eval(); // calls IronScheme.RuntimeExtensions.Eval(string)
  37.         }
  38.     }
  39.     /// <summary>
  40.     /// Interaction logic for MainWindow.xaml
  41.     /// </summary>
  42.     public partial class MainWindow : Window
  43.     {
  44.         private SchemeHandler _schemeHandler;
  45.         public MainWindow()
  46.         {
  47.             InitializeComponent();
  48.             _schemeHandler = new SchemeHandler();
  49.         }
  50.  
  51.         private void Evaluate_Click(object sender, RoutedEventArgs e)
  52.         {
  53.             DisplayArea.Text = _schemeHandler.Evaluate(Input.Text).ToString();
  54.         }
  55.     }
  56. }
  57.  

Could be interesting! :)
"Short cuts make long delays,' argued Pippin.”
J.R.R. Tolkien

Andrey Bushman

  • Swamp Rat
  • Posts: 864
Re: IronScheme - Stable
« Reply #1 on: April 01, 2015, 04:33:03 AM »
Hi MickD,

What favor of it in AutoCAD? Can it be used for .NET code instead of simple mathematical expressions? AutoCAD loads all .net extensions in the same AppDomain (it is horrible, of course), therefore it is not possible to "reload" .net code in AutoCAD.

Best regards, Andrey

MickD

  • King Gator
  • Posts: 3619
  • (x-in)->[process]->(y-out) ... simples!
Re: IronScheme - Stable
« Reply #2 on: April 01, 2015, 04:51:44 AM »
Hi Andrey,
yes, IronScheme is the .net based version of the Scheme Lisp language that is runs on the .net runtime and therefore has access to any .net frameworks and libraries (i.e. C#, VB.net)
similar to IronPython, IronRuby et al.

The benefit is that you can have simple text scripts just like autolisp that get read in and 'interpreted' as opposed to being 'loaded'.
This does come with a slight performance penalty as you can call a function say and it would re-read the script in each time the function is called.
BUT
I think it would be possible to cache these functions, this would give you exactly the same performance as a loaded dll.
The real benefit as compared to autolisp is you can use the whole .net framework and the objectARX/BRX .net libraries and develop in a REPL environment, something you can't do at present.
"Short cuts make long delays,' argued Pippin.”
J.R.R. Tolkien

Andrey Bushman

  • Swamp Rat
  • Posts: 864
Re: IronScheme - Stable
« Reply #3 on: April 01, 2015, 05:01:40 AM »
Is it possible, for example, create a Circle instance in the Modal space through IronScheme? What about a Document locking, using (...){...} blocks, or WorkingDatabase switching? Can you show such samples with IronScheme?

MickD

  • King Gator
  • Posts: 3619
  • (x-in)->[process]->(y-out) ... simples!
Re: IronScheme - Stable
« Reply #4 on: April 01, 2015, 05:21:08 AM »
Is it possible, for example, create a Circle instance in the Modal space through IronScheme? What about a Document locking, using (...){...} blocks, or WorkingDatabase switching? Can you show such samples with IronScheme?

No, not yet but I'm sure it's possible. As noted I was just fooling around and will likely do a bit more tomorrow when/if I get time.
.Net is .Net, if you can run in the runtime you can use the runtime and the framework, just have to work out how to do it with IronScheme :)
"Short cuts make long delays,' argued Pippin.”
J.R.R. Tolkien

Andrey Bushman

  • Swamp Rat
  • Posts: 864
Re: IronScheme - Stable
« Reply #5 on: April 01, 2015, 05:31:03 AM »
This is interesting theme. I will be gratefull to you for interesting samples of its using in AutoCAD (or of any CAD system, based on Teigha). I have not free time for gaming with IronScheme, but if I will see usefull and interesting samples, then I will learn it.

Best regards, Andrey.