Jump to content
Developer Wiki and Function Reference Links ×

Getting a handle to a light.


Sam Jones

Recommended Posts

I have been thinking the same thing Sam.

 

I think you have to do a FirstIn3D and check the object types.

 

But I don't think all Light Fixtures have Light Objects in them. I think some/most use an Emitter instead. So you will probably need to check for 3D loci also and then use SetObjectVariableBoolean to turn off the emitter.

 

Or maybe that doesn't work. JBenghiat has said you can't do it. But I am stubborn enough to try and prove it for myself. Or to let you prove it for me. 😉

 

Link to comment

It depends what you want to do with the light. The light that appears in the Viz palette is in the profile group of the object (which is true for all PIO’s that appear in Visualization). This is what allows you to edit the light via Viz and have the modifications persist. (That is, the light doesn’t redraw of every regen). You start with getting a handle to the profile group and then iterate through the objects until you find the light. 
There’s also a light that gets placed inside the object geometry. Due to a myriad of reasons, this geometry is not so easy to parse. Do some exploring with Debug List View. If I remember correctly, the geometry is in the aux list, which means you can access via Python but not VS. But depending on what you are doing, you may not need to access this light. 

Link to comment

Got it for now, but I have only experimented with ETC Source 4 conventionals shiipping with the program.

Entering the profile group and adjusting the light object with SetLightInfo() procedure seems to do the trick.  I'll see what happens when I find a Lighting Device that uses an emitter.

 

Link to comment

Here's a snippet from my own code that I use to toggle whether a light is on or off.  I wrote it to combat the annoying "feature" introduced in VW2022 where new Lighting Device objects defaulted to being "on."  It will take any selected Lighting Device object and toggle the state of the internal light.  It works for standard Light Devices as well as Lighting Devices using the Emitter settings.

 

PROCEDURE ToggleState(h:HANDLE);

{Polls embedded Light object and toggles its on/off state}

	CONST
    
    	kLight = 81;
        kLightOn = 50;

	VAR
	
		h2,lightHd:HANDLE;
		currentState:BOOLEAN;
		
	BEGIN
		selDeviceCount:=selDeviceCount+1;
		h2:=FInGroup(GetCustomObjectProfileGroup(h));
		WHILE(h2<>NIL) DO
			BEGIN
				IF(GetTypeN(h2)=kLight) THEN
					BEGIN
						lightHd:=h2;
						currentState:=GetObjectVariableBoolean(lightHd,kLightOn);
						h2:=NIL;
					END
				ELSE h2:=NextObj(h2);
			END;
		
		SetObjectVariableBoolean(lightHd,kLightOn,NOT currentState);
		ResetObject(h);
	END;

 

Edited by Jesse Cogswell
Link to comment

@Jesse Cogswell Thank you  Jesse!  Setting the object variable seems to have the same efficiency as the SetLightInfo procedure, but looks a little cleaner to me.  I would use your code, but when I found the asdfasd procedure I added adjusting the brightness to the functionality, but I have other uses for that object variable.

I am constantly and presently surprised by the hooks avalable to scripts in the object variable list.  I just wish I could decipher its organization in  a manner that would let me find the hooks I need more easily. 

Link to comment

I've attached a couple other menu commands that I've done in case you want to borrow any other features from them.

 

Set Emitters by Fixture Type:

 

image.thumb.png.daaa6ac52b3207fe54f474e41af1cb76.png

 

This is a command that I wrote to take advantage of new object variables added in VW2020 to deal with emitter settings.  I often use emitters to get more realistic output for Renderworks renderings (don't work in Redshift unfortunately), and was getting frustrated with having to manually input the emitter data every time I changed a fixture type.  This command will detect the selected fixture types and scale a dialog box allowing you to set the emitter settings for each type.  Once you click OK, the settings will be updated for all selected Lighting Device objects.

 

Set Light Levels by Channel:

 

image.thumb.png.da438387429f4e8a3b65ffc1f5f89845.png

 

This command will likewise scale a dialog by number of selected lighting fixtures (up to 100 channels), allowing you to quickly set levels based on a bunch of channels at once.

Set Emitters By Fixture.vsm Set Light Levels by Channel.vsm

  • Like 2
Link to comment

Just flagging some cross-nomenclature here.

@Sam Jones, you're referring to multiple emitters in a lighting device symbol definition. In this case, you're only going to have one render light per cell in the profile group that masters each set of emitters. (You do need to check for multiple lights for multiple cells).

@Jesse Cogswellis referring to the emitter properties of a light object that allow it to behave more realistically.

  • Like 2
Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...