Reputation: 12421
I'm currently in the process of rewriting some old AutoCAD plugins from VBA to VB.NET. As it turns out, a (rather large) part of said plugin is implemented in LISP, and I've been told to leave that be. So the problem became running LISP-code in AutoCAD from .NET. Now, there are a few resources online who explain the process necessary to do so (like this one), but all of them takes for granted that the lisp-files/functions are already loaded. The VBA-function I'm currently scratching my head trying to figure out how to convert does a "(LOAD ""<file>"")"
, and the script is built in such a way that it auto-executes on load (it's a simple script, doesn't register functions, just runs from start to end and does it's thing).
So my question is. How can I load (and thus execute) a lisp-file in autocad from a .NET plugin?
Upvotes: 0
Views: 5148
Reputation: 86600
Ok, there are two ways to sendcommand
via .NET.
The first thing you need to understand is that ThisDocument
doesn't exist in .NET.
ThisDocument
is the document where the VBA code is written, but since your addin is document undependant, it stands alone and you must take the documents from the Application
object.
You access the application with:
Autodesk.AutoCAD.ApplicationServices.Application
If you want to transform it to the same Application object as in VBA, with same methods and functions
using Autodesk.Autocad.Interop;
using Autodesk.Autocad.Interop.Common;
AcadApplication App = (AcadApplication)Autodesk.AutoCAD.ApplicationServices.Application.AcadApplication;
The first application has MdiActiveDocument
, from where you can call the Editor
and send written commands, or call the SendStringToExecute
as said in other answer.
The AcadApplication
has ActiveDocument
(an AcadDocument object that behaves exactly as in VBA).
This document will have the same SendCommand
your VBA has, use it the same way it's done in VBA.
If you can explain better the autoexecute part, I can help with that too.
Upvotes: 1