Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations MintJulep on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

System.NullReferenceException - AskIdSymbolInfo - NX4 VB.NET App

Status
Not open for further replies.

MarckyMON

Computer
Nov 30, 2010
93
Hi everyone,

I am currently developing a function which counts the number of all round ID symbols containing specific text. Since the NX4 NX/Open VB.NET API does not contain an IDSymbol object, I am using the UG/Open wrapper functions instead:
Code:
Dim idSymbolType As UFDrf.IdSymbolType
Dim idSymbolOrigin() As Double = {0.0, 0.0, 0.0}
Dim idSymbolInfo() As UFDrf.IdSymbolInfo

ufSession.Drf.AskIdSymbolInfo(idSymbolTag, idSymbolType, idSymbolOrigin, idSymbolInfo)

When running the program, it terminates with a System.NullReferenceException when trying to call AskIdSymbolInfo. Here is the snippet from the log file:

System.NullReferenceException: Object reference not set to an instance of an object.
at NXOpen.UF.UFDrf.AskIdSymbolInfo(Tag id_symbol_tag, IdSymbolType& id_symbol_type, Double[] id_symbol_origin, IdSymbolInfo[]& id_symbol_info)

at TDF_MIKRON_change_table.ChangeTable.CountIDSymbols(Part workPart, String idText)
at TDF_MIKRON_change_table.EntryPoint.Main()
*** EXCEPTION: Error code 67 in line 996 of O:\ugnx404\ip2\src\syss\no\ind\lmldr.c at Tue Dec 07 21:34:33 2010 W. Europe Standard Time
+++ Object reference not set to an instance of an object.

I'm not sure where the problem is, but my hunch is it has something to do with the variable declaration:
Code:
Dim idSymbolInfo() As UFDrf.IdSymbolInfo

I'm really at a loss here and any help is much appreciated. Thanks!
 
Replies continue below

Recommended for you

Could you publish the complete code so we've a chance to locate the problem?
 
Hi daluigi,

Here is the function:
Code:
    Public Shared Function CountIDSymbols(ByVal workPart As Part, ByVal idText As String) As Integer
        CountIDSymbols = 0

        Dim idSymbolTag As Tag = Tag.Null
        Dim objType, objSubtype As Integer

        Do
            ufSession.Obj.CycleObjsInPart(workPart.Tag, UFConstants.UF_drafting_entity_type, idSymbolTag)

            If Not idSymbolTag.Equals(Tag.Null) Then
                ufSession.Obj.AskTypeAndSubtype(idSymbolTag, objType, objSubtype)

                If objSubtype.Equals(UFConstants.UF_draft_id_symbol_subtype) Then
                    Dim idSymbolType As UFDrf.IdSymbolType
                    Dim idSymbolOrigin() As Double = {0.0, 0.0, 0.0}
                    Dim idSymbolInfo() As UFDrf.IdSymbolInfo 
                    ufSession.Drf.AskIdSymbolInfo(idSymbolTag, idSymbolType, idSymbolOrigin, idSymbolInfo)

                End If

            End If

        Loop Until idSymbolTag.Equals(Tag.Null)
    End Function
 
Hey, I'm really stuck here and any help would be appreciated. Doesn't anyone have an idea??? :(

Marc
NX Software Developer
 
I have an update on the issue.

Previously, I had NX 4.0.4.2.
I've updated to NX 4.0.4.2 MP10, but now I have a new error message (see below). Apparently, the NX/Open library of NX4 cannot be trusted at all! Has anyone here encountered such an error? Is there a work around for this? I don't want to start my program all over just so I can get it working in C... :/

Caught exception while running: Main
System.ArgumentException: Type _LeaderInfo can not be marshaled as an unmanaged structure; no meaningful size or offset can be computed.

at System.Runtime.InteropServices.Marshal.SizeOf(Type t)

at NXOpen.UF.UFDrf.AskIdSymbolInfo(Tag id_symbol_tag, IdSymbolType& id_symbol_type, Double[] id_symbol_origin, IdSymbolInfo[]& id_symbol_info)


at TDF_MIKRON_change_table.ChangeTable.CountIDSymbols(Part workPart, String idText)

at TDF_MIKRON_change_table.EntryPoint.Main()
*** EXCEPTION: Error code 67 in line 996 of F:\workdir\reference\NX404_2\src\syss\no\ind\lmldr.c at Fri Dec 10 00:55:05 2010 W. Europe Standard Time
+++ Type _LeaderInfo can not be marshaled as an unmanaged structure; no meaningful size or offset can be computed.
[ 1] 75C99617 (KERNELBASE)

Thanks!

Marc
NX Software Developer
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor