AutoCAD .NET Addin Wizard (AcadNetAddinWizard) is far more than just some templates scattered around. It is a real-wizard-sense wizard, i.e. multi paged, configurable, flexible and intelligent. It also includes various project item wizards, coders, and widgets for AutoCAD .NET programming.
In this article, let us see how the LispFunction Definer of AutoCAD .NET Addin Wizard (AcadNetAddinWizard) can create some localizable LispFunction methods automatically and quickly in any AutoCAD supported languages and cultures.
The LispFunction Definer can be found from the Add New Item UI of both Visual C# and VB.NET of Visual Studio both full-fledged and Express in version both 2008 and 2010. Let’s take the C# of Visual Studio 2010 for an example. The AutoCAD Addin category will appear under the Visual C# Items node of the Installed Templates and its various item wizards including the LispFunction Definer appear in turn in the middle pane:
Here are wizard pages and some sample fill-outs of the LispFunction Definer:
The auto-generated LispFunction methods may look like the following:
#region Namespaces
using System;
using System.Text;
using System.Linq;
using System.Xml;
using System.Reflection;
using System.ComponentModel;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Windows;
using System.Windows.Media.Imaging;
using System.Windows.Forms;
using System.Drawing;
using System.IO;
using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.Runtime;
using Autodesk.AutoCAD.EditorInput;
using Autodesk.AutoCAD.Geometry;
using Autodesk.AutoCAD.Windows;
using MgdAcApplication = Autodesk.AutoCAD.ApplicationServices.Application;
using MgdAcDocument = Autodesk.AutoCAD.ApplicationServices.Document;
using AcWindowsNS = Autodesk.AutoCAD.Windows;
#endregion
namespace Acad2012NetDemoAddinCS
{
public class LispFunctions1
{
[LispFunction("HelloFriends", "LispFunctions1_HelloFriends_ID", "LispFunctions1.chm", "LispFunctions1_HelloFriends_Index")]
public Object HelloFriends_Method(ResultBuffer rb)
{
Database db = HostApplicationServices.WorkingDatabase;
Editor ed = MgdAcApplication.DocumentManager.MdiActiveDocument.Editor;
try
{
using (Transaction tr = db.TransactionManager.StartTransaction())
{
//TODO: add your code below.
Debug.WriteLine("The Lisp function HelloFriends is called.");
tr.Commit();
}
return true; // Change to anything else meaningful if necessary.
}
catch (System.Exception ex)
{
Debug.WriteLine(ex.ToString());
ed.WriteMessage(ex.ToString());
return null;
}
}
[LispFunction("GoodBoy", "LispFunctions1_GoodBoy_ID", "LispFunctions1.chm", "LispFunctions1_GoodBoy_Index")]
public Object GoodBoy_Method(ResultBuffer rb)
{
Database db = HostApplicationServices.WorkingDatabase;
Editor ed = MgdAcApplication.DocumentManager.MdiActiveDocument.Editor;
try
{
using (Transaction tr = db.TransactionManager.StartTransaction())
{
//TODO: add your code below.
Debug.WriteLine("The Lisp function GoodBoy is called.");
tr.Commit();
}
return true; // Change to anything else meaningful if necessary.
}
catch (System.Exception ex)
{
Debug.WriteLine(ex.ToString());
ed.WriteMessage(ex.ToString());
return null;
}
}
}
}
The best part is that resource files in those chosen cultures and languages will be created automatically and properly linked with the localizable LispFunction methods. Here is the German resource table for example:
Give the LispFunction Definer of the leading edge AutoCAD .NET Addin Wizard (AcadNetAddinWizard) a try and you will feel no regret.
Posted by: |