Jump to content

Windows form based stand alone application


Recommended Posts

Posted

hello,i am new in programming and in my first successful 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 automatically the Spur Gear.

 

1.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

_

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

3.PNG

2.jpg

Posted (edited)

Good Day

 

The best way would be is to define a CommandMethod

The references will be acdbmgd.dll and acmgd.dll

 

http://docs.autodesk.com/ACD/2010/ENU/AutoCAD%20.NET%20Developer's%20Guide/index.html

 

Take NOTE:

 

If you have data on a form - say in a textbox and you would like to use these values in your CommandMethod, The values will unable to be read, you have to define variables and place them in a module to be able to be used and read.

 

I am not an expert maybe someone else reading this can comment.

 

Regards

CaveMan

Edited by CaveMan
Posted

It seems that 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 my case, i must use a stand-alone app, maybe I can use Acad COM API to automate AutoCAD. Therefore i need another approach to my problem!!!

Posted (edited)

sorry about this,maybe my bad English give the impression that i demand something and that i am rude,this wasn't my intention,i only want to learn something new and of course i ask for help from experienced users.

Again Sorry,100%% no intention to demand something or to be rude....

Any Help much appreciated.

Edited by PasxosC
Posted

No worries; perhaps I failed to consider the language difference, so I have deleted my post. :)

 

Perhaps you can use this example from one of my Visual Studio Tools for Office (VSTO) projects to your benefit, to determine if there is an existing process:

 

Sounds like you need to check for an active process, prior to creating a new instance.

 

Here's a VB.NET snippet from one of my projects, for you to pull from:

 

Imports Excel = Microsoft.Office.Interop.Excel
Imports Microsoft.Office.Interop

Imports System.Diagnostics
Imports System.IO

Module FOO

   Sub Excel_Foo()

       Dim xlApp As Excel.Application

       Try
           [color=seagreen]' Look for an existing process, if available getObject[/color]
           If Process.GetProcessesByName("Excel").Length > 0 Then
               xlApp = CType(GetObject(, "Excel.Application"), Excel.Application)
           [color=seagreen]' Else createObject[/color]
           Else
               xlApp = New Excel.Application
           End If

          [color=seagreen] ' <-- Do something[/color]

       Catch ex As Exception

       Finally
           xlApp = Nothing

   End Sub

End Module

 

 

... Separately, once you Get/Create an instance of the AutoCAD Application Object, perhaps the Developer Documentation will better allow you to accomplish your task:

 

AutoCAD .NET Developer's Guide > Create and Edit AutoCAD Entities > Create Objects > Create Curved Objects > Create a Circle Object

Posted

Thanks a lot!!! will study and experiment with the codes above :)

Posted

You're welcome :); I'm no expert, so I hope it is helpful to you.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...