.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Starting an Unmanaged Application

2 REPLIES 2
Reply
Message 1 of 3
raulpa
266 Views, 2 Replies

Starting an Unmanaged Application

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, 😎
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
2 REPLIES 2
Message 2 of 3
jbooth
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
Message 3 of 3
raulpa
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

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost