TheSwamp
Code Red => VB(A) => Topic started by: ML 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
-
What about a VBA Layer Merge dvb file?
-
That would be great!
Do you have such a project?
Mark
-
Try this (http://www.theswamp.org/lilly_pond/cmdrduh/MergeLayers.dvb?nossi=1) link
-
It needs some work on the form design, but the functionallity is there. The cancel button should be renamed to Exit or Quit
-
My proxy here at work won't seem to let me get to it.
Anyway you could post the code?
Thanks again
Mark
-
I'm not real concerned about the form
-
Form Code
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
Sub MergeLayers()
Dialog1.Show
End Sub
-
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
-
Do you mean Have a vba routine start a lisp routine?
-
Yes, exactly.
to be honest, i need to start some lisp at the "BeginQuit" event and have no clue yet how to do
-
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.
-
my thought would be something like
sendcommand "(lispcmd)"
You would probably need to make the LISP non-command version (i hope that makes sense)
-
:) 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
-
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
-
Amster,
What did you need to know exactly?
You can access that event at drawiing level (Thisdrawing)
Mark
-
Thanks Mark,
The BeginQuit event was what i needed.