| Author |
Message |
RDAY
Guest
|
Posted:
Fri Jan 21, 2005 4:08 am Post subject:
Running VBA code from tool bar button |
|
|
I have a block of an enclosure back panel that I have divided up into a grid. I use the grid for laying out my components. I placed the lines of the grid in their own layer so I can turn them on or off as needed. Now the fun part. I have hashed together some VBA code that will toggle the layer and there by the grid on and off. I have a toolbar button to run this code. This seems to work but each time I open a new drawing I get a message box informing me that the project is already loaded.
According to the doc in the acad2005.lsp file this should only load at start up. Any ideas?
Thanks for you help.
Button code:
^C^C-vbarun PanelGrid
VBA code:
Sub PanelGrid()
Dim layerObj As AcadLayer
Set layer = ThisDrawing.Layers.Add("PANELGRID")
If layerObj.LayerOn = True Then
layerObj.LayerOn = False
Else: layerObj.LayerOn = True
End If
ThisDrawing.Regen acActiveViewport
End Sub
Lisp I placed in “acad2005.lsp”:
(defun S::STARTUP()
(command "_VBALOAD" "PanelGrid.dvb")
)
|
|
| Back to top |
|
 |
Nathan Taylor
Guest
|
Posted:
Fri Jan 21, 2005 4:54 am Post subject:
Re: Running VBA code from tool bar button |
|
|
ACADLSPASDOC System Variable
Type: Integer
Saved in: Registry
Initial value: 0
Controls whether AutoCAD loads the acad.lsp file into every drawing or just the first drawing opened in an AutoCAD session.
0 Loads acad.lsp into just the first drawing opened in an AutoCAD session
1 Loads acad.lsp into every drawing opened |
|
| Back to top |
|
 |
Oberer
Guest
|
Posted:
Fri Jan 21, 2005 10:54 pm Post subject:
Re: Running VBA code from tool bar button |
|
|
you could also add the dvb to your startup suite, or define the command via lisp to check for the load, then run the macro:
(if it's already loaded, you don't see a thing:) )
'LayoutLayerStateManager
(defun c:LM ()
(vl-vbaload "G:/WARE/vb/Layout Layer Manager.dvb")
(vl-vbarun "LayoutLayerStateManager")
)
|
|
| Back to top |
|
 |
Matt W
Guest
|
Posted:
Fri Jan 21, 2005 11:08 pm Post subject:
Re: Running VBA code from tool bar button |
|
|
And here's my $0.02.
^P^C^C_-vbarun BatchPlot.dvb!modMain.Main;
Loads our batch plotting program, provided it resides in one of the search
paths.
--
I support two teams: The Red Sox and whoever beats the Yankees. |
|
| Back to top |
|
 |
RDAY
Guest
|
Posted:
Mon Jan 24, 2005 6:21 pm Post subject:
Re: Running VBA code from tool bar button |
|
|
I removed the code from the .lsp file and this is what I have now as my button macro.
C^C^P(command "-vbarun" "PanelGrid.dvb!PanelGrid")
This works but I get this each time I run it.
Command: C
Command: -vbarun
Macro name: PanelGrid.dvb!PanelGrid Regenerating model.
Command:
Command: nil
Is there any way to turn off the command line echo whenI run this?
Thanks for all the help. |
|
| Back to top |
|
 |
Paul Richardson
Guest
|
Posted:
Mon Jan 24, 2005 7:01 pm Post subject:
Re: Running VBA code from tool bar button |
|
|
Command "CMDECHO" 0 ?
"RDAY" <nospam@address.withheld> wrote in message
news:3726395.1106572935982.JavaMail.jive@jiveforum2.autodesk.com...
| Quote: | I removed the code from the .lsp file and this is what I have now as my
button macro.
C^C^P(command "-vbarun" "PanelGrid.dvb!PanelGrid")
This works but I get this each time I run it.
Command: C
Command: -vbarun
Macro name: PanelGrid.dvb!PanelGrid Regenerating model.
Command:
Command: nil
Is there any way to turn off the command line echo whenI run this?
Thanks for all the help. |
|
|
| Back to top |
|
 |
James Belshan
Guest
|
Posted:
Mon Jan 24, 2005 8:20 pm Post subject:
Re: Running VBA code from tool bar button |
|
|
^C^C, for two Cancels, instead of C^C
"RDAY" <nospam@address.withheld> wrote...
| Quote: |
C^C^P(command "-vbarun" "PanelGrid.dvb!PanelGrid")
This works but I get this each time I run it.
Command: C
Command: -vbarun |
|
|
| Back to top |
|
 |
RDAY
Guest
|
Posted:
Tue Jan 25, 2005 6:24 pm Post subject:
Re: Running VBA code from tool bar button |
|
|
James,
That takes care of everything but the :nil.
I can live with that.
Thanks to all who have offered help. |
|
| Back to top |
|
 |
Juha
Guest
|
Posted:
Thu Jan 27, 2005 10:01 am Post subject:
Re: Running VBA code from tool bar button |
|
|
Would a (princ) help the nil?
^C^C^P(command "-vbarun" "PanelGrid.dvb!PanelGrid") (princ)
"RDAY" <nospam@address.withheld> wrote in message
news:4976101.1106659474241.JavaMail.jive@jiveforum1.autodesk.com...
| Quote: | James,
That takes care of everything but the :nil.
I can live with that.
Thanks to all who have offered help. |
|
|
| Back to top |
|
 |
arcticad
Guest
|
Posted:
Wed Mar 16, 2005 10:56 pm Post subject:
Re: Running VBA code from tool bar button |
|
|
(VL-VBALOAD (findfile (strcat "c:\myprogram\program.dvb")))
You can use this code to load the program. and it won't give you an error message if you call it twice. |
|
| Back to top |
|
 |
Tim Arheit
Guest
|
Posted:
Thu Mar 17, 2005 6:07 pm Post subject:
Re: Running VBA code from tool bar button |
|
|
On Wed, 16 Mar 2005 17:56:12 GMT, arcticad <nospam@address.withheld>
wrote:
| Quote: | (VL-VBALOAD (findfile (strcat "c:\myprogram\program.dvb")))
You can use this code to load the program. and it won't give you an error message if you call it twice.
|
I just use the following on the tool bar
^C^C-vbarun c:/myprogram/myprogram.dvb!mymodule.myfunction
It will load the program if necessary and call the specified function.
It won't generate any error if you call it twice. (Note the forward
slash '/', you have to do it this way to make it work).
-Tim |
|
| Back to top |
|
 |
Edward Bagby
Guest
|
Posted:
Wed Mar 23, 2005 8:20 pm Post subject:
Re: Running VBA code from tool bar button |
|
|
I usually make a command in my startup lisp file and then add the command
name to the button. this way the user can use the button, the keyboard
command, and can use [enter] to activate the command multiple times.
here is an example I have in my lisp file
; C:InvRenameDrawing
; Rename drawing in database and all records with the drawing name
(defun c:InvRenameDrawing ()
(vl-vbaload "//Ssx_server/cadd_std/Macros/FieldApp.dvb")
(vl-vbarun "InvestigationApp.modMain.ChangeDrawingName")
(princ)
)
"arcticad" <nospam@address.withheld> wrote in message
news:21658938.1110995802719.JavaMail.jive@jiveforum2.autodesk.com...
| Quote: | (VL-VBALOAD (findfile (strcat "c:\myprogram\program.dvb")))
You can use this code to load the program. and it won't give you an error
message if you call it twice. |
|
|
| Back to top |
|
 |
|
|
|
|