Run .NET code in AutoCAD without AutoCAD command or UserForm

surfer96
Advocate

Run .NET code in AutoCAD without AutoCAD command or UserForm

surfer96
Advocate
Advocate

Can .NET code (aimed at creating new geometry) be executed in AutoCAD by simply typing F5 in Visual Studio?

 

Or do you always have to link your code to some "new AutoCAD command" or some "new Windows form" to get it running? Simply typing F5 for testing purposes would avoid the NETLOAD dll-loading and unloading processes.

 

There is a VBA-sample in "Program Files\Autodesk\AutoCAD 20xx\Sample\VBA\drawline.dvb" where you can draw a line in model space (more or less) directly. Although I don't know if the UserForm and its CommandButton are mandatory in that sample?

0 Likes
Reply
Accepted solutions (1)
415 Views
3 Replies
Replies (3)

Ed__Jobe
Mentor
Mentor

To test code in Visual Studio, the dll still has to be NETLOADed. And dll's can't be unloaded. VBA is different in that the IDE is bound to the running instance of AutoCAD automatically. VisualStudio is a separate exe.

 

What I do for VS is add a line to my mnl that loads the test dll. So it is loaded when AutoCAD starts. Then when the testing is done. I change the path from the test dll to the production dll.

Ed


Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
How to post your code.

EESignature

surfer96
Advocate
Advocate
Thanks!
What about the VBA sample? Would that also run directly if its UserForm was omitted?
0 Likes

Ed__Jobe
Mentor
Mentor
Accepted solution

VBA can be executed from the IDE, but that sample would have to be modified so that the functionality in the form was included in the main sub. To add a line, you just need to call ThisDrawing.AddLine() which requires start point and endpoint arguments.

Ed


Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
How to post your code.

EESignature