Help to code

Help to code

nucliabrasil
Advocate Advocate
524 Views
2 Replies
Message 1 of 3

Help to code

nucliabrasil
Advocate
Advocate

Hello Companions!
I am migrating from vb6 to vb.net and need a light to resolve an issue. In vb6, in 32bits architecture I create a dll and inside it my forms which are called via menus created by vb6 itself. Well, let's get to the point.
Now I'm developing for autocad on windows 64bits. Is it possible to reuse the dll created in vb6 and recompile it in VS2017? If the answer is positive, how would the lisp code that invokes commands by the prompt look like?
I will post a call just as an example the way I do this in vb6:

(defun c: mycmd (/ echo * acad * vbcls retval)

  (setq echo (getvar "CMDECHO"))
  (setvar "CMDECHO" 0)

  (vl-load-com)
  ; (setq acadObject (vlax-get-acad-object))
  (setq * acad * (vl-catch-all-apply 'vlax-get-acad-object))
  (if (not (vl-catch-all-error-p * acad *))
    progn
      (setq vbcls (vl-catch-all-apply
'vla-GetInterfaceObject
(list * acad * "ProjVB.clsGL"); << clsGL = dll
)
      )
      (if (not (vl-catch-all-error-p vbcls))
progn
(setq retval (vl-catch-all-apply
'vlax-invoke
(list vbcls "SetAcadApp" * acad *)
)
)
(if (not (vl-catch-all-error-p retval))
progn
(vlax-invoke-method vbcls "Show_myForm"); << form created inside the dll

)
)
)
      )
    )
  )

  (if (vl-catch-all-error-p retval)
    (vlax-release-object retval)
  )

  (if (not (= vbcls nil))
    (vlax-release-object vbcls)
  )

  (if (not (= * acad * nil))
    (vlax-release-object * acad *)
  )

  (setvar "CMDECHO" echo)
  (princ)

)

If anyone can help me I will be immensely grateful.

0 Likes
525 Views
2 Replies
Replies (2)
Message 2 of 3

JamesMaeding
Advisor
Advisor

@nucliabrasil

You will be spending more time trying to mix old vb6 dll's into .net, so so don't waste your time on that.

Also, you don't want that kind of complexity, as you cannot debug the code in the dll in VS.

Instead, rewrite the code in .net, preferably c#, and you will get a dll you can load into acad.

The functions that you mark with [CommandMethod("Name")] will run on command line. Its actually easier than old vb6.

I may be the king of mixing .net and lisp, as I have crtitical complicated things in lisp that I have not rewritten, but I did rewrite all my vb6 dll's that used to talk to the acad verticals like civil3d before the .net api was out.


internal protected virtual unsafe Human() : mostlyHarmless
I'm just here for the Shelties

0 Likes
Message 3 of 3

nucliabrasil
Advocate
Advocate

Thanks for clarifyment.

0 Likes