sleep a Macro
CADForums.net Forum Index CADForums.net
Discussion of AutoCAD and other CAD software.
 
 FAQFAQ   MemberlistMemberlist     RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 
Google
 
Web cadforums.net
sleep a Macro

 
Post new topic   Reply to topic    CADForums.net Forum Index -> VBA
Author Message
Eduardo Chávez Vallín
Guest





Posted: Wed Mar 23, 2005 4:23 am    Post subject: sleep a Macro Reply with quote

Hello all

I'm doing a macro. This Macro must generate a DWF of all files on directory
given.

This Macro works good but I need to wait that the DWF is generated to close
file.

Is there a Command that sleep until the file is generated??

I did it

do until (files.dwf)
Loop

But Autocad get blocked

I need something like it

do until (files.dwf)
sleep (10 seconds)
loop

thanks

Back to top
Laurie Comerford
Guest





Posted: Wed Mar 23, 2005 7:39 am    Post subject: Re: sleep a Macro Reply with quote

Hi,

You can set the time to a variable and loop till the current time minus the
variable is a suitable value.

You could also do a file size on the output file and not exit the loop till
the file size was stable.

These may be kludgy, but should work.

Or alternatively you could attempt to do it without "Sendcommand" so the
code runs synchronously.


--

Regards,


Laurie Comerford
www.cadapps.com.au


"Eduardo Chávez Vallín" <lalo_olal@hotmail.com> wrote in message
news:4240a879$1_3@newsprd01...
Quote:
Hello all

I'm doing a macro. This Macro must generate a DWF of all files on
directory given.

This Macro works good but I need to wait that the DWF is generated to
close file.

Is there a Command that sleep until the file is generated??

I did it

do until (files.dwf)
Loop

But Autocad get blocked

I need something like it

do until (files.dwf)
sleep (10 seconds)
loop

thanks
Back to top
Mike Tuersley
Guest





Posted: Wed Mar 23, 2005 8:30 am    Post subject: Re: sleep a Macro Reply with quote

What kind of DWF are you producing? There is no need for a sleep command.,
just follow the paths below:

If it s a single page, then PLOT the dwf and there is no need to wait.

If it is a multi-page and you are using sendcommand with Publish, set a
variable equal to the number of pages the dwf will have. Then have a global
counter that is incremented on every End_Plot event. Keep checking for the
two variables to be equal.

-- Mike
___________________________
Mike Tuersley
___________________________
the trick is to realize that there is no spoon...

Back to top
Matt W
Guest





Posted: Wed Mar 23, 2005 7:21 pm    Post subject: Re: sleep a Macro Reply with quote

KLUDGY. Now there's a word I haven't seen in quite some time.

--
I support two teams: The Red Sox and whoever beats the Yankees.

"Laurie Comerford" <laurie.comerford at I hate Spam.com.au> wrote in message
news:4240d7d3$1_2@newsprd01...
Quote:
Hi,

You can set the time to a variable and loop till the current time minus
the variable is a suitable value.

You could also do a file size on the output file and not exit the loop
till the file size was stable.

These may be kludgy, but should work.

Or alternatively you could attempt to do it without "Sendcommand" so the
code runs synchronously.


--

Regards,


Laurie Comerford
www.cadapps.com.au


"Eduardo Chávez Vallín" <lalo_olal@hotmail.com> wrote in message
news:4240a879$1_3@newsprd01...
Hello all

I'm doing a macro. This Macro must generate a DWF of all files on
directory given.

This Macro works good but I need to wait that the DWF is generated to
close file.

Is there a Command that sleep until the file is generated??

I did it

do until (files.dwf)
Loop

But Autocad get blocked

I need something like it

do until (files.dwf)
sleep (10 seconds)
loop

thanks


Back to top
Eduardo Chávez Vallín
Guest





Posted: Wed Mar 23, 2005 7:31 pm    Post subject: Re: sleep a Macro Reply with quote

Hi MIke

I am producing a single page. these are steps I'm doing:

1. The user give a path where there are X drawings.
2. I Open drawing and I send to Plot DWF.
3. Close Drawing and repeat step 2 until last drawing
3. I get only the first file DWF, the others were not generated
4. I tried to sleep before to plot next drawing until the dwf exist and it's
working but Autocad seems blocked.

Can you help me?

this is the code

For I = 1 To lstArchivo.ListCount
lstArchivo.ListIndex = I - 1
Set oDocAct = Application.Documents.Open(txtFolder.Value & "\" &
lstArchivo.Value, True)
cUltimo = txtFolder.Value & "\" & Left(lstArchivo.Value,
Len(lstArchivo.Value) - 4) & "-model.DWF"
oDocAct.Activate
nListo = 1
Do While nListo
ExportaDWF.GlobalDWF 'Procedure that generate a DWF
nVeces = 0
Do While nVeces < 5
Start = Timer
Do While Timer < Start + 3
Loop
If oSistema.FileExists(cUltimo) Then
nListo = 0
Else
pgrBar.Value = 1 / lstArchivo.ListCount
Me.Repaint
pgrBar.Refresh
End If
nVeces = nVeces + 1
Loop
Loop
End If
oDocAct.Close False
Next I

Thanks for your time


"Mike Tuersley" <mtuersley_NOT_@rand.com> escribió en el mensaje
news:1ky9a2zl7glg8.1u9uxxgmhlid0.dlg@40tude.net...
Quote:
What kind of DWF are you producing? There is no need for a sleep command.,
just follow the paths below:

If it s a single page, then PLOT the dwf and there is no need to wait.

If it is a multi-page and you are using sendcommand with Publish, set a
variable equal to the number of pages the dwf will have. Then have a
global
counter that is incremented on every End_Plot event. Keep checking for the
two variables to be equal.

