×
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

Measure Intersection Curve

Measure Intersection Curve

Measure Intersection Curve

(OP)
I need to convert my intersection curve to a displayable object, so far everything I have tried has failed.

The error says "System.NullReferenceException: Object reference not set to an instance of an object.
at ModelChecking.MeasureLineLength(IntersectionCurve moldInterLine, String strMoldLength, Boolean boolLength, Unit_unitMM) in" ... "line 676"

CODE --> vb

Sub MeasureLineLength( ByRef moldInterLine As Features.IntersectionCurve, ByRef strMoldLength As String, _
      ByRef boolLength As Boolean, ByRef unitMM As Unit )

      Dim measureDistanceBuilder1     As MeasureDistanceBuilder
      Dim measureLength1              As MeasureLength
      Dim curves(-1)                  As NXObject
      Dim nullNXObject                As NXObject

      nullNXObject = Nothing

       measureDistanceBuilder1 = workPart.MeasureManager.CreateMeasureDistanceBuilder(nullNXObject)

      curves = moldInterLine.GetEntities()

      'Try

         measureLength1 = workPart.MeasureManager.NewLength( unitMM, curves )

         strMoldLength = measureLength1.value.ToString

         msgbox("Mold length = " & strMoldLength )

      'Catch

         'strMoldLength = "Failed To Measure"

      'End Try
   End Sub 

Line 676 is the line curves = moldInterLine.GetEntities()

Any help is greatly appreciated.

RE: Measure Intersection Curve

Try this:

CODE

Dim featureObjects() As NXObject  
featureObjects = myIntersectionCurve.GetEntities  
Dim featureCurves As New List(Of Curve)  
For Each crv As Curve In featureObjects  
    featureCurves.Add(crv)  
Next  

Dim totalLength As Double = 0  
For Each crv As Curve In featureCurves  
    totalLength += crv.GetLength  
Next  

MsgBox("total length of intersection curve: " & totalLength) 

To use the list, you'll need to add the line:
Imports System.Collections.Generic
to the "imports" section

Length will be returned in the "analysis units" of the part.

www.nxjournaling.com

RE: Measure Intersection Curve

(OP)
I added that import though I already had:
Imports System.Collections

The problem is it is failing at the second line of your code, or that is where my error is directing me:
<code>
featureObjects = myIntersectionCurve.GetEntities
<code>

I had the same line in my code, I don't know why it won't work.

Error reads:

System.NullReferenceException: Object reference not set to an instance of an object.
at ModelChecking.MeasureLineLength(intersectionCurve moldInterLine, String, strmoldInterLine, String strMoldLength, Boolean, boolLength, Unit_unitMM) ... line 678

RE: Measure Intersection Curve

In that case it is most likely a problem with moldInterLine; either it is null or doesn't hold what you think it holds. I'd add some code in this routine to investigate if moldInterLine IsNull or IsEmpty. If it is null or empty, you'll have to dig a bit deeper to find out why. If it isn't, then you'll need to find out what that variable does contain.

www.nxjournaling.com

RE: Measure Intersection Curve

(OP)
In the sub where the intersection line is created, after it is committed then you get the following line before destroying the builder.

CODE --> vb

Try
         feature1 = intersectionCurveBuilder1.commitFeature()
         moldinterLine = CType( feature1, Features.IntersectionCurve )
      Catch
         boolIntersection = false
         intersectionCurveBuilder1.Destroy()
         Exit Sub
      End Try
      intersectionCurveBuilder1.Destroy() 

From a glance is this "transforming" the builder to curve, correctly?

RE: Measure Intersection Curve

How is moldinterLine declared?

I'd try:

CODE

dim moldInterLine as Features.IntersectionCurve
...
...
...
moldInterLine = intersectionCurveBuilder1.commitFeature() 

www.nxjournaling.com

RE: Measure Intersection Curve

(OP)
Alright right after setting:

moldInterLine = intersectionCurveBuilder1.commitFeature()

I did an if statement as follows

If moldInterLine is Nothing then
msgbox("interLine = Nothing")
End If

and it activated.

I am attempting to place an intersection curve on a component of an assembly, the intersection curve does appear but it is unassociated, that is fine I can make it work, but would this effect the ability of the variable to be passed and used later in the program?

RE: Measure Intersection Curve

As a test, I opened a small assembly and recorded a journal while creating an intersect curve feature. I selected the face of a component for the first set and a datum plane owned by the assembly file itself for the second set. The journal showed that 2 extract face features and a wave link were created but they did not show up in the feature tree, only the intersection curve. It appears that the .CommitCreateOnTheFly method creates some "behind the scenes" features.

To investigate further, I ran this code on the assembly file (where the intersect curve feature was created):

CODE

Option Strict Off
Imports System
Imports NXOpen
Imports NXOpen.Features

Module NXJournal
Sub Main


Dim s As Session = Session.GetSession()
Dim ui As UI = UI.GetUI()
Dim lw As ListingWindow = s.ListingWindow
lw.Open()

Dim featArray() As Feature = s.Parts.Work.Features.GetFeatures()
Dim featEntities() as NXObject

lw.WriteLine("*** All Features ***")
For each myFeature as Feature in featArray
    lw.WriteLine(myFeature.GetFeatureName)
	lw.WriteLine(myFeature.FeatureType)
	lw.writeline("")

Next
lw.Close

End Sub
End Module 

This is a simple journal that simply lists all the features in the work part to the information window. I found there was a linked face feature with the same feature number as the intersect curve feature, but it does not appear in the part history.

Perhaps too much code was cut from the journal you originally created to help make your intersect curve feature subroutine?

www.nxjournaling.com

RE: Measure Intersection Curve

(OP)
Very very possible.

I have actually called the GTAC helpline and gotten them to see if they can help me, in the mean time I'll check the original journal and see if I can start from scratch

Thanks for all your help.

RE: Measure Intersection Curve

(OP)
For future programmers, there is no such thing as an unassociative feature. once the feature is unassociated it looses the information which would make it a feature.

For getting something like an intersection curve from a component of an assembly you must wave link the feature you are working off of.

So I'm off to learn how to wave link.

Thanks for all the help cowski!

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