Community
PowerShape and PowerMill API Forum
Welcome to Autodesk’s PowerShape and PowerMill API Forums. Share your knowledge, ask questions, and explore popular API topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

System.IndexOutOfRangeException

8 REPLIES 8
Reply
Message 1 of 9
LAV_PERM77
473 Views, 8 Replies

System.IndexOutOfRangeException

LAV_PERM77_0-1704817366759.png

Help me find the error. Connecting to the Power Mill on line 27 gives the error System.IndexOutOfRangeException , but if you open the pM.ActiveProject.NCPrograms[0].Toolpaths tree in Visual Studio Explorer before executing line 27 "Local Variables", there is no error the program is running. It works until the Power mill is closed and reopened. When reopening, you need to put a BREAKPOINT on line 27, open the object tree, then run on and everything works. Line 27 is a test line.

8 REPLIES 8
Message 2 of 9

Hi, when the exception is thrown can you send over the stack trace from the exception object? I'm hoping it will point us in the right direction... What version of the API are you using and also what version of PowerMill?

 

Thanks

Luke


Luke Edwards
Consulting Services Manager
Message 3 of 9

power mill 2022

LAV_PERM77_0-1704851105008.png

I'll do the stack trace late

Message 4 of 9

LAV_PERM77_0-1704897728669.png

 

Message 5 of 9
LAV_PERM77
in reply to: LAV_PERM77

Initially, this exception was created in this call stack: Autodesk.ProductInterface.PowerMILL.PMNCProgram.Toolpaths.get()

Message 6 of 9
LAV_PERM77
in reply to: LAV_PERM77

I tortured PM a bit, the result is as follows. The code below works, but the error remained in the test line.
Console.WriteLine(pM.ActiveProject.Setups[0].Name);
Console.WriteLine(pM.ActiveProject.Toolpaths[0].Name);
Console.WriteLine(pM.ActiveProject.Tools[0].Name);
Console.WriteLine(pM.ActiveProject.NCPrograms[0].Name);
Console.WriteLine(pM.ActiveProject.LevelsAndSets[0].Name);
Console.WriteLine(pM.ActiveProject.Models[0].Name);
Console.WriteLine(pM.ActiveProject.Workplanes[0].Name);
Console.WriteLine(pM.ActiveProject.Patterns[0].Name);
Console.WriteLine(pM.ActiveProject.FeatureSets[0].Name);
Console.WriteLine(pM.ActiveProject.Setups[0].Toolpaths[0].Tool.Length.ToString());
Console.WriteLine(pM.ActiveProject.NCPrograms[0].Toolpaths[0].Name) ; (ERROR)(TEST STRING)

But the interesting thing is that if you refer to the BoundingBox properties before the test line, the error will not appear in the test line, and the program will work as needed.
Console.WriteLine(pM.ActiveProject.FeatureSets[0].BoundingBox.MaxZ.ToString());
or
Console.WriteLine(pM.ActiveProject.Setups[0].Toolpaths[0].BoundingBox.MinZ.ToString());

Console.WriteLine(pM.ActiveProject.NCPrograms[0].Toolpaths[0].Name) ; // OK

Message 7 of 9

I notice that you are running in non-English. Could it be related to the characters in the name of the toolpath perhaps? Do you only get this issue on a certain project or is it happening for all projects?


Luke Edwards
Consulting Services Manager
Message 8 of 9

The name of the ToolPath is all in English.

Message 9 of 9

Would you be able to share the PowerMill project with me? Or at least a version where you can repeat the issue?


Luke Edwards
Consulting Services Manager

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Technology Administrators