Hello everyone, This is my first post.
I am trying to get variable values from a data card. i have ran into this problem where it returns as “edit”. which i think it’s because it’s user inputed as a text box. I need the value from said text box. Any Thoughts?
Code and Output listed below
using System;
using EPDM.Interop.epdm;
using System.Collections.Generic;
namespace PDMFileDetails
{
class Program
{
private static IEdmFolder5 ppoRetParentFolder;
[STAThread]
private static void Main(string[] args)
{
string vaultName = "PDM Sandbox"; // Replace with your actual vault name
string filePath = @"c:\PDM Sandbox\Document Control\IWO Files\13---\13010_IWO.xlsx"; // Adjust this to match your file path
try
{
IEdmVault5 vault = new EdmVault5Class();
vault.LoginAuto(vaultName, 0);
if (vault.IsLoggedIn)
{
Console.WriteLine($"Connected to vault: {vaultName}");
IEdmFile5 file = vault.GetFileFromPath(filePath, out ppoRetParentFolder);
if (file != null)
{
string stateName = file.CurrentState.Name;
Console.WriteLine($"File: {file.Name}, State: {stateName}");
// Get and print the specific PROJ_ID value
string projID = GetVariableValue(file, "PROJ_ID");
Console.WriteLine($"PROJ_ID: {projID}");
}
else
{
Console.WriteLine($"File not found: {filePath}");
}
}
else
{
Console.WriteLine("Failed to log in to the vault.");
}
}
catch (Exception ex)
{
Console.WriteLine($"An error occurred: {ex.Message}");
}
}
public static string GetVariableValue(IEdmFile5 file, string variableName)
{
if (file == null)
throw new ArgumentNullException(nameof(file));
if (string.IsNullOrEmpty(variableName))
throw new ArgumentNullException(nameof(variableName));
var vault = file.Vault;
var extension = System.IO.Path.GetExtension(file.Name).Replace(".", "");
var aCard = (IEdmCard6)(file.GetNextFolder(file.GetFirstFolderPosition())).GetCard(extension);
var controlPosition = aCard.GetFirstControlPosition();
while (controlPosition.IsNull == false)
{
IEdmVariable5 variable = null;
var control = aCard.GetNextControl(controlPosition) as IEdmCardControl7;
var variableID = control.VariableID;
if (variableID != 0)
variable = vault.GetObject(EdmObjectType.EdmObject_Variable, control.VariableID) as IEdmVariable5;
if (variable != null)
{
if (variable.Name.Equals(variableName, StringComparison.OrdinalIgnoreCase))
{
string[] variablesList = null;
control.GetControlVariableList(file.ID, out variablesList);
if (variablesList != null && variablesList.Length > 0)
return variablesList[0];
else
return "N/A";
}
}
}
return "N/A";
}
}
}
PS C:\Users\jgrewe\Development\JGrewe_code\GitRepo2\PDMAutoNoti\PDMFileVariables> dotnet run
Connected to vault: PDM Sandbox
File: 13010_IWO.xlsx, State: Released
PROJ_ID: Edit

Hello and welcome to CADOverflow! We're excited to have you join our community of CAD enthusiasts and professionals. Dive in, ask questions, share your knowledge, and explore the endless possibilities of CAD with us! I'm a real person. :)
– AmenJlili