TheSwamp

Code Red => .NET => Topic started by: www1970 on July 21, 2006, 04:51:13 AM

Title: vbnet how to load userdefined autoCAD dll
Post by: www1970 on July 21, 2006, 04:51:13 AM
I used VB NET develop objectArx , then I want to put some common functions in a "MYLIB" dll, load then in other programl, but I tryed N times , failed ! I don't know if to set some things in VBNET, or set the DLL functions to "shared"。please give me a detailed step. thanks before!
english not well :-o
Title: Re: vbnet how to load userdefined autoCAD dll
Post by: www1970 on July 21, 2006, 05:26:34 AM
reinforce more
for example:

a object is:

Imports Autodesk.AutoCAD.ApplicationServices
Imports Autodesk.AutoCAD.EditorInput
Imports Autodesk.AutoCAD.Runtime

Public Class hw
    <Autodesk.AutoCAD.Runtime.CommandMethod("Hello")> _
    Public Shared Sub HelloWorld()
        Application.DocumentManager.MdiActiveDocument.Editor.WriteMessage("Hello World")
    End Sub
End Class

compile to "HW.dll"

the second example :
new a class1 object

first “Add Reference” "HW.dll"

Imports HW
Imports Autodesk.AutoCAD.ApplicationServices
Imports Autodesk.AutoCAD.EditorInput
Imports Autodesk.AutoCAD.Runtime

Public Class Class1
    <Autodesk.AutoCAD.Runtime.CommandMethod("Example")> _
    Public Shared Sub Example()
        Dim exp as HW
       exp.Hello
    End Sub
End Class

Title: Re: vbnet how to load userdefined autoCAD dll
Post by: jonesy on July 21, 2006, 05:44:09 AM
hi www1970, welcome to theswamp.

Unfortunately I know nothing about programming. There are many very good programmers that visit the site on a daily basis, but they havent logged on just yet today. I'm sure someone will be along shortly to help you.

Kind regards
Tracey
Title: Re: vbnet how to load userdefined autoCAD dll
Post by: Kerry on July 21, 2006, 05:59:10 AM
Try exo.HelloWorld  .. which is the name of the method of the hw class.

Hello is the registered command to be used from the command AutoCAD line
Title: Re: vbnet how to load userdefined autoCAD dll
Post by: Glenn R on July 21, 2006, 07:04:16 AM
I don't think that will work as you're trying to call a registered command from another registered command, for some reason...
Title: Re: vbnet how to load userdefined autoCAD dll
Post by: MickD on July 21, 2006, 08:14:13 AM
You should still be able to call the method (HelloWorld in this case) all the same, the command method attribute is just the acad 'export' of the method for the command stack.
I don't know about vb but maybe a 'Set' is required for a new instance of exo??

Or-

if 'shared' is the same as static, you would need to call hw.HelloWorld, not HW which is what he is trying to create that doesn't exist, the class declaration is 'hw'
Title: Re: vbnet how to load userdefined autoCAD dll
Post by: Bob Wahr on July 21, 2006, 08:19:29 AM
Triple Aussied...Nice.

Quadruple if you count Jonesy and subscribe to the belief that Brits are just Aussies who didn't get caught.
Title: Re: vbnet how to load userdefined autoCAD dll
Post by: www1970 on July 21, 2006, 08:27:40 PM
thanks for everyone
though my problem isnot solved,but I am inspired by everybody
Title: Re: vbnet how to load userdefined autoCAD dll
Post by: www1970 on July 21, 2006, 08:46:17 PM
Congratulate! solved

  Public Sub Example()
        Dim exp As HW = New HW
        exp.HelloWorld()
  End Sub

first:     exp.HelloWorld()
second:      New HW

not need define shared
Title: Re: vbnet how to load userdefined autoCAD dll
Post by: Kerry on July 22, 2006, 01:11:36 AM
Try exo.HelloWorld  .. which is the name of the method of the hw class.

Hello is the registered command to be used from the command AutoCAD line

DUH ! I forgot the parenthesis
exo.HelloWorld ( )

now thats a silly thing for an old lisper to do :lol:
Title: Re: vbnet how to load userdefined autoCAD dll
Post by: www1970 on July 23, 2006, 08:17:12 PM
Kerry Brown
not silly,thank you wery much!