Author Topic: saveman.vba problem.  (Read 5659 times)

0 Members and 1 Guest are viewing this topic.

hudster

  • Gator
  • Posts: 2848
saveman.vba problem.
« on: August 04, 2004, 06:34:55 AM »
I downloaded this from the afralisp website but when I try to run it I get an error message stating

compile error:
case without select case.

can anyone fix this as this is a much better solution than the Autocad autosave function.

Code: [Select]
'<--Start Coding Here
Option Explicit
Private Sub AcadDocument_BeginCommand(ByVal CommandName As String)
Dim OldTime
Dim NewTime
'trigger when user selects
Case "LINE", "PLINE", "ZOOM"
'get the time now
NewTime = (Hour(Time) * 60) + Minute(Time)
'get the time stored in USERI2
OldTime = ThisDrawing.GetVariable("Useri2")
'If the time has not been set
If OldTime = 0 Then
'set the time
ThisDrawing.SetVariable ("Useri2"), NewTime
'then end
End
End If
'if the difference is greater that 15 minutes
If (NewTime - OldTime) > 15 Then
'save the drawing
ThisDrawing.Save
'and then reset Useri2
ThisDrawing.SetVariable ("Useri2"), NewTime
End If
' end of the Select
End Select
End
End Sub
'End Coding Here-->



Cheers
Andy
Revit BDS 2017, 2016, 2015, 2014, AutoCAD 2017, 2016, Navisworks 2017, 2016, BIM360 Glue

Jeff_M

  • King Gator
  • Posts: 4087
  • C3D user & customizer
Re: saveman.vba problem.
« Reply #1 on: August 04, 2004, 11:44:42 AM »
Quote from: Hudster

compile error:
case without select case.

Code: [Select]
'<--Start Coding Here
<snip>
'trigger when user selects
'Add the next line
Select Case Ucase(CommandName)
Case "LINE", "PLINE", "ZOOM"
'get the time now
<snip>


hudster

  • Gator
  • Posts: 2848
saveman.vba problem.
« Reply #2 on: August 04, 2004, 12:17:55 PM »
brilliant, cheers mate :D
Revit BDS 2017, 2016, 2015, 2014, AutoCAD 2017, 2016, Navisworks 2017, 2016, BIM360 Glue

t-bear

  • Guest
saveman.vba problem.
« Reply #3 on: August 04, 2004, 01:12:26 PM »
OK... this is something I've just been asking about in CAD General....so you guys gotta help this old fool out.
Got this from Afralisp:
 
Quote
Stick this coding in a module, save it as "SaveMan.dvb," and add it to your startup suitcase.

What's a "module" and where do I find it?

Once I insert the origional and Jeffs fix, I need to save it to my acad path and load it similar to a lisp routine....right?  If I want to change the prompts that activate it, I edit this part:
Quote
Case "LINE", "PLINE", "ZOOM"
...So far so good.  To change the time difference.....edit:
Quote
If (NewTime - OldTime) > 15 Then
....Now does this part ...
Quote
'save the drawing

ThisDrawing.Save
save to the current dir as a "*.save" file??? Lost again....  Enough for now.  Thanks fellas.

Jeff_M

  • King Gator
  • Posts: 4087
  • C3D user & customizer
saveman.vba problem.
« Reply #4 on: August 04, 2004, 03:49:01 PM »
Quote from: t-bear
OK... this is something I've just been asking about in CAD General....so you guys gotta help this old fool out. OK, I'll try...
Got this from Afralisp:
 
Quote
Stick this coding in a module, save it as "SaveMan.dvb," and add it to your startup suitcase.

What's a "module" and where do I find it?A Module is a portion of the dvb file....In ACAD type VBAMAN, select the New button, then select the Visual Basic Editor button to put you in the editor. Now make sure that the new dvb you just created is highlighted in the left pane, go to the "Insert" menu, select "Module" and you will now have a new Module1 in your dvb. Right click the new module and select "View Code". Now you can place the cursor in the module's code window and paste the code.

Once I insert the origional and Jeffs fix, I need to save it to my acad path and load it similar to a lisp routine....right? Yes & No.....As was suggested, place in the startup suite to load with eash acad session. If I want to change the prompts that activate it, I edit this part:
Quote
Case "LINE", "PLINE", "ZOOM"
...So far so good.  To change the time difference.....edit:
Quote
If (NewTime - OldTime) > 15 Then
Correct!....Now does this part ...
Quote
'save the drawing

ThisDrawing.Save
save to the current dir as a "*.save" file??? No, this just saves the drawing as if you typed "qsave" at the command line.Lost again....  Enough for now.  Thanks fellas.
To save as a different name you'd use the "SaveAs" method which is a little more detailed....path, name, & version must be supplied.

Hope that clears it up a bit,
Jeff

t-bear

  • Guest
saveman.vba problem.
« Reply #5 on: August 04, 2004, 04:11:35 PM »
Thjanks Jeff. That's a big help.  Soon as I get a chance, I'll try this out and let you know how bad I screwed up..... The "thisDrawing.Save" thing threw me. I want it to save as a standard .bak....not a save-as.  As for loading the routine, I always place my "good'ns" in the startup suite.....

hudster

  • Gator
  • Posts: 2848
saveman.vba problem.
« Reply #6 on: August 05, 2004, 03:48:28 AM »
So whats the solution to the saveas dilema, as this would be a better solution.

 I'd rather the drawing savedas to a temp directory rather than overwrite the master drawing, as sometimes I'm only copying from the drawing, or doing some hypothetical editing and don't really want to alter it.
Revit BDS 2017, 2016, 2015, 2014, AutoCAD 2017, 2016, Navisworks 2017, 2016, BIM360 Glue

Spageddie

  • Guest
saveman.vba problem.
« Reply #7 on: August 19, 2004, 11:30:29 PM »
8) Remember...this would be the same as if you selected SAVEAS from the FILE menu......Are you sure you want to do this ??

hendie

  • Guest
saveman.vba problem.
« Reply #8 on: August 20, 2004, 03:39:38 AM »
Quote from: Hudster
So whats the solution to the saveas dilema, as this would be a better solution.

 I'd rather the drawing savedas to a temp directory rather than overwrite the master drawing, as sometimes I'm only copying from the drawing, or doing some hypothetical editing and don't really want to alter it.


ehmn.. exactly what is the saveas dielmna  ?
Autocad in reality does save the drawing to a "temp" directory ~ when you "open" a drawing, Autocad actually creates a copy of the original, then places a lock on the original drawing file so it can't be "edited". When you carry out a save, it deletes the original, replaces it with a copy of the drawing you are actually working on and goes through the process again.
When I think on it, it may not replace the original until you physically close the drawing, but I'm not sure on that point. ~ Anyone use the Revert command ? does it open the drawing as the original or does it only open the drawing back to the last save command ? aha, I just checked ~ it only opens the drawing back to the last save command.
So, everytime you issue a save command, it replaces the original and creates another "copy" for you to work on. simple, no ?

what was the question again ?

hudster

  • Gator
  • Posts: 2848
saveman.vba problem.
« Reply #9 on: August 20, 2004, 03:52:28 AM »
The save as dilema is
Quote
I'd rather the drawing savedas to a temp directory rather than overwrite the master drawing, as sometimes I'm only copying from the drawing, or doing some hypothetical editing and don't really want to alter it
Revit BDS 2017, 2016, 2015, 2014, AutoCAD 2017, 2016, Navisworks 2017, 2016, BIM360 Glue