Author Topic: vbnet how to load userdefined autoCAD dll  (Read 3412 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: 15502
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
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

--> Donate to theSwamp<--

Glenn R

  • Water Moccasin
  • Posts: 1932
  • What idiot child of married cousins wrote this?!
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...
Me

MickD

  • Gator
  • Posts: 3314
  • (x-in)->[process]->(y-out)
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'
Forth is like the Tao: it is a Way, and is realized when followed.
Its fragility is its strength; its simplicity is its direction - Michael Ham

Lao Tzu: “To attain knowledge, add things
every day; to obtain wisdom, remove things every day.”

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:
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

--> Donate to theSwamp<--

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!