Click or drag to resize

ExtensionGetDataCardVariable Method

Gets the value of the vault data card variable for the specified checked out file.

Namespace:  CADSharpTools.PDM
Assembly:  CADSharpTools.PDM (in CADSharpTools.PDM.dll) Version: 1.4.16.0 (1.4.16)
Syntax
public static MethodReturn<Object, GetDataCardVariableReturn_e> GetDataCardVariable(
	this IEdmFile5 file,
	string variable,
	string configurationName = "@"
)

Parameters

file
Type: IEdmFile5
File object.
variable
Type: SystemString
Vault variable name.
configurationName (Optional)
Type: SystemString
Configuration name. Default is "@".

Return Value

Type: MethodReturnObject, GetDataCardVariableReturn_e
MethodReturn of the data card variable's value and the GetDataCardVariableReturn_e operation return.

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type IEdmFile5. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).
Exceptions
ExceptionCondition
CADSharpToolsPDMExceptionThrown when:
  • unable to get the parent folder of the specified file object.
  • the specified file has no local copy.
Remarks
  • You have to call IEdmFile5::GetFileCopy get a local copy of a file before using this method to read variables. This is not required if there is a local copy. Use HasLocalCopy(IEdmFile5, Int32) to check whether the specified file object has a local copy or not.
  • Use GetVariableFromDb(IEdmFile5, String, String) to get data from files that are not cached (have no local copies).
Examples
This example shows how to login to the vault and get the value of a vault variable called "Part Number" for the first file.
public enum EdmLoginFlags
{
    Nothing,
    WebClient
}

public static void Example()
{
    //create vault object 
    var swPDMVault = new EdmVault5();
    var swPDMVaultEx = swPDMVault as IEdmVault13;

    //required per PDM EULA in out-of-process applications              
    swPDMVaultEx.LoginEx("Admin", "****", "CADSharp LLC", (int)EdmLoginFlags.Nothing);

    // get root folder 
    var swPDMRootFolder = swPDMVaultEx.RootFolder;

    // get first file position
    var swPDMFirstFilePos = swPDMRootFolder.GetFirstFilePosition();
    if (swPDMFirstFilePos.IsNull == false)
    {
        var swPDMFirstFile = swPDMRootFolder.GetNextFile(swPDMFirstFilePos);

        // get the part number of the first file 
        var variableReturn = swPDMFirstFile.GetDataCardVariable("Part Number");
        if (variableReturn.IsError)
        {
            Debug.Print(variableReturn.Error);
            return;
        }

        var partNumberValue = variableReturn.Value.ToString();
        Debug.Print($"Part Number variable value: {partNumberValue}");
    }
    else
    {
        Debug.Print($"Vault has no files at the root folder.");
    }
}
See Also