Message 1 of 6
slow this thing down...
Not applicable
07-11-2002
12:50 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
i wrote a vb script that opens a drwing and saves it out under a new name,
closes and opens up the newly created drawing. it's basically a work-around
for the saveas command not opening the new file in the current session of
inventor. the script works great and i don't have a problem with it. i
thought that i might convert it to vba...which should have taken me 20
seconds to do. th problem is that i can slow the script down using the sleep
command which delays the program. in vba there is no pause or sleep...only
something modal like a msgbox. when trying to run the vba routine, it dies
at the first msgbox. don't know why. can anyone help?
vbs code...save as a .vbs file, ahve inventor running, double-click the vbs
file...
'*********************************************
'VBScript Start a new drawing using a template for Inventor
Set WshShell = WScript.CreateObject("WScript.Shell")
If WshShell.AppActivate("Autodesk Inventor") then
WshShell.SendKeys "%F"
WshShell.SendKeys "O"
WScript.Sleep 1000
WshShell.SendKeys "aa_dwg_template.idw"
WshShell.SendKeys "{TAB}"
WshShell.SendKeys "{TAB}"
WScript.Sleep 500
WshShell.SendKeys "{ENTER}"
WScript.Sleep 1000
WshShell.SendKeys "%F"
WshShell.SendKeys "A"
WScript.Sleep 1500
MSGBOX "Enter a new filename including the .idw, then press Ok."
WshShell.AppActivate("Autodesk Inventor")
WshShell.SendKeys "{TAB}"
WshShell.SendKeys "{TAB}"
WshShell.SendKeys "{TAB}"
WshShell.SendKeys "{TAB}"
WshShell.SendKeys "{TAB}"
WshShell.SendKeys "{TAB}"
WshShell.SendKeys "{TAB}"
WshShell.SendKeys "{TAB}"
WshShell.SendKeys "{TAB}"
WScript.Sleep 500
WshShell.SendKeys "^c"
WshShell.SendKeys "{TAB}"
WshShell.SendKeys "{TAB}"
WScript.Sleep 500
WshShell.SendKeys "{ENTER}"
WScript.Sleep 2000
WshShell.SendKeys "%F"
WshShell.SendKeys "C"
WScript.Sleep 2000
WshShell.SendKeys "%F"
WshShell.SendKeys "O"
WScript.Sleep 500
WshShell.SendKeys "^v"
WshShell.SendKeys "{TAB}"
WshShell.SendKeys "{TAB}"
WScript.Sleep 500
WshShell.SendKeys "{ENTER}"
WScript.Sleep 2000
MSGBOX "Your new drawing is now open."
else
wscript.quit
end if
'*********************************************
vba code.
'*********************************************
Public Sub StartNewDrawing()
SendKeys "%F"
SendKeys "O"
SendKeys "aa_dwg_template.idw"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{ENTER}"
SendKeys "%F"
SendKeys "A"
MsgBox "Enter a new filename including the .idw, then press Ok."
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "^c"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{ENTER}"
SendKeys "%F"
SendKeys "C"
SendKeys "%F"
SendKeys "O"
SendKeys "^v"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{ENTER}"
MsgBox "Your new drawing is now open."
End Sub
'*********************************************
--
Mark A. Bystry
Engineer
Ziggity Systems, Inc.
mbystry@ziggity.com
closes and opens up the newly created drawing. it's basically a work-around
for the saveas command not opening the new file in the current session of
inventor. the script works great and i don't have a problem with it. i
thought that i might convert it to vba...which should have taken me 20
seconds to do. th problem is that i can slow the script down using the sleep
command which delays the program. in vba there is no pause or sleep...only
something modal like a msgbox. when trying to run the vba routine, it dies
at the first msgbox. don't know why. can anyone help?
vbs code...save as a .vbs file, ahve inventor running, double-click the vbs
file...
'*********************************************
'VBScript Start a new drawing using a template for Inventor
Set WshShell = WScript.CreateObject("WScript.Shell")
If WshShell.AppActivate("Autodesk Inventor") then
WshShell.SendKeys "%F"
WshShell.SendKeys "O"
WScript.Sleep 1000
WshShell.SendKeys "aa_dwg_template.idw"
WshShell.SendKeys "{TAB}"
WshShell.SendKeys "{TAB}"
WScript.Sleep 500
WshShell.SendKeys "{ENTER}"
WScript.Sleep 1000
WshShell.SendKeys "%F"
WshShell.SendKeys "A"
WScript.Sleep 1500
MSGBOX "Enter a new filename including the .idw, then press Ok."
WshShell.AppActivate("Autodesk Inventor")
WshShell.SendKeys "{TAB}"
WshShell.SendKeys "{TAB}"
WshShell.SendKeys "{TAB}"
WshShell.SendKeys "{TAB}"
WshShell.SendKeys "{TAB}"
WshShell.SendKeys "{TAB}"
WshShell.SendKeys "{TAB}"
WshShell.SendKeys "{TAB}"
WshShell.SendKeys "{TAB}"
WScript.Sleep 500
WshShell.SendKeys "^c"
WshShell.SendKeys "{TAB}"
WshShell.SendKeys "{TAB}"
WScript.Sleep 500
WshShell.SendKeys "{ENTER}"
WScript.Sleep 2000
WshShell.SendKeys "%F"
WshShell.SendKeys "C"
WScript.Sleep 2000
WshShell.SendKeys "%F"
WshShell.SendKeys "O"
WScript.Sleep 500
WshShell.SendKeys "^v"
WshShell.SendKeys "{TAB}"
WshShell.SendKeys "{TAB}"
WScript.Sleep 500
WshShell.SendKeys "{ENTER}"
WScript.Sleep 2000
MSGBOX "Your new drawing is now open."
else
wscript.quit
end if
'*********************************************
vba code.
'*********************************************
Public Sub StartNewDrawing()
SendKeys "%F"
SendKeys "O"
SendKeys "aa_dwg_template.idw"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{ENTER}"
SendKeys "%F"
SendKeys "A"
MsgBox "Enter a new filename including the .idw, then press Ok."
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "^c"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{ENTER}"
SendKeys "%F"
SendKeys "C"
SendKeys "%F"
SendKeys "O"
SendKeys "^v"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{ENTER}"
MsgBox "Your new drawing is now open."
End Sub
'*********************************************
--
Mark A. Bystry
Engineer
Ziggity Systems, Inc.
mbystry@ziggity.com