Reply

SolidEdgeFramework.Variables

I have this code that fails editing the variable table formulas, this is the line where it breaks

 

variablesTable.Edit (varName, varValue);

 

publicvoid writeVariables(string filePath, string[] variableTable)

{

SolidEdgeFramework.Application application = null;

SolidEdgeDocument document = null;

SolidEdgeFramework.Variables variablesTable = null;

try

{

OleMessageFilter.Register();

// Connect to running Solid Edge Instance

application = (SolidEdgeFramework.Application)

Marshal.GetActiveObject("SolidEdge.Application");

document = application.ActiveDocument;

variablesTable = document.Variables;

 

for (int i = 0; i <= variableTable.Length - 1; i++)

{

try

{

string varName = variableTable[i].Remove(variableTable[i].LastIndexOf("|"));

string varValue = Convert.ToString(Convert.ToDouble(variableTable[i].Remove(0, variableTable[i].LastIndexOf("|") + 1)) * imperial);

variablesTable.Edit (varName, varValue);

 

}

catch (SystemException ex)

{

System.Windows.Forms.MessageBox.Show(string.Concat("Error Updating Variable: ", variableTable[i], string.Empty, ex.ToString()));

Console.WriteLine(ex.Message);

}

catch (System.Exception ex)

{

System.Windows.Forms.MessageBox.Show(string.Concat("Error getting Solid Edge active document ", ex.ToString()));

Console.WriteLine(ex.Message);

}

finally

{

 

OleMessageFilter.Revoke();

}

}

 

 

2 REPLIES

Re: SolidEdgeFramework.Variables

You may want to have look at this thread before attempting to edit a variable value.

I found myself recently in a similar situation and this post helped me.

 

~Tushar

http://surfandcode.blogspot.in

 

Re: SolidEdgeFramework.Variables

Thank you Tushar. My code was good, no errors there, the error was in the variable names, there was a mistmatch between the name sent as parameter and the name on the variable table and the SE file.