How can I use Scripter to turn off all of my Grapher axes or plots?

This article contains a sample script for selecting all plots or all axes in the open Grapher window and changing visibility. Prompts for plot or axes and visible or invisible.

To run this script:

  1. Copy the script below, or click here to download the BAS file:Select all plots or axes and change visibility.BAS
  2. In a Windows Explorer window, navigate to C:\Program Files\Golden Software\Grapher 13.
  3. Double click on Scripter.exe to launch Scripter.
  4. Press Ctrl+A to select all of the existing lines then press Delete.
  5. If you copied this script, press Ctrl+V to paste it into Scripter. If you downloaded it, click File | Open, select the BAS file from your downloads directory, and click Open.
  6. Click Script | Run to run the script.
     

OR:

  1. Copy the script below.
  2. Open Grapher and turn on the Script Manager by clicking View | Display | Script Manager.
  3. Press Ctrl+A to select all of the existing lines in the Script Manager and then press DELETE.
  4. Press Ctrl+V to paste it into the Script Manager.
  5. Click the Start/Resume icon () in the Script Manager.

*********

Sub Main

'Create Grapher as an Object
Dim Grapher As Object

'Start Grapher
Set Grapher = CreateObject("Grapher.Application")

'Make Grapher visible
Grapher.Visible = True

'Use the existing plot
Set Plot1 = Grapher.Documents.Active

'Prompt for axes or plots
	Begin Dialog UserDialog 350,203 ' %GRID:10,7,1,1
		Text 20,14,330,21,"Do you want to select all axes or all plots?",.Text1
		OptionGroup .Group1
			OptionButton 70,49,90,14,"Axes",.OptionButton1
			OptionButton 180,49,90,14,"Plots",.OptionButton2
		Text 20,91,270,21,"Turn object visibility on or off?",.Text2
		OptionGroup .Group2
			OptionButton 70,126,90,14,"On",.OptionButton3
			OptionButton 170,126,90,14,"Off",.OptionButton4
		CancelButton 130,154,90,21
		OKButton 20,154,90,21
	End Dialog
	Dim dlg As UserDialog
	Dialog dlg

	'What was selected in dialog?
	If dlg.Group1 = 0 Then	'This would be Axes selected
		'Change visibility of all axes
		For i = 1 To Plot1.Shapes.Count
				If Plot1.Shapes.Item(i).Type = grfShapeGraph Then
					For j = 1 To Plot1.Shapes.Item(i).Axes.Count
						If dlg.Group2 = 0 Then 'This would be turn visibility on
							Plot1.Shapes.Item(i).Axes.Item(j).Visible = True
						End If
						If dlg.Group2 = 1 Then ' this would be turn visibility off
							Plot1.Shapes.Item(i).Axes.Item(j).Visible = False
						End If
					Next
				End If
		Next
	End If
	If dlg.Group1 = 1 Then		'This would be Plots selected
		'Select all plots
		For i = 1 To Plot1.Shapes.Count
			If Plot1.Shapes.Item(i).Type = grfShapeGraph Then
				For k = 1 To Plot1.Shapes.Item(i).Plots.Count
					If dlg.Group2 = 0 Then 'This would be turn visibility on
						Plot1.Shapes.Item(i).Plots.Item(k).Visible = True
					End If
					If dlg.Group2 = 1 Then ' this would be turn visibility off
						Plot1.Shapes.Item(i).Plots.Item(k).Visible = False
					End If
				Next
			End If
		Next
	End If


End Sub

 

Updated September 24, 2018

Was this article helpful?
0 out of 0 found this helpful

Comments

0 comments

Please sign in to leave a comment.