Real Time Rendering

Switching off the Lights


This macro shows you how to switch off all the lights of a the current document.

 

switchOFF_Ligths is launched in CATIA. An existing document called "TestLight.CATProduct" must be found in the CATDocView. It needs "Back.CATPart" and "Hole.CATPart".

switchOFF_Ligths.CATScript is located in the CAAScdRscUseCases module. Execute macro (windows only).

 

switchOFF_Ligths includes five steps:

  1. Accessing the Collection of Documents
  2. Accessing the Product Document
  3. Accessing the Root Product
  4. Accessing the Collection of Rendering Lights
  5. Switching off all the Lights

Accessing the Collection of Documents

	' 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
	...

Access the collection of documents and test if it is not empty.

[Top]

Accessing the Product Document

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

	' test if the active document is a material library (CATMaterial)
	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
	...

Access the product document and test if it is really a CATProduct.

[Top]

Accessing the Root Product

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

[Top]

Accessing the Collection of Rendering Lights

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

[Top]

Switching off All the Lights

	...
	' 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
	...

Going through the lights collection and switch off all.

[Top]


In Short

This use case has shown the way of going through a collection and how to change a parameter like the ActiveStatus.

[Top]


Copyright © 1994-2003, Dassault Systèmes. All rights reserved.