.NET

Reply
New Member
PasxosC
Posts: 2
Registered: ‎02-09-2012
Message 1 of 4 (1,521 Views)

Windows form based stand alone application

1521 Views, 3 Replies
02-09-2012 03:17 AM

hello,i am new in programming and in my first succesfull attempt i developed a windows form based stand alone application in Vb.net 2010 that calculates all the geometry data needed for a Spur Gear ,my final goal is to send all Calculated data needed in Autocad 2012 and draw automatticly the Spur Gear.

 

1.PNG

 

 2.PNG

 

 

3.PNG

 

At first i started to experiment my self with a simple only task (created a new project only for this) to draw 4 circles with the same center (radius1,2,3,4) in autocad with a simple click of the command button.

The code i used is the following (for 1circle) but it returned a error  like this>>         SendACommandToAutoCAD()-->>Could not load file or assembly 'Acmgd, Version=18.2.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.

 

 

 

Imports Autodesk.AutoCAD.ApplicationServices

Imports Autodesk.AutoCAD.Runtime


Public Class Form1

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        SendACommandToAutoCAD()
    End Sub
    <CommandMethod("SendACommandToAutoCAD")> _
    Public Sub SendACommandToAutoCAD()

        Dim acDoc As Document = Application.DocumentManager.MdiActiveDocument



        '' Draws a circle and zooms to the extents or

        '' limits of the drawing

        acDoc.SendStringToExecute("._circle 2,2,0 4 ", True, False, False)

        acDoc.SendStringToExecute("._zoom _all ", True, False, False)

    End Sub

End Class

 

 

*Expert Elite*
norman.yuan
Posts: 987
Registered: ‎04-27-2009
Message 2 of 4 (1,498 Views)

Re: Windows form based stand alone application

02-09-2012 07:01 AM in reply to: PasxosC

The AutoCAD .NET API Assemblies (acadmgd.dll, acmgd.dll...) CANNOT be used in stand-alone exe app. They can ONLY be used inside AutoCAD (NETLOADed DLLs into AutoCAD).

 

In your case, if you must use a stand-alone app, then you can use Acad COM API to automate AutoCAD. But do not addict to use something like "SendCommand()". Explore Acad COM object model to create/manipulate AutoCAD entities and Acad environment.

 

However, you need to be carefully analyse the app's usability to deside if you want to automate Acad from an external exe or not.

 

For example, if you expect user does the data entry via the forms you provided and sees Acad in action right way, so that user can adjust the entered data, then EXE + automated Acad might not be a best approach in terms of userability, because user needs to constantly make switch between your app and Acad, no to mention possible other apps the user may have to use in the same time. Worse, user may clicked wrong place and accidently closed the running Acad session that automated by your app. So, in this case, it will be far better that your app runs inside AutoCAD, so there is no confusion to the user where he/she is working in. I'd only make EXE + Acad automation as my last option

 

OTH, if user mainly collects data via your app, and mostly make Acad draw something later, then your app can store the entered data somewhere (file, database) and you have code in AutoCAD that reads data in and does the drawing, thus, avoid the out-process AutoCAD automation.

 

New Member
PasxosC
Posts: 2
Registered: ‎02-09-2012
Message 3 of 4 (1,469 Views)

Re: Windows form based stand alone application

02-10-2012 10:16 AM in reply to: PasxosC

thanks for the reply,much appreciated and helpful,now i understand the type of the error,maybe i try another aproach to my problem.

Thanks again

Board Manager
StephenPreston
Posts: 377
Registered: ‎05-22-2006
Message 4 of 4 (1,456 Views)

Re: Windows form based stand alone application

02-10-2012 03:27 PM in reply to: PasxosC

If you want to create a DWG directly from your executable, you could licnese RealDWG - www.autodesk.com/realdwg.

Cheers,

Stephen Preston
Autodesk Developer Network
Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.