Author Topic: LISP AND VBA  (Read 8906 times)

0 Members and 1 Guest are viewing this topic.

ML

  • Guest
LISP AND VBA
« on: March 09, 2005, 02:38:44 PM »
Does anyone know if there is a way to call up and use a lisp routine from within THe VBA Editor?

I wanted to use this layer merge (laymrg) lisp routine from Express Tools  along with my VBA Macro but I don't really want to send a number of commands to the AutoCAD command Line from within THe VBA Module.

This is the only way that I know of to use a LISP routine from within VBA

Any help is appreciated

Mark

David Hall

  • Automatic Duh Generator
  • King Gator
  • Posts: 4075
LISP AND VBA
« Reply #1 on: March 10, 2005, 08:40:29 AM »
What about a VBA Layer Merge dvb file?
Everyone has a photographic memory, Some just don't have film.
They say money can't buy happiness, but it can buy Bacon and that's a close second.
Sometimes the question is more important than the answer. (Thanks Kerry for reminding me)

ML

  • Guest
LISP AND VBA
« Reply #2 on: March 10, 2005, 09:00:49 AM »
That would be great!

Do you have such a project?

Mark

David Hall

  • Automatic Duh Generator
  • King Gator
  • Posts: 4075
LISP AND VBA
« Reply #3 on: March 10, 2005, 09:34:30 AM »
Everyone has a photographic memory, Some just don't have film.
They say money can't buy happiness, but it can buy Bacon and that's a close second.
Sometimes the question is more important than the answer. (Thanks Kerry for reminding me)

David Hall

  • Automatic Duh Generator
  • King Gator
  • Posts: 4075
LISP AND VBA
« Reply #4 on: March 10, 2005, 09:35:35 AM »
It needs some work on the form design, but the functionallity is there.  The cancel button should be renamed to Exit or Quit
Everyone has a photographic memory, Some just don't have film.
They say money can't buy happiness, but it can buy Bacon and that's a close second.
Sometimes the question is more important than the answer. (Thanks Kerry for reminding me)

ML

  • Guest
LISP AND VBA
« Reply #5 on: March 10, 2005, 09:39:41 AM »
My proxy here at work won't seem to let me get to it.

Anyway you could post the code?

Thanks again

Mark

ML

  • Guest
LISP AND VBA
« Reply #6 on: March 10, 2005, 09:40:02 AM »
I'm not real concerned about the form

David Hall

  • Automatic Duh Generator
  • King Gator
  • Posts: 4075
LISP AND VBA
« Reply #7 on: March 10, 2005, 10:13:48 AM »
Form Code

Code: [Select]

Private Sub CancelButton_Click()

End
'ends program

End Sub

Private Sub MergeButton_Click()
Dim BlkCol As Object
Dim BlkObj As Object
Dim Obj As Object
Dim Lay As Object
Dim AttObj As Variant
Dim item As Object
Dim FromLay As String
Dim ToLay As String
Dim reLay As Object
Dim I As Integer
Dim intCount As Integer

   
FromLay = FromLayerList.Text
ToLay = ToLayerList.Text
Set Lay = ThisDrawing.Layers(FromLay)
Set BlkCol = ThisDrawing.Blocks
For Each BlkObj In BlkCol
    If BlkObj.IsLayout = True Then
        For Each Obj In BlkObj
            If Obj.ObjectName = "AcDbBlockReference" Then
                If Obj.HasAttributes = True Then
                    AttObj = Obj.GetAttributes
                    For I = LBound(AttObj) To UBound(AttObj)
                        If AttObj(I).Layer = FromLay Then
                            AttObj(I).Layer = ToLay
                        End If
                    Next
                    AttObj = Obj.GetConstantAttributes
                    For I = LBound(AttObj) To UBound(AttObj)
                        If AttObj(I).Layer = FromLay Then
                            AttObj(I).Layer = ToLay
                        End If
                    Next
                End If
            End If
            If Obj.Layer = FromLay Then
                Obj.Layer = ToLay
            End If
        Next
    Else
        For Each item In BlkObj
            If item.Layer = FromLay Then
                item.Layer = ToLay
            End If
        Next
    End If
Next


If FromLay <> ToLay Then
    If FromLay <> "0" Then
        Lay.Delete
    End If
End If

intCount = FromLayerList.ListCount - 1
For I = intCount To 0 Step -1
If FromLayerList.Selected(I) = True Then
FromLayerList.RemoveItem I
End If
Next

'ThisDrawing.Regen

End Sub

Private Sub UserForm_Initialize()
Dim Lay As Object

For Each Lay In ThisDrawing.Layers
    FromLayerList.AddItem Lay.Name
    ToLayerList.AddItem Lay.Name
Next

End Sub



Module code

Code: [Select]

Sub MergeLayers()
Dialog1.Show
End Sub
Everyone has a photographic memory, Some just don't have film.
They say money can't buy happiness, but it can buy Bacon and that's a close second.
Sometimes the question is more important than the answer. (Thanks Kerry for reminding me)

Amsterdammed

  • Guest
LISP AND VBA
« Reply #8 on: June 03, 2005, 09:13:43 AM »
I just tried the VBA Layer Merge dvb, it's great.

But i would like to join the question: is there a way to start a lisp out of VBA?
Bernd

David Hall

  • Automatic Duh Generator
  • King Gator
  • Posts: 4075
LISP AND VBA
« Reply #9 on: June 03, 2005, 09:35:18 AM »
Do you mean Have a vba routine start a lisp routine?
Everyone has a photographic memory, Some just don't have film.
They say money can't buy happiness, but it can buy Bacon and that's a close second.
Sometimes the question is more important than the answer. (Thanks Kerry for reminding me)

Amsterdammed

  • Guest
LISP AND VBA
« Reply #10 on: June 03, 2005, 10:59:48 AM »
Yes, exactly.

to be honest, i need to start some lisp at the "BeginQuit" event and have no clue yet how to do

David Hall

  • Automatic Duh Generator
  • King Gator
  • Posts: 4075
LISP AND VBA
« Reply #11 on: June 03, 2005, 11:06:11 AM »
I am not a LISP guru, but I think it can be done.  I think you might have to use SendCommand though, which is frowned upon, but sometimes necessary.
Everyone has a photographic memory, Some just don't have film.
They say money can't buy happiness, but it can buy Bacon and that's a close second.
Sometimes the question is more important than the answer. (Thanks Kerry for reminding me)

David Hall

  • Automatic Duh Generator
  • King Gator
  • Posts: 4075
LISP AND VBA
« Reply #12 on: June 03, 2005, 11:08:10 AM »
my thought would be something like

sendcommand "(lispcmd)"

You would probably need to make the LISP non-command version (i hope that makes sense)
Everyone has a photographic memory, Some just don't have film.
They say money can't buy happiness, but it can buy Bacon and that's a close second.
Sometimes the question is more important than the answer. (Thanks Kerry for reminding me)

Amsterdammed

  • Guest
LISP AND VBA
« Reply #13 on: June 03, 2005, 12:37:01 PM »
:) Thanks,

it might be not the most sophisticated solution, but it works. Commands in the lisp do not bother at all.

Do you know anything about how to trigger de event handler for leaving Acad?

Bernd

ML

  • Guest
LISP AND VBA
« Reply #14 on: June 04, 2005, 12:51:17 AM »
Hey CMD, I was able to load The Layer Merge dvb file, it is real nice. Thank you

As far as The calling up a LISP routine from VBA, the solution you guys found is exactly how I started the post :)

I was trying not to use The Send Command over and over

Mark