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 VB.NET of Visual Studio 2010 for an example. The AutoCAD Addin category will appear under the Common 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"
Imports System.Text
Imports System.Linq
Imports System.Xml
Imports System.Reflection
Imports System.ComponentModel
Imports System.Collections
Imports System.Collections.Generic
Imports System.Diagnostics
Imports System.Windows
Imports System.Windows.Media.Imaging
Imports System.Windows.Forms
Imports System.Drawing
Imports System.IO
Imports Autodesk.AutoCAD.ApplicationServices
Imports Autodesk.AutoCAD.DatabaseServices
Imports Autodesk.AutoCAD.Runtime
Imports Autodesk.AutoCAD.EditorInput
Imports Autodesk.AutoCAD.Geometry
Imports Autodesk.AutoCAD.Windows
Imports MgdAcApplication = Autodesk.AutoCAD.ApplicationServices.Application
Imports MgdAcDocument = Autodesk.AutoCAD.ApplicationServices.Document
Imports AcWindowsNS = Autodesk.AutoCAD.Windows
#End Region
Namespace AcadNetAddinVB1
Public Class LispFunctions1
<LispFunction("HelloFriends", "LispFunctions1_HelloFriends_ID", "LispFunctions1.chm", "LispFunctions1_HelloFriends_Index")> _
Public Function HelloFriends_Method(rb As ResultBuffer) As Object
Dim db As Database = HostApplicationServices.WorkingDatabase
Dim ed As Editor = MgdAcApplication.DocumentManager.MdiActiveDocument.Editor
Try
Using tr As Transaction = db.TransactionManager.StartTransaction()
'TODO: add your code below. 'DEBUG_MSG_BEGIN
Debug.WriteLine("The Lisp function HelloFriends is called.")
'DEBUG_MSG_END
tr.Commit()
End Using
Return True ' Change to anything else meaningful if necessary.
Catch ex As System.Exception
Debug.WriteLine(ex.ToString())
ed.WriteMessage(ex.ToString())
Return Nothing
End Try
End Function
<LispFunction("GoodBoy", "LispFunctions1_GoodBoy_ID", "LispFunctions1.chm", "LispFunctions1_GoodBoy_Index")> _
Public Function GoodBoy_Method(rb As ResultBuffer) As Object
Dim db As Database = HostApplicationServices.WorkingDatabase
Dim ed As Editor = MgdAcApplication.DocumentManager.MdiActiveDocument.Editor
Try
Using tr As Transaction = db.TransactionManager.StartTransaction()
'TODO: add your code below. 'DEBUG_MSG_BEGIN
Debug.WriteLine("The Lisp function GoodBoy is called.")
'DEBUG_MSG_END
tr.Commit()
End Using
Return True ' Change to anything else meaningful if necessary.
Catch ex As System.Exception
Debug.WriteLine(ex.ToString())
ed.WriteMessage(ex.ToString())
Return Nothing
End Try
End Function
End Class
End Namespace
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.
Recent Comments