.NET

Reply
Active Contributor
raulpa
Posts: 49
Registered: ‎10-12-2006
Message 1 of 3 (62 Views)

Starting an Unmanaged Application

62 Views, 2 Replies
10-12-2006 06:47 AM
Hi:

I hope somebody can help me. I am trying to create a simple 3D Box in AutoCAD 2007 using VB 2005 and ActiveX. Based on what I have read so far, it appears that I need to create a ComClass template and then use the NETLOAD AutoCAD command to load my unmanaged application. This is what I have for the ComClass template:

_
Public Class ComTFCBuild

#Region "COM GUIDs"
' These GUIDs provide the COM identity for this class
' and its COM interfaces. If you change them, existing
' clients will no longer be able to access the class.
Public Const ClassId As String = "bf4c0501-aede-4435-a7ad-63c8530bdffe"
Public Const InterfaceId As String = "999efde1-1898-48b8-98cc-39c6138b7f13"
Public Const EventsId As String = "efbb0675-80f8-4803-97a5-347501575f7f"
#End Region

' A creatable COM class must have a Public Sub New()
' with no parameters, otherwise, the class will not be
' registered in the COM registry and cannot be created
' via CreateObject.
Public Sub New()
MyBase.New()
End Sub

Public Sub Start()
Dim MyBox As New ClsMyBox
MyBox.Create()
End Sub

End Class

And this is what I have for the ClsMyBox class:

Imports Autodesk.AutoCAD.Interop
Imports Autodesk.AutoCAD.Interop.Common

Public Class ClsMyBox

Public Sub Create()
Dim ObjAcad As New AcadApplication
Dim ThisDrawing As AcadDocument
Dim Obj As Acad3DSolid
Dim ZeroOrgin() As Double = {0, 0, 0}

ObjAcad.Visible = True
ThisDrawing = ObjAcad.ActiveDocument

Obj = ThisDrawing.ModelSpace.AddBox(ZeroOrgin, 2, 4, 8)
End Sub

End Class

Is this the way it is supposed to work? If it is, then how do I tell AutoCAD to use the Start routine after executing the NETLOAD command?

Thanks in advance for your help.

Raul Aguilar
McMichaels Design Group
Distinguished Contributor
jbooth
Posts: 223
Registered: ‎02-17-2006
Message 2 of 3 (62 Views)

Re: Starting an Unmanaged Application

10-12-2006 07:41 AM in reply to: raulpa
You do not need to crete a COM object unless you want to call your code from within an Autocad VBA macro.

I did a quick google search for you, and got this article:
http://through-the-interface.typepad.com/through_the_interface/2006/08/calling_command.html
Active Contributor
raulpa
Posts: 49
Registered: ‎10-12-2006
Message 3 of 3 (62 Views)

Re: Starting an Unmanaged Application

10-12-2006 09:09 AM in reply to: raulpa
Jason:

Thank you very much for your prompt reply. I read the article you pointed me to and things make a lot more sense now. I am finally able to do what I wanted.

Thanks again,

Raul Aguilar

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

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 to get help installing your software.

Ask the Community