slow this thing down...

slow this thing down...

Anonymous
Not applicable
410 Views
5 Replies
Message 1 of 6

slow this thing down...

Anonymous
Not applicable
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
0 Likes
411 Views
5 Replies
Replies (5)
Message 2 of 6

Anonymous
Not applicable
'Add this to your declarations Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)

'then you use it similar to vbs, sleep 1000
Public Sub StartNewDrawing()


SendKeys "%F"
SendKeys "O"

Sleep 1000

SendKeys "aa_dwg_template.idw"
SendKeys "{TAB}"
SendKeys "{TAB}"

Sleep 1000

SendKeys "{ENTER}"


'etc

Mike@RTSWright
0 Likes
Message 3 of 6

Anonymous
Not applicable
ahh. i'll try that. thank-you...

--
Mark A. Bystry
Engineer
Ziggity Systems, Inc.
mbystry@ziggity.com
0 Likes
Message 4 of 6

Anonymous
Not applicable
Did it work, it should have...Mike
0 Likes
Message 5 of 6

Anonymous
Not applicable
yeah, it worked.

--
Mark A. Bystry
Engineer
Ziggity Systems, Inc.
mbystry@ziggity.com
"MDB" wrote in message
news:f0f4fb0.2@WebX.maYIadrTaRb...
> Did it work, it should have...Mike
>
0 Likes
Message 6 of 6

Anonymous
Not applicable
ohh...i added to the vbscript so i could stop it at the start, in case i
clicked the icon on accident...
in vba i would just use a form with a couple of command buttons on it.

'VBScript Start a new drawing using a template for Inventor

'###########################################################################
##
Dim vbNo
vbNo = MsgBox ("Do you want to start a new drawing in Inventor 5.3?", 36,
"AutoDesk Inventor 5.3 Script")
If vbNo = 7 Then
wscript.quit
end if

'###########################################################################
##

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." ,4096
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




--
Mark A. Bystry
Engineer
Ziggity Systems, Inc.
mbystry@ziggity.com
"MDB" wrote in message
news:f0f4fb0.2@WebX.maYIadrTaRb...
> Did it work, it should have...Mike
>
0 Likes