On 08/04/2016 at 05:07, xxxxxxxx wrote:
Cinema 4D Version: 16+
Platform: Mac OSX ;
Language(s) : C++ ;
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:
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);
Please try this to see if it works correctly.
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:
sorry, but still the same result. The IES light just doesn't update.
On 13/04/2016 at 09:24, xxxxxxxx wrote:
can you provide your source code and some more information on what exactly you are doing?
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.id == PROJECT_IT)
BaseObject* PolyHuelle = op->GetDown();
if (PolyHuelle && myData->GetInt32(MY_IES_MODUS) == MY_IES_MODUS_SPLINE)
if (PolyHuelle->GetType() == Ospline)
AutoAlloc <BaseFile> file;
BaseObject* Licht = myData->GetObjectLink(LIGHT_LINK, doc);
BaseContainer* licht_bc = Licht->GetDataInstance();
if ((licht_bc->GetFilename(LIGHT_PHOTOMETRIC_FILE)).GetString() != "")
Fname = licht_bc->GetFilename(LIGHT_PHOTOMETRIC_FILE);
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
// 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);
// 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);
On 15/04/2016 at 09:05, xxxxxxxx wrote:
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?
On 18/04/2016 at 05:45, xxxxxxxx wrote:
my plugin is an Object plugin, using a grouped Spline object to create IES files. (Here is the full workflow if you're interested: https://youtu.be/WDTtmdZ3xa0 )YouTube-Link
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:
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.