Author Topic: Loopy Loop sending me loopy..  (Read 1964 times)

0 Members and 1 Guest are viewing this topic.

hardwired

  • Guest
Loopy Loop sending me loopy..
« on: December 11, 2008, 05:05:17 AM »
Hi,

Can anyone take a look at this code and spot why its not working properly..

Basically, its a small section of a main program i wrote to revise up drawings and this section resets the titleblocks back to default settings. The main form has a listbox showing the layouts, so the user can choose whichever layouts they need to revise or reset..

The code for the ONLY SELECTED ONES part of the routine below works fine (click No from the msgbox), but the Yes option (ALL LAYOUTS) will only do the current layout and not loop through them all, as its supposed to..

The ResetTitleBlocks subroutine just cycles through the attributes of the titleblock and changes them to default values..

The code in question is in red. btw, layoutZ is dim'd as an ACAD LAYOUT..

Code: [Select]
' DELETE REVISION DETAILS..
Private Sub cmdDELETEREVISIONS_Click()
response = MsgBox("Would you like to reset ALL titleblocks or just the selected ones?.." & vbCr & vbCr & "Click Yes to reset ALL layouts or click No to reset only selected layouts..", vbYesNoCancel, "Revision Details Editor..")
    If response = vbCancel Then
        Exit Sub
    End If
    If response = vbNo Then
    ' Loop through the selected layouts..
    For Cx = LBound(SelectedLayouts) + 1 To UBound(SelectedLayouts)
        ThisDrawing.ActiveLayout = ThisDrawing.Layouts(SelectedLayouts(Cx))
        ResetTitleBlocks
    Next Cx
    GoTo RESETEND
[color=red]ElseIf response = vbYes Then
    For Each layoutZ In ThisDrawing.Layouts
        ResetTitleBlocks
    Next layoutZ[/color]
    GoTo RESETEND
End If

RESETEND:
Unload Me
End Sub

Any ideas why its not looping through all the drawing's layouts?

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
Re: Loopy Loop sending me loopy..
« Reply #1 on: December 11, 2008, 08:16:42 AM »
I'd suspect it has something to do with the fact that you are not setting the layouts current ...

You could also make the code a bit more friendly like so:

Code: [Select]
Private Sub cmdDELETEREVISIONS_Click()
  response = MsgBox("Would you like to reset ALL titleblocks or just the selected ones?.." & vbCr & vbCr & "Click Yes to reset ALL layouts or click No to reset only selected layouts..", vbYesNoCancel, "Revision Details Editor..")
  Select Case response
  Case vbCancel
    Exit Sub
  Case vbNo
    ' Loop through the selected layouts..
    For Cx = LBound(SelectedLayouts) + 1 To UBound(SelectedLayouts)
      ThisDrawing.ActiveLayout = ThisDrawing.Layouts(SelectedLayouts(Cx))
      ResetTitleBlocks
    Next Cx
  Case vbYes
    For Each layoutZ In ThisDrawing.Layouts
      ThisDrawing.ActiveLayout = layoutZ
      ResetTitleBlocks
    Next layoutZ
  End Select
  Unload Me
End Sub
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie