Author Topic: vbnet how to load userdefined autoCAD dll  (Read 5900 times)

0 Members and 1 Guest are viewing this topic.

www1970

  • Guest
vbnet how to load userdefined autoCAD dll
« 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

www1970

  • Guest
Re: vbnet how to load userdefined autoCAD dll
« Reply #1 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


jonesy

  • SuperMod
  • Seagull
  • Posts: 15568
Re: vbnet how to load userdefined autoCAD dll
« Reply #2 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
Thanks for explaining the word "many" to me, it means a lot.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: vbnet how to load userdefined autoCAD dll
« Reply #3 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
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

Glenn R

  • Guest
Re: vbnet how to load userdefined autoCAD dll
« Reply #4 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...

MickD

  • King Gator
  • Posts: 3636
  • (x-in)->[process]->(y-out) ... simples!
Re: vbnet how to load userdefined autoCAD dll
« Reply #5 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'
"Programming is really just the mundane aspect of expressing a solution to a problem."
- John Carmack

"Short cuts make long delays,' argued Pippin.”
- J.R.R. Tolkien

Bob Wahr

  • Guest
Re: vbnet how to load userdefined autoCAD dll
« Reply #6 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.
« Last Edit: July 21, 2006, 08:21:13 AM by Bob Wahr »

www1970

  • Guest
Re: vbnet how to load userdefined autoCAD dll
« Reply #7 on: July 21, 2006, 08:27:40 PM »
thanks for everyone
though my problem isnot solved,but I am inspired by everybody

www1970

  • Guest
Re: vbnet how to load userdefined autoCAD dll
« Reply #8 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

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: vbnet how to load userdefined autoCAD dll
« Reply #9 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:
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

www1970

  • Guest
Re: vbnet how to load userdefined autoCAD dll
« Reply #10 on: July 23, 2006, 08:17:12 PM »
Kerry Brown
not silly,thank you wery much!