-- Mike
___________________________
Mike Tuersley
___________________________
the trick is to realize that there is no spoon...
Back to top
Tony Tanzillo
Guest





Posted: Wed Mar 23, 2005 8:11 pm    Post subject: Re: sleep a Macro Reply with quote

A loop that contains nothing but a call to sleep()
is going block AutoCAD until the looping condition
has been met.

The other suggestions you've gotten do not
address that issue.

To allow AutoCAD to continue processing windows
notifications and not appear to be 'blocked', you
can try placing a call to DoEvents() in your loop:

do until (files.dwf)
sleep(1 second)
DoEvents()
loop

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2004/2005
http://www.acadxtabs.com

"Eduardo Chávez Vallín" <lalo_olal@hotmail.com> wrote in message news:4240a879$1_3@newsprd01...
Quote:
Hello all

I'm doing a macro. This Macro must generate a DWF of all files on directory given.

This Macro works good but I need to wait that the DWF is generated to close file.

Is there a Command that sleep until the file is generated??

I did it

do until (files.dwf)
Loop

But Autocad get blocked

I need something like it

do until (files.dwf)
sleep (10 seconds)
loop

thanks
Back to top
Mike Tuersley
Guest





Posted: Wed Mar 23, 2005 8:15 pm    Post subject: Re: sleep a Macro Reply with quote

Hi Eduardo,

Can you post your function ExportaDWF.GlobalDWF?

Without seeing it, there are two possible problems. First is you are
reusing the same dwf name which would cause a problem. Second is when you
plot, you aren't specifying the correct plot command:

ThisDrawing.Plot.PlotToFile "d:\myfile.dwf", "DWF ePlot.pc3"


-- Mike
___________________________
Mike Tuersley
___________________________
the trick is to realize that there is no spoon...
Back to top
Eduardo Chávez Vallín
Guest





Posted: Wed Mar 23, 2005 8:51 pm    Post subject: Re: sleep a Macro Reply with quote

Mike:

this is my code, but I changed the line:
.Plot.PlotToDevice "DWF6 ePlot.pc3" 'Manda la
ventana al archivo
by:
.plot.plotofile cfilename,"DWF6 ePlot.pc3"

and it's generated only the first file.


With ThisDrawing
If .ActiveSpace = acPaperSpace Then
.MSpace = True
.ActiveSpace = acModelSpace
End If

.ActiveLayout.ConfigName = "DWF6 ePlot.pc3"
.ActiveLayout.PlotType = acWindow 'Plotear una
ventana
.ActiveLayout.SetWindowToPlot aInicio, aFin 'Plotea la
Ventana
.ActiveLayout.StandardScale = acScaleToFit 'Encaja en la
Hoja
.ActiveLayout.StyleSheet = "Monochrome.ctb" 'Plumillas de
DWF
.ActiveLayout.CanonicalMediaName =
"ANSI_expand_B_11.00_x_17.00_Inches)"
.ActiveLayout.PlotRotation = ac90degrees 'Gira a 90
Grados
.ActiveLayout.CenterPlot = True
.Plot.PlotToDevice "DWF6 ePlot.pc3" 'Manda la
ventana al archivo

End With



"Mike Tuersley" <mtuersley_NOT_@rand.com> escribió en el mensaje
news:1gq0zd3ss14eg$.ukj1wfdkkqpj.dlg@40tude.net...
Quote:
Hi Eduardo,

Can you post your function ExportaDWF.GlobalDWF?

Without seeing it, there are two possible problems. First is you are
reusing the same dwf name which would cause a problem. Second is when you
plot, you aren't specifying the correct plot command:

ThisDrawing.Plot.PlotToFile "d:\myfile.dwf", "DWF ePlot.pc3"


-- Mike
___________________________
Mike Tuersley
___________________________
the trick is to realize that there is no spoon...
Back to top
Mike Tuersley
Guest





Posted: Wed Mar 23, 2005 10:16 pm    Post subject: Re: sleep a Macro Reply with quote

Try putting all of this code within your calling procedure and don't loop.
out. Also make sure you have Option Explicit called out and don't have any
errant error handlers in place [ie - On Error Resume Next]. Then see what
happens.

-- Mike
___________________________
Mike Tuersley
___________________________
the trick is to realize that there is no spoon...
Back to top
Mike Tuersley
Guest





Posted: Wed Mar 23, 2005 10:19 pm    Post subject: Re: sleep a Macro Reply with quote

Quote:
The other suggestions you've gotten do not
address that issue.

Hmmmm???? I am saying there is no need for sleep, just a while loop to
compare 2 variables which works fine as I use it quite frequently.

Am I missing something, Tony? Or are you saing that sleep is a better
solution [if implemented appropriately]?

-- Mike
___________________________
Mike Tuersley
___________________________
the trick is to realize that there is no spoon...
Back to top
Tony Tanzillo
Guest





Posted: Thu Mar 24, 2005 6:30 am    Post subject: Re: sleep a Macro Reply with quote

"Mike Tuersley" <mtuersley_NOT_@rand.com> wrote in message news:12vmga01qeuop$.14v04tz2avvvo.dlg@40tude.net...
Quote:
The other suggestions you've gotten do not
address that issue.

Hmmmm???? I am saying there is no need for sleep, just a while loop to
compare 2 variables which works fine as I use it quite frequently.

Doing this without yielding processor time to AutoCAD
to process windows notifications will cause it to appear
to be 'locked up'.


--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2004/2005
http://www.acadxtabs.com
Back to top
 
Post new topic   Reply to topic    CADForums.net Forum Index -> VBA All times are GMT
Page 1 of 1

 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum




Windows Server DSP VoIP Electronics New Topics
Powered by phpBB