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();
}
}
}
}
}
}
}
}