×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

System.NullReferenceException - AskIdSymbolInfo - NX4 VB.NET App

System.NullReferenceException - AskIdSymbolInfo - NX4 VB.NET App

System.NullReferenceException - AskIdSymbolInfo - NX4 VB.NET App

(OP)
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!

RE: System.NullReferenceException - AskIdSymbolInfo - NX4 VB.NET App

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

RE: System.NullReferenceException - AskIdSymbolInfo - NX4 VB.NET App

(OP)
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

RE: System.NullReferenceException - AskIdSymbolInfo - NX4 VB.NET App

(OP)
Hey, I'm really stuck here and any help would be appreciated. Doesn't anyone have an idea??? :(

Marc
NX Software Developer
 

RE: System.NullReferenceException - AskIdSymbolInfo - NX4 VB.NET App

(OP)
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
 

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources