Option Explicit
Language="VBSCRIPT"

' COPYRIGTH DASSAULT SYSTEMES 2003

' ***********************************************************************
'   Purpose:		Switch off all the ligths of a product
'
'   Version:		1.0
'   Author:			bmb
'   Languages:		VBScript 
'   Locales:		English 
'   CATIA Level:	V5R11 
' ***********************************************************************


' Main 
Sub CATMain()

	' Get the documents collection
	Dim oCollection As Documents
	Set oCollection = CATIA.Documents

	' test if no document is open
	If 0=oCollection.Count Then 
		msgbox "A product document must be active to execute this macro.", vbOKOnly, "Switch Off Lights"
		Exit Sub
	End If

	 ' Get material library
	Dim oProductDocument As Document
	Set oProductDocument = CATIA.ActiveDocument

	' test if the active document is a product
	If 0=InStr(oProductDocument.Name, ".CATProduct") Then
		msgbox "A product document must be active to execute this macro.", vbOKOnly, "Switch Off Lights"
		Exit Sub
	End If

	' Accessing the Root Product
	Dim oRootProduct As Document
	Set oRootProduct = oProductDocument.Product

	' Accessing the collection of rendering lights
	Dim oLights As RenderingLights
	Set oLights = oRootProduct.GetItem("CATRscRenderingLightVBExt")

	' Declarations
	Dim I As Int
	Dim oLight As RenderingLight

	' Ligths loop
	For I=1 To oLights.Count
		Set oLight = oLights.Item(I)
		oLight.ActiveStatus = 0
	Next

End Sub