Author Topic: a Suggestion  (Read 38079 times)

0 Members and 1 Guest are viewing this topic.

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: a Suggestion
« Reply #45 on: July 14, 2006, 12:37:51 PM »
Thanks James. I remember that thread now. I believe the genesis of the idea (accessing the VL application from VB) originates with Cyrille Fauvel, not the two sparring in that thread (most of which Anne Brown nuked).
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

TR

  • Guest
Re: a Suggestion
« Reply #46 on: July 14, 2006, 02:05:55 PM »
So I was looking at maybe studying Common Lisp (clisp) as a .Net language, would that work with AutoCad?  I was doing this just because maybe the syntax would be the same as lisp is, so maybe the learning curve won't be as bad.

I suggest you take an hour or two of your time and look into boo. If that doesn't look to bad you can develop AutoCAD apps in it.

T.Willey

  • Needs a day job
  • Posts: 5251
Re: a Suggestion
« Reply #47 on: July 14, 2006, 03:07:37 PM »
So I was looking at maybe studying Common Lisp (clisp) as a .Net language, would that work with AutoCad?  I was doing this just because maybe the syntax would be the same as lisp is, so maybe the learning curve won't be as bad.

I suggest you take an hour or two of your time and look into boo. If that doesn't look to bad you can develop AutoCAD apps in it.
Thanks Tim.  I will have to look at that tonight, kind of busy at work today.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

FengK

  • Guest
Re: a Suggestion
« Reply #48 on: January 03, 2007, 01:48:25 PM »
Can anyone confirm if one can use language like Python to achieve what Tony T did using VBA? I did some testing using Python to interact with vl16.tlb without success.  I always got an error saying "Error in dll".
Thanks.

Mick, this is the original code posting

Written by Tony Tanzillo sometime in the beginning of the 21st Century . . .

Code: [Select]
Private vlapp As Object
Private vlFuncs As Object

Public Function EvalLispExpression(lispStatement As String)

    Dim sym As Object, RET As Object, retVal
   
    Set vlapp = CreateObject("Vl.Application.16")
    Set vlFuncs = vlapp.ActiveDocument.Functions

    Set sym = vlFuncs.Item("read").funcall(lispStatement)
    On Error Resume Next
    retVal = vlFuncs.Item("eval").funcall(sym)
    If Err Then
        EvalLispExpression = ""
    Else
        EvalLispExpression = retVal
    End If

End Function

Public Sub SetLispVar(Symbol As String, Value)
'Dim vlapp As Object
'Dim vlFuncs As Object
Dim vlSet As Object
Dim vSym
Set vlapp = CreateObject("Vl.Application.16")
Set vlFuncs = vlapp.ActiveDocument.Functions
Set vSym = vlFuncs.Item("read").funcall(Symbol)
Set vlSet = vlFuncs.Item("set")
Select Case VarType(Value)
Case vbByte, vbInteger, vbLong
Dim lVal As Long
lVal = Value
vlSet.funcall vSym, lVal
Case vbString
Dim strVal As String
strVal = Value
vlSet.funcall vSym, strVal
Case vbDouble
Dim dblVal As String
dblVal = Value
vlSet.funcall vSym, dblVal
Case vbEmpty
vlSet.funcall vSym, vlFuncs.Item("read").funcall("nil")
Case Else
If IsArray(Value) Then
Dim List As Variant
List = Value
vlSet.funcall vSym, List
Else
vlSet.funcall vSym, Value
End If
End Select
End Sub

Public Function GetLispVar(Symbol As String) As Variant
'Dim vlapp As Object
'Dim vlFuncs As Object
Set vlapp = CreateObject("Vl.Application.16")
Set vlFuncs = vlapp.ActiveDocument.Functions
GetLispVar = vlFuncs.Item("eval").funcall(vlFuncs.Item("read").funcall(Symbol))
End Function

Here are some example uses:

Code: [Select]
If index1 > -1 Then
ws = ListBox1.List(ListBox1.ListIndex)
End If

If index2 > -1 Then
dwg = ListBox2.List(ListBox2.ListIndex)
End If

SetLispVar "jb%WorkingState", ws
SetLispVar "jb%WSXref", dwg