ERROR IN VISUAL STUDIO PROGRAMMING WHILE ACCESING PLANES OF INVENTOR PART

ERROR IN VISUAL STUDIO PROGRAMMING WHILE ACCESING PLANES OF INVENTOR PART

ashish.patilSP94R
Participant Participant
485 Views
4 Replies
Message 1 of 5

ERROR IN VISUAL STUDIO PROGRAMMING WHILE ACCESING PLANES OF INVENTOR PART

ashish.patilSP94R
Participant
Participant

An unhandled exception of type 'System.NullReferenceException' occurred in InventorDrawingGenerator.exe

Additional information: Object reference not set to an instance of an object.

ashishpatilSP94R_0-1712392711175.png

 

0 Likes
486 Views
4 Replies
Replies (4)
Message 2 of 5

JelteDeJong
Mentor
Mentor

I wrote a bit of test code. The line that throws an error in your code works fine for me.

A "NullReferenceException" means that one of the variables in the line is not set correctly. In this specific line of code, there are not that many variables. Therefore I expect that the "sheetMetalCompDef" variable is not set. You can check this by adding a check for a null reference before this line. something like this.

if (sheetMetalCompDef == null)
{
    // sheetMetalCompDef is not set. 
    // You have a problem in your code before this line.
    Debugger.Break();
}

PlanarSketch baseSketch = sheetMetalCompDef.Sketches.Add(sheetMetalCompDef.WorkPlanes[3]);

 If the "sheetMetalCompDef" variable is not set then the debugger will stop on line 5.

If you have confirmed that this is the issue then you probably want to solve the issue. With that, I can't help without looking at more code.

Jelte de Jong
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature


Blog: hjalte.nl - github.com

Message 3 of 5

ashish.patilSP94R
Participant
Participant

I got your debugger point but to access the work-plane what command (code) need to use.

because even after trying multiple times not getting correct 

0 Likes
Message 4 of 5

JelteDeJong
Mentor
Mentor

If the debugger stops at that point you have a problem in a part of your code that I can not see. Therefore I can't help you. Maybe you can share the complete function.

Jelte de Jong
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature


Blog: hjalte.nl - github.com

0 Likes
Message 5 of 5

ashish.patilSP94R
Participant
Participant

thanks for reply where I need to share function so that you can access? @JelteDeJong 

0 Likes