2024 Technology Preview Program:
Master powerful new features and shape the latest BIM-enabled innovations
2023-07-12 03:09 PM
Is there anyone know with this DG::GetOpenFile() function, how to set its filter to be able to open only .pln or .pla type?
2023-07-13 12:28 AM
mmmh i can't find the GetOpenFile function in the documentation and neither in the DG_Test example.
are you maybe speaking of the Open File Dialog? Something like this:
When yes, the filter system for this dialog ist quite simple:
//OPEN DIALOG UNISTRINGS SETTINGS
const GS::UniString input = "Open Button... =)";
const GS::UniString inputFilter = "Excel Files";
const char* fileExtensions = "xls";
//FILE TYPE MANAGER SETTINGS
FTM::TypeID retID;
FTM::FileTypeManager ftman("xls");
FTM::FileType type(nullptr, fileExtensions, 0, 0, 0);
FTM::TypeID id = FTM::FileTypeManager::SearchForType(type);
if (id == FTM::UnknownType)
id = ftman.AddType(type);
//FILE DIALOG SETTINGS
DG::FileDialog dlg(DG::FileDialog::OpenFile); // Open only 1 file
UIndex i = dlg.AddFilter(id, DG::FileDialog::DisplayExtensions); // Force it on mac...
dlg.SetFilterText(i, inputFilter);
//INIT OF IO LOCATION
IO::Location location;
if (!dlg.Invoke())
{
ACAPI_WriteReport("ERROR IN OPEN FILE DIALOG!", false);
}
else
{
location = dlg.GetSelectedFile();
// with the location you can start working on the file
}
You find this in a modified version in the DG_Test example 😃
2023-07-13
03:19 AM
- last edited on
2023-07-18
04:05 AM
by
Laszlo Nagy
Hi Joel,
From your code below, the fileExtensions parameter can be only "xls". Which recently it could be "xls" or "xlsx", so how could it filter with both format?
//OPEN DIALOG UNISTRINGS SETTINGS
const GS::UniString input = "Open Button... =)";
const GS::UniString inputFilter = "Excel Files";
const char* fileExtensions = "xls";
//FILE TYPE MANAGER SETTINGS
FTM::TypeID retID;
FTM::FileTypeManager ftman("xls");
FTM::FileType type(nullptr, fileExtensions, 0, 0, 0);
2023-07-15 10:56 PM - edited 2023-07-15 10:56 PM
like this:
FTM::FileTypeManager ftMan("Exel Files");
FTM::GroupID gid = ftMan.AddGroup("Excel Old Format");
ftMan.AddType(FTM::FileType("ExcelOld", "xls", ' ', ' ', 0), gid);
FTM::GroupID gid2 = ftMan.AddGroup("Excel New Format");
ftMan.AddType(FTM::FileType("ExcelNew", "xlsx", ' ', ' ', 0), gid2);
DG::FileDialog flDlg(DG::FileDialog::OpenFile);
flDlg.AddFilter(gid);
flDlg.AddFilter(gid2);
results in this:
by the way: The Archicad API has the very cool excel capabilities since the paid version of the libXl library is a part of archicad.