System.ArgumentException in AddFolder Method (IEdmBatchListing)

i completely do not understand why it happens…
i want to get folder variable value…


link to API help: AddFolder Method (IEdmBatchListing) - 2021 - SOLIDWORKS API Help

void AddFolder( 
   System.object oIdOrPath,
   System.int lParam,
   System.int lEdmListFolderFlags
)

problem in System.int lEdmListFolderFlags. i need set to 0, not to 1(recursive folder content). but 0 do not work. only this is work:

BatchListing.AddFolder(FolderID, 0, Convert.ToInt32(EdmListFolderFlags.EdmListFolder_Recursive));

but i do not need folder content…
EdmListFolder_Nothing is not workable, when using it System.ArgumentException is appear…

is where a way to get value from folder variable? it seems to me that somewhere in the examples I have seen how this is done, but I can not find where…

and in visual studio, then typing this method:


says that the third parameter is not required, but the value 0 causes an error

found this method: GetVar2 Method (IEdmEnumeratorVariable10) - 2021 - SOLIDWORKS API Help

in this API help about EnumVar IEdmEnumeratorVariable5 Interface - 2021 - SOLIDWORKS API Help

said:
IEdmEnumeratorVariableN interfaces on the following do not need calls to IEdmEnumeratorVariable8::CloseFile:

  • folders (cast IEdmFolder5 to this interface)

what i do wrong? because an error occurs “the interface is not supported”

private string GetFolderPN(ref IEdmVault5 tmpVault, int FolderID)
        {
            IEdmFolder5 folder = (IEdmFolder5)tmpVault.GetObject(EdmObjectType.EdmObject_Folder, FolderID);
            IEdmEnumeratorVariable5 EnumVarObj5 = (IEdmEnumeratorVariable5)folder;
            IEdmEnumeratorVariable10 EnumVarObj10 = (IEdmEnumeratorVariable10)EnumVarObj5;

            object VarObj = null;
            EnumVarObj10.GetVar2(V_DN, "", FolderID, out VarObj);
            string CurrentDN = VarObj?.ToString();

            return CurrentDN;
            }

without understanding what the problem was, I had to use an outdated method “GetVar”.
well, everything worked as expected…

private string GetFolderPN(ref IEdmVault5 tmpVault, int FolderID)
        {
            IEdmFolder5 folder = (IEdmFolder5)tmpVault.GetObject(EdmObjectType.EdmObject_Folder, FolderID);
            IEdmEnumeratorVariable5 EnumVarObj5 = (IEdmEnumeratorVariable5)folder;

            object VarObj = null;
            EnumVarObj5.GetVar(V_PN, "", out VarObj);
            string CurrentPN = VarObj?.ToString();
            return CurrentPN;
            }
1 Like

Can you tick your reply as an answer if it is correct? Thanks!

this is not an answer, but ok)