Threaded holes while logged off using API

Threaded holes while logged off using API

ZKeimW5SN7
Explorer Explorer
711 Views
11 Replies
Message 1 of 12

Threaded holes while logged off using API

ZKeimW5SN7
Explorer
Explorer

We are using Inventor on a computer that has a C# console application querying a database for “work to do.” This console application is started by a task that launches the console application at the machine’s startup, and it runs in the background whether a person is logged into the machine or not. Once the query returns a part to draw, it goes in, draws the part, and outputs it to a specified location. This works great for most things; however, we noticed it would always throw an “unable to invoke object” error while trying to create a threaded hole. Then we noticed that if the user was logged in, it would work every time. Does a user HAVE to be logged in to use the Inventor API without errors?

0 Likes
712 Views
11 Replies
Replies (11)
Message 2 of 12

YuhanZhang
Autodesk
Autodesk

Did you test with a different machine for this?  Can you share more detailed info about the error?



If this solves the problem please click ACCEPT SOLUTION so other people can find it easily.



Rocky Zhang
Inventor API PD
Manufacturing Solutions
Autodesk, Inc.

0 Likes
Message 3 of 12

ZKeimW5SN7
Explorer
Explorer

Hello,

Yes, we have 2 separate machines that have this issue.  We have a "TEST" machine and a "Production" machine.  

 

 

The error comes from this line in our code:

cSE.oIHoleTapInfo = cSE.oIHoleFeatures.CreateTapInfo(true, "ANSI Unified Screw Threads", x.ToUpper(), "2B", false, dDrillDepth);

 

example inputs of the variables are:

x = 1/2-13 UNC

dDrillDepth = 1.5

 

Here is some of the settings on our task that we use to start the program.  If we use the top setting, everything works.  If we use the bottom setting, we get the error.  I believe it says: "Unable to invoke object".

2024-10-30_9-57-26.png

0 Likes
Message 4 of 12

YuhanZhang
Autodesk
Autodesk

Which Inventor version are you working with? Where you placed your app for startup? If you configured the app as startup app for specified user to log in, it may require the user to log in.

 

2024-11-1 12-10-50.png

 

Please share your steps to configure your startup app, so we can check if this is Windows limitation or Inventor side issue.



If this solves the problem please click ACCEPT SOLUTION so other people can find it easily.



Rocky Zhang
Inventor API PD
Manufacturing Solutions
Autodesk, Inc.

0 Likes
Message 5 of 12

ZKeimW5SN7
Explorer
Explorer
It's Autodesk Inventor Processsional 2023 64 bit edition
Build 446, Release 2023.5
0 Likes
Message 6 of 12

YuhanZhang
Autodesk
Autodesk

We did a test here for CreateTapInfo, and it succeeded without logging in. Can you share more info that might be a reason to cause this problem?



If this solves the problem please click ACCEPT SOLUTION so other people can find it easily.



Rocky Zhang
Inventor API PD
Manufacturing Solutions
Autodesk, Inc.

0 Likes
Message 7 of 12

ZKeimW5SN7
Explorer
Explorer

We have a function that starts inventor when the request is an Inventor request.  If it's not (other CAD platforms) they have a similar function.  Inventor remains open unless it crashes.  If it does, or the computer is restarted, this function will open inventor and attach the process to it on the first requests that requires it.

 

