Error not getting COM objects

Valued Contributor
Valued Contributor

Hello All,


Can some one help me with this? It errors out because API is not getting the COM objects,


Here is the line where fails:


objPartDoc.AdjustableDefinition.GetAdjustables(out numEntries, partVariables, arrayNotesOut);


ht code is supposed to change assembly variables on ad adjustable part. Please run it with the attached SE files


Here is the Code: 

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Runtime.InteropServices;
using System.Threading;
using SolidEdgeFramework;
using SolidEdgeAssembly;
using SolidEdgeConstants;
using SolidEdgeGeometry;
using SolidEdgePart;
using SolidEdgeDraft;

namespace ConsoleApplication1
class Program

static void Main(string[] args)

SolidEdgeFramework.Application objApp = null;
SolidEdgeAssembly.AssemblyDocument objDoc;
SolidEdgePart.PartDocument objPartDoc;
SolidEdgeAssembly.AdjustablePart objAdjPart;

int numEntries=new int();
object [] partVariables=new object [] {};
object [] asmVariables=new object [] {};
string [] arrayNotesOut= new string[] {};

Array.Resize(ref partVariables, 3);
Array.Resize(ref asmVariables, 3);
Array.Resize(ref arrayNotesOut, 3);

objApp = (SolidEdgeFramework.Application)
objDoc = objApp.ActiveDocument;
objAdjPart = objDoc.Occurrences.Item(1).GetAdjustablePart(); //Occurrence containing adjustable aprt
objPartDoc = objAdjPart.Occurrence.OccurrenceDocument;


objPartDoc.AdjustableDefinition.GetAdjustables(out numEntries, partVariables, arrayNotesOut);

objAdjPart.GetAdjustables(numEntries, partVariables, asmVariables);

asmVariables[0] = 25; //New Value for adjustable part in assembly
asmVariables[1] = 50;//New Value for adjustable part in assembly
asmVariables[2] = 10;//New Value for adjustable part in assembly


objAdjPart.SetAdjustables(numEntries, partVariables, asmVariables);


Re: Error not getting COM objects

Solution Partner Phenom Solution Partner Phenom
Solution Partner Phenom

Since you only provided the part, I couldn't provide the assembly code but you should get the idea.


static void Main(string[] args)
    SolidEdgeFramework.Application objApp = null;
    SolidEdgePart.PartDocument objPartDoc;
    SolidEdgePart.AdjustableDefinition adjustableDefinition = null;

    objApp = (SolidEdgeFramework.Application)Marshal.GetActiveObject("SolidEdge.Application");

    objPartDoc = (SolidEdgePart.PartDocument)objApp.ActiveDocument;
    adjustableDefinition = objPartDoc.AdjustableDefinition;

    int NumberOfEntries = default(int);
    Array Variables = Array.CreateInstance(typeof(object), 0);
    Array Notes = Array.CreateInstance(typeof(string), 0);

    adjustableDefinition.GetAdjustables(out NumberOfEntries, ref Variables, ref Notes);

    var variable1 = (SolidEdgeFramework.variable)Variables.GetValue(0);
    var variable2 = (SolidEdgeFramework.variable)Variables.GetValue(1);
    var variable3 = (SolidEdgeFramework.variable)Variables.GetValue(2);

    variable1.Value = variable1.Value * 2;
    variable2.Value = variable1.Value * 2;
    variable3.Value = variable1.Value * 2;
Jason Newell
Applications Architect