Trying to change/update IES Filename in lightsourc
-
On 08/04/2016 at 05:07, xxxxxxxx wrote:
User Information:
Cinema 4D Version: 16+
Platform: Mac OSX ;
Language(s) : C++ ;---------
Hi,I am trying to set/delete or exchange the filename of an IES file within the photometric tab of a light source.
It seems that I cannot trigger an update of the light source. Even with an deleted Filename it still shows the effect of the previously loaded file.
SetDirty(DIRTYFLAGS_DATA) and EventAdd() does nothing. Any thoughts? -
On 11/04/2016 at 01:49, xxxxxxxx wrote:
Hello,
it seems that these parameters weren't build to be easily edited using code or scripts. One has to set the flag DESCFLAGS_SET_USERINTERACTION to change the LIGHT_PHOTOMETRIC_FILE parameter:
light->SetParameter(LIGHT_TYPE, LIGHT_TYPE_PHOTOMETRIC, DESCFLAGS_SET_0); light->SetParameter(LIGHT_PHOTOMETRIC_UNITS, true, DESCFLAGS_SET_0); light->SetParameter(LIGHT_PHOTOMETRIC_DATA, true, DESCFLAGS_SET_0); light->SetParameter(LIGHT_PHOTOMETRIC_FILE, iseFile, DESCFLAGS_SET_USERINTERACTION); EventAdd();
Please try this to see if it works correctly.
Bet wishes,
Sebastian -
On 11/04/2016 at 04:42, xxxxxxxx wrote:
Hi Sebastian, thank you very much. I give it a try!
-
On 13/04/2016 at 02:19, xxxxxxxx wrote:
Hi Sebastian,
sorry, but still the same result. The IES light just doesn't update.
-
On 13/04/2016 at 09:24, xxxxxxxx wrote:
Hello,
can you provide your source code and some more information on what exactly you are doing?
Best wishes,
Sebastian -
On 15/04/2016 at 02:02, xxxxxxxx wrote:
Here is the relevant part taken from the Message Routine, activated when the user presses a button in the dialog. If a light source has been linked in the dialog already,I planed to update the loaded IES file, so the light source will directly show the new IES file without having to unload and load the edited file manually again. Deleting and loading the IES file through the dialog of the light source works fine of course.
if (dc->id[0].id == PROJECT_IT)
{
BaseObject* PolyHuelle = op->GetDown();
if (PolyHuelle && myData->GetInt32(MY_IES_MODUS) == MY_IES_MODUS_SPLINE)
{
if (PolyHuelle->GetType() == Ospline)
{
Filename Fname;
AutoAlloc <BaseFile> file;
BaseObject* Licht = myData->GetObjectLink(LIGHT_LINK, doc);
if (Licht)
{
if (Licht->IsInstanceOf(Olight))
{
BaseContainer* licht_bc = Licht->GetDataInstance();
if (licht_bc)
{
if ((licht_bc->GetFilename(LIGHT_PHOTOMETRIC_FILE)).GetString() != "")
{
Fname = licht_bc->GetFilename(LIGHT_PHOTOMETRIC_FILE);
}
else
{
Fname.FileSelect(FILESELECTTYPE_ANYTHING, FILESELECT_SAVE, "Save the IES File", "ies");
}
if (Fname.GetString() != "")
{
if (file->Open(Fname, FILEOPEN_WRITE, FILEDIALOG_NONE, BYTEORDER_INTEL, MACTYPE_CINEMA,'ttxt'))
{
// Create the IES data and save the file
// Code was clipped here
// ********************************************
// Update the linked light source
if (licht_bc)
{
// First I delete the old IES file from the light source, as the name of the file wouldn't change by updating the IES data
Licht->SetParameter(LIGHT_PHOTOMETRIC_FILE, Filename(""), DESCFLAGS_SET_USERINTERACTION);
EventAdd();
// Here I try to load the updated IES data and trigger a refresh of the light source
Licht->SetParameter(LIGHT_TYPE, LIGHT_TYPE_PHOTOMETRIC, DESCFLAGS_SET_0);
Licht->SetParameter(LIGHT_PHOTOMETRIC_UNITS, true, DESCFLAGS_SET_0);
Licht->SetParameter(LIGHT_PHOTOMETRIC_DATA, true, DESCFLAGS_SET_0);
Licht->SetParameter(LIGHT_PHOTOMETRIC_FILE, Fname, DESCFLAGS_SET_USERINTERACTION);
EventAdd();
}
}
}
}
}
}
}
} -
On 15/04/2016 at 09:05, xxxxxxxx wrote:
Hello,
the change of LIGHT_TYPE, LIGHT_PHOTOMETRIC_UNITS and LIGHT_PHOTOMETRIC_DATA is needed so that the LIGHT_PHOTOMETRIC_FILE parameter is enabled. If the parameter is not enabled, it cannot be changed.
I guess you talk about the Message() function of a NodeData based plugin? What exactly do you mean with "so the light source will directly show the new IES file without having to unload and load the edited file manually again", can you elaborate on that?
Best wishes,
Sebastian -
On 18/04/2016 at 05:45, xxxxxxxx wrote:
Hi Sebastian,
my plugin is an Object plugin, using a grouped Spline object to create IES files. (Here is the full workflow if you're interested:
)Up to now, the created IES file has to loaded manually to a light source whenever a change was made to the settings, to be able to see the resulting IES effect in the viewport.
I would like the light source to update whenever the user saves an edited version of the IES file (the filename stay the same).
The type of the light source has already been switched to be IES, so I just need the light source to re-read the updated IES file and update. -
On 18/04/2016 at 09:13, xxxxxxxx wrote:
Hello,
as far as I can tell setting the filename should work as described. But I see in your code that you open the file and you don't close the file again. When the filename is set, the light object itself will try to open the given file. I guess that can't work as long as you "Open" the file yourself.
Also, if you re-set the same value to a parameter you can try the flag DESCFLAGS_SET_FORCESET.
Best wishes,
Sebastian