Access unexposed suppression variables programmatically?

 

Hi!

Has anyone bumped into a requirement of being able to access and set suppression variables (that are not exposed, if it makes any difference) programmatically?

I didn't manage to find them in the variables collection as either dimensions or vars. I might have missed something trivial, hopefully.

 

Br,

Kalle

 

Posted by: Kalle Launiala
Post date: 9/3/2009 10:16:58 AM

1 REPLY

RE: Access unexposed suppression variables programmatically?

 

Hi Kalle,

If you need to find the name of the suppresion variable for a feature you'll need to go through the feature (e.g. ExtrudedProtrusion.SuppressVariable). Let me know if you need an example. Otherwise use the Query method and late binding to find the variable:using System;using System.Runtime.InteropServices;using System.Reflection;namespace ConsoleApplication1{ class Program { static void Main(string[] args) { SolidEdgeFramework.Application application = null; SolidEdgeFramework.SolidEdgeDocument document = null; SolidEdgeFramework.Variables variables = null; try { /* Connect to a running instance of Solid Edge */ application = (SolidEdgeFramework.Application)Marshal.GetActiveObject("SolidEdge.Application"); /* Get a reference to the active document */ document = (SolidEdgeFramework.SolidEdgeDocument)application.ActiveDocument; /* Get a reference to the variables collection */ variables = (SolidEdgeFramework.Variables)document.Variables; /* Perform a case-insensitive query for the variable */ SolidEdgeFramework.VariableList variableList = (SolidEdgeFramework.VariableList)variables.Query("ExtrudedProtrusion_1_Suppress", Type.Missing, Type.Missing, true); /* Check if we found the variable and set it */ if (variableList.Count == 1) { object variable = variableList.Item(1); try { /* Check if the variable is set (Value = 0.0) */ object value = variable.GetType().InvokeMember( "Value", BindingFlags.GetProperty, null, variable, null); if ((double)value == 0) { /* Set the supression variable */ variable.GetType().InvokeMember("Value", BindingFlags.SetProperty, null, variable, new object[] { 1.0 }); } } finally { if (variable != null) { Marshal.ReleaseComObject(variable); variable = null; } } } } catch (Exception ex) { Console.WriteLine(ex.Message); } finally { if (variables != null) { Marshal.ReleaseComObject(variables); variables = null; } if (document != null) { Marshal.ReleaseComObject(document); document = null; } if (application != null) { Marshal.ReleaseComObject(application); application = null; } } } }}

Hope this helps

Calum

 

Posted by: Calum McLellan
Post date: 9/3/2009 10:47:04 AM