public static void StartInventor()
{
try
{
string sName = "";
int loop = 0;
foreach (Process Proc in Process.GetProcesses())
{
if (Proc.ProcessName.Equals("Inventor"))
{
if (loop > 0)
{
DebugLog("before kill process inventor");
killInventor();
DebugLog("after kill process inventor");
}
else
{
sName = Proc.ProcessName;
loop++;
}
}
}

if (sName == "")
{
Process.Start(@"C:\Program Files\Autodesk\Inventor 2023\Bin\Inventor.exe");

bool found = false;
int count = 0;
while (!found && count < 60)
{
try
{
System.Threading.Thread.Sleep(1000);
count++;
cSE.oInventorApp = (Inventor.Application)Marshal.GetActiveObject("Inventor.Application");
found = true;
}
catch
{
DebugLog("attempts to get inventor process " + count.ToString());
}
}
if (!found)
{
cSE.oInventorApp = null;
throw new Exception("Inventor start timed out");
}
}
else
{
cSE.oInventorApp = (Inventor.Application)Marshal.GetActiveObject("Inventor.Application");
}

_InvapplicationEvents = cSE.oInventorApp.ApplicationEvents;
_InvassemblyEvents = cSE.oInventorApp.AssemblyEvents;
_InvmodelEvents = cSE.oInventorApp.ModelingEvents;
if (!IsINVInit)
{
_InvapplicationEvents.OnOpenDocument += oIAppEvents_OnOpenDocument;
_InvapplicationEvents.OnSaveDocument += oIAppEvents_OnSaveDocument;
_InvapplicationEvents.OnCloseDocument += oIAppEvents_OnCloseDocument;
_InvapplicationEvents.OnInitializeDocument += oIAppEvents_OnInitializeDocument;
_InvapplicationEvents.OnReady += oIAppEvents_OnReady;

_InvassemblyEvents.OnNewOccurrence += oIAssemblyEvents_OnNewOccurrence;
_InvassemblyEvents.OnOccurrenceChange += oIAssemblyEvents_OnOccurrenceChange;
_InvassemblyEvents.OnAssemblyChange += oIAssemblyEvents_OnAssemblyChange;
_InvassemblyEvents.OnAssemblyChanged += oIAssemblyEvents_OnAssemblyChanged;

_InvmodelEvents.OnNewFeature += oIModelEvents_OnNewFeature;

IsINVInit = true;
}

//if (cFG.cServer == "DEV")
//{

//}
cSE.oInventorApp.Visible = true;
cSE.oInventorApp.WindowState = kMaximize;
cSE.oInventorApp.SilentOperation = true;
cSE.oIDocs = cSE.oInventorApp.Documents;
cSE.oITransGeo = cSE.oInventorApp.TransientGeometry;
cSE.oITransObj = cSE.oInventorApp.TransientObjects;
}
catch (Exception ex)
{
ErrorLog(ex);
throw (ex);
}
}

0 Likes
Message 8 of 12

ZKeimW5SN7
Explorer
Explorer
Sorry, I saw a previous message and was replying to that, the page didn't scroll to the appropriate reply...

I will get with my CAD developer to answer your latest question.
0 Likes
Message 9 of 12

ZKeimW5SN7
Explorer
Explorer

 

I asked my developer to create a small sample program that will do only this one thing so we can have something to share.  In the meantime, I thought it might be good to make clearer an observation about these settings.  This issue happens if you are logged in or not.  We can start this task ask the second option, leave the computer logged in, run the CAD request and it will fail.  Turn this setting the other way as shown below, and you it works every time.

 

ZKeimW5SN7_3-1730730993989.png

 

ZKeimW5SN7_0-1730730479358.png

ZKeimW5SN7_1-1730730490895.png

Here are the other settings of the task that starts our console application.  

ZKeimW5SN7_2-1730730503865.png

 

 

0 Likes
Message 10 of 12

YuhanZhang
Autodesk
Autodesk

If you can provide us a sample project and how you configure it via Task Scheduler, then we can try to reproduce it here.



If this solves the problem please click ACCEPT SOLUTION so other people can find it easily.



Rocky Zhang
Inventor API PD
Manufacturing Solutions
Autodesk, Inc.

0 Likes
Message 11 of 12

YuhanZhang
Autodesk
Autodesk

Hi @ZKeimW5SN7 ,

 

I got your project and tested here, I created a task in Task Scheduler as below and it works well:

 

1-General.png2-Triggers.png3-Actions.png4-Conditions.png5-Settings.png

 

Here is the log result:

 

6-LogResult.png

 

Can you double check it there?



If this solves the problem please click ACCEPT SOLUTION so other people can find it easily.



Rocky Zhang
Inventor API PD
Manufacturing Solutions
Autodesk, Inc.

0 Likes
Message 12 of 12

ZKeimW5SN7
Explorer
Explorer

Hi Rocky,

Did you run it while signed out?  I created the sample project and tested it the day I sent it in.  The error only happens when the user is not currently logged in, so the best way to do that is restart the computer and let the task start on its own when the computer turns back on.

0 Likes