.NET

Reply
Moderator
Alexander.Rivilis
Posts: 1,458
Registered: ‎04-09-2008
Message 21 of 34 (255 Views)

Re: Launching AutoCad Issue

02-13-2013 01:28 PM in reply to: mgorecki

You confused me so much that I can not understand what you need.
I see what you would do:
1. exe-file has to run AutoCAD and load the dll-file in the AutoCAD command NETLOAD
2. dll-to interact with the exe-file and receive data from it. How you do it - I do not know.

Problem of the interaction of two processes unrelated to programming in AutoCAD .NET API

For example: http://www.codeproject.com/Articles/138290/Programming-Memory-Mapped-Files-with-the-NET-Frame
3. exe-file does not need to refer to dll-file.


That's all.


Пожалуйста не забывайте про Утвердить в качестве решения! Утвердить в качестве решения и Give Kudos!Баллы
Please remember to Accept Solution! Accept as Solution and Give Kudos!Kudos

Mentor
mgorecki
Posts: 415
Registered: ‎09-23-2004
Message 22 of 34 (250 Views)

Re: Launching AutoCad Issue

02-13-2013 01:40 PM in reply to: Alexander.Rivilis

Ok I just want to know it this is possible:

1.  I have a .dll that gets called by an exe, that will launch AutoCad ( that part works)

2.  I want it to accept an array argument so that it can create some graphics in the AutoCad session that is now open.

 

Can an exe file pass a dll an argument?  If so, how?

 

The exe is a standalone, and the dll is basically an AutoCad dll.

Moderator
Alexander.Rivilis
Posts: 1,458
Registered: ‎04-09-2008
Message 23 of 34 (241 Views)

Re: Launching AutoCad Issue

02-13-2013 02:07 PM in reply to: mgorecki

>>Ok I just want to know it this is possible:
>>1.  I have a .dll that gets called by an exe, that will launch AutoCad ( that part works)

Why do you need dll-file, if exe-file itself can run AutoCAD? You put me in a deadlock.

>>2.  I want it to accept an array argument so that it can create some graphics in the AutoCad session that is now open.

 The easiest way:

1) write down your’s array to a “file with a specific name” from exe-file.

2) register with dll-file new command in AutoCAD (for example, with name “StartTransArray”)

3) start command “StartTransArray” with exe-file

4) function which registered as command handler read “file with a specific name” and draw graphics to AutoCAD based on this file content.


Пожалуйста не забывайте про Утвердить в качестве решения! Утвердить в качестве решения и Give Kudos!Баллы
Please remember to Accept Solution! Accept as Solution and Give Kudos!Kudos

*Expert Elite*
norman.yuan
Posts: 1,064
Registered: ‎04-27-2009
Message 24 of 34 (238 Views)

Re: Launching AutoCad Issue

02-13-2013 02:18 PM in reply to: mgorecki

Although Alex has replyed...

 

Yes, you can have a DLL, that is called from EXE, to start AutoCAD (but why, I'd ask as Alex asked? Is launching AutoCAD via COM that complicated to deserve a separate DLL project?). In this ccase, the DLL IS PART of the process of the EXE. Thus, you CANNOT use AutoCAD ObjectARX .NET assemblies (acdbmgd/acmgd.dll).

 

 

Mentor
mgorecki
Posts: 415
Registered: ‎09-23-2004
Message 25 of 34 (233 Views)

Re: Launching AutoCad Issue

02-13-2013 02:38 PM in reply to: norman.yuan

Here's the thing; we are going to use a web application that will launch a dll and pass it an array.

That dll will launch AutoCad and run the program using the array as the information it will use to set the variables in the program.

It was not my call to do it this way.

 

The web app developer that is creating the web app is out right now, so I don't have his web app to use to test my code.  So, I was just trying to create a simple exe file to use in it's place until they came back.  They will be gone for 3 weeks and the project needs to be finished in about 4 weeks.  Yay for me :-(

 

That's why I needed the exe to launch the dll which in turn would launch AutoCad and run using the variables passed to it.

Valued Mentor
jeff
Posts: 338
Registered: ‎05-12-2009
Message 26 of 34 (224 Views)

Re: Launching AutoCad Issue

02-13-2013 06:19 PM in reply to: mgorecki

Not sure how you 'launch' a dll, but I am not familiar how but there might be a way to create an entry point for a dll.

 

 

If you have to ship it very soon and just need to get it going the first hack that comes to mind is to serialize the data to the same location as the dll, and have a static initializer  in the class of the first method called that will deserialize the data.

 

Sounds and feels pretty hackish, but maybe searching for "C# dll main" or "Class Library entry point" might turn up some results.

You can also find your answers @ TheSwamp
Valued Mentor
jeff
Posts: 338
Registered: ‎05-12-2009
Message 27 of 34 (216 Views)

Re: Launching AutoCad Issue

02-13-2013 09:15 PM in reply to: jeff

Sorry,

My last post does not make sense and was confrused.

You can also find your answers @ TheSwamp
Distinguished Contributor
alex_b
Posts: 405
Registered: ‎08-15-2003
Message 28 of 34 (204 Views)

Re: Launching AutoCad Issue

02-14-2013 06:55 PM in reply to: mgorecki

Just a thought:

Are you trying to NETLOAD a plugin (dll) into Acad and pass to it an array to use inside Acad?

Mentor
mgorecki
Posts: 415
Registered: ‎09-23-2004
Message 29 of 34 (184 Views)

Re: Launching AutoCad Issue

02-19-2013 11:53 AM in reply to: alex_b

No, I don't think it's possible to pass an array to a program that is loaded using Netload.

I just want to be able to pass an array argument to the .dll.

Mentor
mgorecki
Posts: 415
Registered: ‎09-23-2004
Message 30 of 34 (136 Views)

Re: Launching AutoCad Issue

03-07-2013 02:34 PM in reply to: norman.yuan

Hi Norman,

Thank you for your help (on this and stuff in the past).  Ok we've decided to go another route.  We're going to stick to the text file that the dll will read and get all it's info.  So I've updated the code and all is wonderful, but now they also want me to save and exit AutoCad when the drawing is complete.

 

I have the save part down, but I cannot quit AutoCad as the program was "netloaded".

 

Can you please tell me how to launch AutoCad, create graphics, save and then close AutoCad?  I've read a bunch of things and I know you can launch AutoCad from a dll, but the problem happens when you try to create graphic objects because the launching program doesn't like having a reference to "acdbmgd".

 

This is some of the code I'm using to launch:

<CommandMethod("POD")> _
Public Sub POD()
Const progID As String = "AutoCAD.Application.18" Dim acApp As AcadApplication = Nothing Try ' Get a running instance of AutoCad acApp = DirectCast(Marshal.GetActiveObject(progID), AcadApplication) Catch 'ex As Exception Try Dim acType As Type = Type.GetTypeFromProgID(progID) acApp = DirectCast(Activator.CreateInstance(acType, True), AcadApplication) Catch 'ex2 As Exception If IsProcessRunning("acad") = False Then MsgBox("Cannot create object of type """ & progID & """") Else acApp = DirectCast(Marshal.GetActiveObject(progID), AcadApplication) End If End Try End Try ' AutoCad should be running If acApp IsNot Nothing Then acApp.Visible = True

 I've always used netload, but I know some people can launch AutoCad, do stuff in the drawings, then close the drawings and exit AutoCad.  Can you show me how to do that?  I want to expand past "just netloading".

 

Thanks,

Mark

Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Do you have 60 seconds to spare? The Autodesk Community Team is revamping our site ranking system and we want your feedback! Please click here to launch the 5 question survey. As always your input is greatly appreciated.