- UID
- 151438
- 积分
- 440
- 精华
- 贡献
-
- 威望
-
- 活跃度
-
- D豆
-
- 在线时间
- 小时
- 注册时间
- 2004-6-21
- 最后登录
- 1970-1-1
|
发表于 2004-9-13 09:32:57
|
显示全部楼层
RAW MATERIALS.....
Hello Turbosketch,
I have successfully used following three methods:
1) If you want to store a single integer / string / real, you can store it in appropriate 'user' type system variable. (useri1-5, users1-5, userr1-5). The values can be stored manually in the drawing or through lisp or VBA. They are also available in all the three modes. You can thus store 15 individual values (5 max of each type).
2) Pass parameters between lisp and VBA routines.
3) Store as xrecords in user created dictionaries. Using this method, you can permanently store values in a drawing so that they are available in different sessions.
4) Storing a list of objects (as in selection sets) presents special problem. I have overcome this by creating a single concatenated string of object handles with a separator and storing this string using one of the above three methods.
I hope this helps.
Sanjay Kulkarni.
Re:
Hello,
There does not seem to be a simple, straightforward, generalized solution for transferring arrays to from VBA to AutoLISP.
It seems that you need write code for each specific array.
The first hurdle is that AutoLISP does not have arrays. So, you export an array as a list (a list of lists in case of multidimensional arrays.)
Here is a sample code:
Sub array2lst()
Dim Array1(2)
Dim Array2
Dim iElements As Integer
Dim sList As String
Dim iKounter As Integer
' Craeting arrays
Array1(0) = 1
Array1(1) = "A"
Array1(2) = 2.5
Array2 = Array(1, "A", 2.5)
''' Converting Array to string
iElements = UBound(Array1)
sList = "("
For iKounter = 0 To iElements
If TypeName(Array1(iKounter)) = "Straing" Then
sList = sList & Chr(34) & Array1(iKounter) & Chr(34)
Else
sList = sList & Array1(iKounter)
End If
sList = sList & " "
Next
sList = sList & ")"
''' Passing string to Lisp
SendCommand "(getArray " & sList & ")"
' where getarray is an AutoLISP function:
' (defun getArray (lst)
' (setq x (nth lst 0))
' )
End Sub
Hope this helps.
Sanjay Kulkarni.
Data transfer between Lisp and VBA using Vlisp's ActiveX (4 replies)
Posted by: Russ, Kiwi
Date: Jul/28/02 - 21:32 (GMT)
I would like to know how to use ActiveX to transfer data via vlisp to VBA.
Frank Oquendo has written an interesting article on his web site at
http://acadx.com (under articles)
"transferring Data between AutoLISP and VBA". He notes 4 options(amoungst
others) to do this:
1) USER1 etc system
variables
2)Text files
3) the registry
4)ActiveX interface
"The direct route"
For me I would like to use "ActiveX interface" method. Here is his
description:
-------------------start article-----------------------------------
Option #4: The direct route
VisualLISP has an ActiveX interface that you can use directly from any
ActiveX enabled client, including VBA. There is no official documentation on
it and the type library is less than helpful so this approach is a bit
harder to implement than most. Fortunately, the hard part has already been
done for you in the form of VLAX.cls (available from you know where). Using
the SetLispSymbol method creates a global variable that can be read from
AutoLISP while GetLispSymbol allows you to read a variable initialized by
AutoLISP. Here's an example:In VBA:
Dim obj As VLAX Set obj = New VLAX obj.SetLispSymbol "test", 5
In AutoLISP, you would just use the symbol TEST which is now bound to 5.
It's that easy. As an added benefit, if the variable you pass to
SetLispSymbol is an array, that array becomes a list in AutoLISP. You can
create nested lists in VBA by embedding arrays withing arrays. However, you
are limited to reading unnested lists using VLAX's GetLispList method. You
can work around this limitation by using EvalLispExpression to excute any
number of list handling functions such as CAR/CDR and NTH.
---------------end article----------------------------------------
What I don't understand is how do I use the vlax function in vlisp to setq
the value(test)? He says that it is written in the form of VLAX.cls with a
link to another site, but I can't access the site. I also don't know what he
means by "from you know where". Does he mean the help file? I have looked in
the help file but to me its not much help.
So how would I make the variable "test" in vlisp compatiable with the
equivalent vba?
Thanks for any help
Russ |
|