Is it possible to create a single DLL for use with AutoCAD and Inventor

Is it possible to create a single DLL for use with AutoCAD and Inventor

JBerns
Advisor Advisor
687 Views
6 Replies
Message 1 of 7

Is it possible to create a single DLL for use with AutoCAD and Inventor

JBerns
Advisor
Advisor

Community,

 

I am a long-time developer of AutoLISP and Visual LISP code for AutoCAD.
In the last few years, I have developed iLogic code for Inventor.

 

I am expanding to the use of DLL applications.

 

A recent project requires reading customer names from a SQL database.


I have been successful in developing separate code for AutoCAD (AutoLISP) and for Inventor (iLogic/VB.NET) to accomplish the desired customer list.

 

I was able to take the VB.NET code from the Inventor iLogic rule and put it in an AutoCAD DLL.

 

I would prefer, if possible, not to have to manage two DLLs.

 

Would it be possible to develop a single DLL (VB.NET) that could be called by either AutoCAD or Inventor to return this customer list as a string?

 

Thank you for your time and attention. I look forward to your responses.

 

Regards,

Jerry

-----------------------------------------------------------------------------------------
CAD Administrator
Using AutoCAD & Inventor 2025
Autodesk Certified Instructor
Autodesk Inventor 2020 Certified Professional
Autodesk AutoCAD 2017 Certified Professional
0 Likes
688 Views
6 Replies
Replies (6)
Message 2 of 7

a.kouchakzadeh
Advocate
Advocate

I'm not 100% sure but I feel it is possible. a couple of months ago I was dealing with creating an autoloader and in one of the threads some one told me what to do if I want to use a .dll file for both Revit and Autocad.

again I'm not 100% sure about it.

0 Likes
Message 3 of 7

JBerns
Advisor
Advisor

@a.kouchakzadeh,

 

That is good to hear. It seemed possible to me.

 

The next challenge I have in testing this DLL - how do I get the data from the DLL? Easy with Inventor since it is also VB code. For AutoCAD, 99% of our existing code is AutoLISP / Visual LISP.

 

For example, if the DLL creates the customer names as a List(of String), how do I pass the data back to an AutoLISP or Visual LISP variable? How do I pass any argument between the languages?

 

This article, Set or Get Lisp Symbol in .NET,  is from 2014. I tried to implement the code, but have been unsuccessful.

 

I would welcome and appreciate any assistance the Community can offer.

 

 

Regards,

Jerry

 

-----------------------------------------------------------------------------------------
CAD Administrator
Using AutoCAD & Inventor 2025
Autodesk Certified Instructor
Autodesk Inventor 2020 Certified Professional
Autodesk AutoCAD 2017 Certified Professional
0 Likes
Message 4 of 7

_gile
Consultant
Consultant

Hi,

 

The linked code to set a LISP symbol should work with newer AutoCAD versions, the following sample does work:

        public static void SetLispSymbol()
        {
            var doc = Application.DocumentManager.MdiActiveDocument;
            var data = new TypedValue[4] {
                new TypedValue((int)LispDataType.ListBegin),
                new TypedValue((int)LispDataType.Text, "foo"),
                new TypedValue((int)LispDataType.Text, "bar"),
                new TypedValue((int)LispDataType.ListEnd) };
            doc.SetLispSymbol("lst", data);
        }

 

To work, this code needs a DLL which references AutoCAD libraries (at least AcCoreMgd.dll and AcDbMgd.dll).



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

0 Likes
Message 5 of 7

_gile
Consultant
Consultant

On my side, for this kind of task, I would prefer to use three DLLs: one independent DLL only for the database management and two specific DLLs for Inventor and AutoCAD that use the first one to get the data.



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

0 Likes
Message 6 of 7

JBerns
Advisor
Advisor

@_gile,

 

Thanks for the code. I will try to convert it to VB, which I should have mentioned is my familiar language.

I have noticed that more and more .NET code examples are written in C.

Is there a benefit to C versus VB when it comes to DLLs?

Maybe its time to revisit coding with C.

Thanks again, Gilles.

 

Regards,

Jerry

-----------------------------------------------------------------------------------------
CAD Administrator
Using AutoCAD & Inventor 2025
Autodesk Certified Instructor
Autodesk Inventor 2020 Certified Professional
Autodesk AutoCAD 2017 Certified Professional
0 Likes
Message 7 of 7

_gile
Consultant
Consultant

@JBerns  a écrit :

I have noticed that more and more .NET code examples are written in C.

Is there a benefit to C versus VB when it comes to DLLs?


C# and VB codes are both compiled in the same IL (Intermediate Language) so there's no benefit when it comes to DLLs, but as you said, you'll find much more example and relevant help in C# than in VB.



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

0 Likes