Page 1 of 1
Lisp Routine Attempting to pass parameters to VBA Module
Posted: Tue Apr 06, 2004 8:14 am
by ENSIGN
I have a set of toolbars the are linked to LISP Files, and am attempting to pass parameters to a VBA Module But get the following error
Method 'Getstring' of object 'IIcadUtility' Failed
the lisp routine is as follows ;-
(defun c:TestRoutine (/ )
(command "-VBARUN" "TestRtn" "This" "Works")
)
The VBA Routine is as follows ;-
Sub TestRtn()
Dim Txt1 as String
Dim Txt2 as String
Txt1 = Intellicad.ActiveDocument.Utility.GetString(0)
Txt2 = Intellicad.ActiveDocument.Utility.GetString(0)
MsgBox Txt1
MsgBox Txt2
End Sub
This should produce 2 msgboxes saying "This" and then "Works" when the icon is selected. However, the system errors on the line
Txt2 = Intellicad.ActiveDocument.Utility.GetString(0)
Txt1 contains "This", so that works.
Could you please let me know what is the problem.
Posted: Tue Apr 06, 2004 3:53 pm
by John Finlay
ENSIGN,
I am using the latest version of IntelliCAD and this works sometimes on my system.
You are experiencing the difference in speed between Lisp and VBA.
Lisp is an interpretative non-compiled language and VBA is compiled at runtime and executes faster than Lisp.
GetString Method was designed to halt execution of the program and obtain a string at the command prompt from the user.
Using GetString in this manner will produce erratic results depending on the speed of your computer.
I only use Lisp to run VBA programs.
------------------
Regards
John Finlay
Posted: Wed Apr 07, 2004 12:43 am
by ENSIGN
Hi,
I am currently converting software from AutoCAD VBA to IntelliCAD VBA and the above routines allways works in that.
Is there any other way to pass parameters from LISP to VBA as i dont really want a seperate VBA routine for each icon (we have a lot of possible icons)
I usually pass the item type being placed on the CAD along with the start point and an angle of orientation.
ENSIGN
Posted: Wed Apr 07, 2004 3:04 pm
by John Finlay
ENSIGN,
On your toolbar try:
^C^C^C(setq a "Try");(setq b "This");(command "-VBARUN" "Module1.TestLVar" )
In VBA:
Sub TestLVar()
MsgBox "Lisp a = " & IntelliCAD.ActiveDocument.GetLispVariable("a")
MsgBox "Lisp b = " & IntelliCAD.ActiveDocument.GetLispVariable("b")
End Sub
This GetLispVariable was not available in AutoCAD 2000, I am not sure if this has since been added.
------------------
Regards
John Finlay
Posted: Tue Apr 20, 2004 10:26 am
by AHM
Hi,
I think you introduce in your vba routine
on error resume next it works fine I holpe
it help you.
Sub TestRtn()
on error resume next
Dim Txt1 as String
Dim Txt2 as String
Txt1 = Intellicad.ActiveDocument.Utility.GetString(0)
Txt2 = Intellicad.ActiveDocument.Utility.GetString(0)
MsgBox Txt1
MsgBox Txt2
End Sub
<BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by ENSIGN:
<B>I have a set of toolbars the are linked to LISP Files, and am attempting to pass parameters to a VBA Module But get the following error
Method 'Getstring' of object 'IIcadUtility' Failed
the lisp routine is as follows ;-
(defun c:TestRoutine (/ )
(command "-VBARUN" "TestRtn" "This" "Works")
)
The VBA Routine is as follows ;-
Sub TestRtn()
Dim Txt1 as String
Dim Txt2 as String
Txt1 = Intellicad.ActiveDocument.Utility.GetString(0)
Txt2 = Intellicad.ActiveDocument.Utility.GetString(0)
MsgBox Txt1
MsgBox Txt2
End Sub
This should produce 2 msgboxes saying "This" and then "Works" when the icon is selected. However, the system errors on the line
Txt2 = Intellicad.ActiveDocument.Utility.GetString(0)
Txt1 contains "This", so that works.
Could you please let me know what is the problem.</B><HR></BLOCKQUOTE>
Posted: Wed Apr 21, 2004 5:06 am
by John Finlay
AHM,
I generally leave out error trapping out of my answers because it can lead to adding some 60% increase in the amount of code.
This may confuse the issue at hand.
On Error Resume Next is not needed to run my example on the latest version of IntelliCAD.
Are you experiencing difficulties?
------------------
Regards
John Finlay
Posted: Mon Apr 26, 2004 4:33 pm
by AHM
John,
The routine above doesn't work but when
I introduce "on error resume next" this
works fine but I don“t use on error resume...
or another error trapping in my VBA macro
I only make a suggestion
Thanks
AHM