C3D 2022, No Function Definition with LispFunction

C3D 2022, No Function Definition with LispFunction

CodeDing
Advisor Advisor
654 Views
4 Replies
Message 1 of 5

C3D 2022, No Function Definition with LispFunction

CodeDing
Advisor
Advisor

Hey All,

 

I'm hoping this can be an easy fix for some of you experts. I'm by no means totally proficient with C#/.NET/Visual Studio yet. Trying to get better. Anyways...

 

In short.. Trying to create a Lisp Function via .NET (C#). I've created some Lisp Functions via this API in the past, but now that I've switched over to Civil 3D I can't seem to get something right?

 

I have a SIMPLE method / function:

using System;
using System.Windows;

using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.Runtime;

namespace Test
{
    public class Testing
    {

        [LispFunction("test")]
        public static void RunTest(ResultBuffer rbArgs)
        {
            Autodesk.AutoCAD.ApplicationServices.Application.ShowAlertDialog("Hello World!");
        }
    }
}

 

There are no build errors:

image.png

 

I believe I have all the correct dependencies referenced:

image.png

 

Yet, when I run the function, it does not exist:

image.png

 

Please can I get some advice to get over this hurdle?

...About:

image.png

 

Best,

~DD

 

0 Likes
Accepted solutions (1)
655 Views
4 Replies
Replies (4)
Message 2 of 5

_gile
Consultant
Consultant

Hi,

Is Copy Local property equal to False for each AutoCAD reference ?



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

0 Likes
Message 3 of 5

CodeDing
Advisor
Advisor

Correct, they are all set to "No".

image.png

0 Likes
Message 4 of 5

norman.yuan
Mentor
Mentor
Accepted solution

@CodeDing ,

 

I think you started a wrong project type with your Visual Studio (2022, it looks to me). I tell this from 2 pictures you attached in your post. 

 

1. The picture in your first post showing the references, it shows as "Dependencies", rather than "References" a it is supposed to be;

2. The picture attached to your reply to @_gile shows "Copy Local" to "No", rather "False" as it is supposed to be.

 

These 2 things indicate that you have chosen the project as .NET Core (.NET5/6), rather than .NET framework (4.7x/8). AutoCAD .NET API CAN ONLY work with .NET Framework, not .NET Core/5/6. You need to recreate your class library project as .NET Framework class library.

 

Norman Yuan

Drive CAD With Code

EESignature

Message 5 of 5

CodeDing
Advisor
Advisor

@norman.yuan ,

 

You are exactly correct. I did not know that. Thank you very much!

 

Best,

~DD

0 Likes