Jump to content

Running VBA program from lisp with aurgument list


Recommended Posts

Posted

I have a lisp routine that needs to call a VBA program and pass it an argument. This is what I have.

 
(vl-vbarun (strcat "Gptoolbox.BlnEdit(" gron:lastent ")")) 

It throws no error, but doen't do anything either. Ideas?

Posted

Visual LISP and VBA has incompatable data types and you cannot to call VBA function with lisp argument. You can to organize data interchange by a custom dictionary, therefore it is long and difficult way. May be use one programming language Visual LISP or VBA?

Posted
I have a lisp routine that needs to call a VBA program and pass it an argument. This is what I have.

 
(vl-vbarun (strcat "Gptoolbox.BlnEdit(" gron:lastent ")")) 

It throws no error, but doen't do anything either. Ideas?

 

There is a quick work-aroundif the amount of data is relatively small that you need to send the VBA routine and that is to use the USERS1 through USERS5 system variables. These are defined string variables defined by AutoCAD and available for use through LISP or VBA.

 

In LISP you would do something like:

 

(setvar "USERS1" sometext1)

(setvar "USERS2" sometext2)

(command "-vbaload" "Project")

(command "-vbarun" "BlnEdit")

(command "vbaunload" "Project")

 

and then in VBA you would do:

 

Dim var1, var2 As String

var1 = ThisDrawing.GetVariable("USERS1")

var2 = ThisDrawing.GetVariable("USERS2")

 

With some manipulation of data type, you will be surprised how much info you can send back and forth. Hope this helps.

Posted

> swestbrook60

 

It seems this guy want to call VBA program from this Viasual LISP code: http://www.cadtutor.net/forum/showthread.php?t=27872 . But it no need because he can make the same in VBA.

 

P. S. USERXN variables usage is no good because its opened for any not authorised change. Dictionaries is best way to data transfer.

Posted
> swestbrook60

 

It seems this guy want to call VBA program from this Viasual LISP code: http://www.cadtutor.net/forum/showthread.php?t=27872 . But it no need because he can make the same in VBA.

 

P. S. USERXN variables usage is no good because its opened for any not authorised change. Dictionaries is best way to data transfer.

 

Your correct on both points, but the risk of the data in thre USERSX variables being corrupted are very minimal if any as long as they are treated as such. They are provided by AutoDesk for this particular reason and if you place your data there and then immediately go use that data, you will be safe.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...