I think there is nothing wrong in my code but if i run the code, point A,B and first line(AB) disappeared

hello.

i tried to make four point A,B,C,D
and connect them using two lines(A and B, C and D)

I think there is nothing wrong in my code
but if i run the code, point A,B and first line(AB) disappeared.

please help me in this problem.
i attach the code here.

thanks

----------------------------------------------------------------

Option Strict Off
Imports System
Imports NXOpen

Module Points_01b

Sub Main()

Dim theSession As Session = Session.GetSession()
Dim workPart As Part = theSession.Parts.Work
Dim lw As ListingWindow = theSession.ListingWindow

'set undo mark
Dim markId1 As Session.UndoMarkId
markId1 = theSession.SetUndoMark(Session.MarkVisibility.Visible, "Journal")

lw.open()

Dim A As New Point3d( -90, -7, -126 )
Dim B As New Point3d( -6@, -5, -560 )
Dim C As New Point3d( -110, 11, -550 )
Dim D As New Point3d( -22, 7, -540 )

Dim newPt1 As Point
Dim newPt2 As Point
Dim newPt3 As Point
Dim newPt4 As Point

newPt1=workPart.Points.CreatePoint(A)
newPt1.SetVisibility(SmartObject.VisibilityOption.Visible)

newPt2=workPart.Points.CreatePoint(B)
newPt2.SetVisibility(SmartObject.VisibilityOption.Visible)

newPt3=workPart.Points.CreatePoint(C)
newPt3.SetVisibility(SmartObject.VisibilityOption.Visible)

newPt4=workPart.Points.CreatePoint(D)
newPt4.SetVisibility(SmartObject.VisibilityOption.Visible)

'make point on part navigation
Dim nullFeatures_Feature As Features.Feature = Nothing

Dim pointFeatureBuilder1 As Features.PointFeatureBuilder
pointFeatureBuilder1 = workPart.BaseFeatures.CreatePointFeatureBuilder(nullFeatures_Feature)

pointFeatureBuilder1.Point = newPt1

Dim myPointFeature1 As Features.Feature
myPointFeature1 = pointFeatureBuilder1.Commit()

pointFeatureBuilder1.Destroy()
' ' ' '''
Dim pointFeatureBuilder2 As Features.PointFeatureBuilder
pointFeatureBuilder2 = workPart.BaseFeatures.CreatePointFeatureBuilder(nullFeatures_Feature)

pointFeatureBuilder2.Point = newPt2

Dim myPointFeature2 As Features.Feature
myPointFeature2 = pointFeatureBuilder2.Commit()

pointFeatureBuilder2.Destroy()

' '''
Dim pointFeatureBuilder3 As Features.PointFeatureBuilder
pointFeatureBuilder3 = workPart.BaseFeatures.CreatePointFeatureBuilder(nullFeatures_Feature)

pointFeatureBuilder3.Point = newPt3

Dim myPointFeature3 As Features.Feature
myPointFeature3 = pointFeatureBuilder3.Commit()
pointFeatureBuilder3.Destroy()

' '''
Dim pointFeatureBuilder4 As Features.PointFeatureBuilder
pointFeatureBuilder4 = workPart.BaseFeatures.CreatePointFeatureBuilder(nullFeatures_Feature)

pointFeatureBuilder4.Point = newPt4

Dim myPointFeature4 As Features.Feature
myPointFeature4 = pointFeatureBuilder4.Commit()

pointFeatureBuilder4.Destroy()

'make point on part navigation(connect point A and B)
Dim nullFeatures_AssociativeLine As Features.AssociativeLine = Nothing

Dim associativeLineBuilder1 As Features.AssociativeLineBuilder
associativeLineBuilder1 = workPart.BaseFeatures.CreateAssociativeLineBuilder(nullFeatures_AssociativeLine)

associativeLineBuilder1.StartPoint.Value = newPt1
associativeLineBuilder1.StartPointOptions =Features.AssociativeLineBuilder.StartOption.Point

associativeLineBuilder1.EndPoint.Value = newPt2
associativeLineBuilder1.EndPointOptions = Features.AssociativeLineBuilder.EndOption.Point

Dim myLineFeature As Features.AssociativeLine
myLineFeature = associativeLineBuilder1.Commit()

associativeLineBuilder1.Destroy()

'make point on part navigation(connect point C and D)
Dim associativeLineBuilder2 As Features.AssociativeLineBuilder
associativeLineBuilder2 = workPart.BaseFeatures.CreateAssociativeLineBuilder(nullFeatures_AssociativeLine)

associativeLineBuilder2.StartPoint.Value = newPt3
associativeLineBuilder2.StartPointOptions = Features.AssociativeLineBuilder.StartOption.Point

associativeLineBuilder2.EndPoint.Value = newPt4
associativeLineBuilder2.EndPointOptions = Features.AssociativeLineBuilder.EndOption.Point

Dim myLineFeature2 As Features.AssociativeLine
myLineFeature2 = associativeLineBuilder2.Commit()

associativeLineBuilder2.Destroy()

lw.Close()

End Sub

Public Function GetUnloadOption(ByVal dummy As String) As Integer

'Unloads the image when the NX session terminates
GetUnloadOption = NXOpen.Session.LibraryUnloadOption.AtTermination

End Function

End Module

Try the following:

Option Strict Off
Imports System
Imports NXOpen

Module Points_01b

Sub Main()

Dim theSession As Session = Session.GetSession()
Dim workPart As Part = theSession.Parts.Work
Dim lw As ListingWindow = theSession.ListingWindow

'set undo mark
Dim markId1 As Session.UndoMarkId
markId1 = theSession.SetUndoMark(Session.MarkVisibility.Visible, "Journal")

lw.open()

Dim A As New Point3d( -90, -7, -126 )
Dim B As New Point3d( -6, -5, -560 )
Dim C As New Point3d( -110, 11, -550 )
Dim D As New Point3d( -22, 7, -540 )

Dim newPt1 As Point
Dim newPt2 As Point
Dim newPt3 As Point
Dim newPt4 As Point

newPt1=workPart.Points.CreatePoint(A)
'newPt1.SetVisibility(SmartObject.VisibilityOption.Visible)

newPt2=workPart.Points.CreatePoint(B)
'newPt2.SetVisibility(SmartObject.VisibilityOption.Visible)

newPt3=workPart.Points.CreatePoint(C)
'newPt3.SetVisibility(SmartObject.VisibilityOption.Visible)

newPt4=workPart.Points.CreatePoint(D)
'newPt4.SetVisibility(SmartObject.VisibilityOption.Visible)

Dim nullXform As Xform = Nothing

'make point on part navigation
Dim nullFeatures_Feature As Features.Feature = Nothing

Dim pointFeatureBuilder1 As Features.PointFeatureBuilder
pointFeatureBuilder1 = workPart.BaseFeatures.CreatePointFeatureBuilder(nullFeatures_Feature)

pointFeatureBuilder1.Point = newPt1

Dim myPointFeature1 As Features.PointFeature
myPointFeature1 = pointFeatureBuilder1.Commit()

pointFeatureBuilder1.Destroy()
newPt1 = workPart.Points.CreatePoint(CType(myPointFeature1.GetEntities(0), Point), nullXform, SmartObject.UpdateOption.WithinModeling)
'''
Dim pointFeatureBuilder2 As Features.PointFeatureBuilder
pointFeatureBuilder2 = workPart.BaseFeatures.CreatePointFeatureBuilder(nullFeatures_Feature)

pointFeatureBuilder2.Point = newPt2

Dim myPointFeature2 As Features.Feature
myPointFeature2 = pointFeatureBuilder2.Commit()

pointFeatureBuilder2.Destroy()
newPt2 = workPart.Points.CreatePoint(CType(myPointFeature2.GetEntities(0), Point), nullXform, SmartObject.UpdateOption.WithinModeling)
'''
Dim pointFeatureBuilder3 As Features.PointFeatureBuilder
pointFeatureBuilder3 = workPart.BaseFeatures.CreatePointFeatureBuilder(nullFeatures_Feature)

pointFeatureBuilder3.Point = newPt3

Dim myPointFeature3 As Features.Feature
myPointFeature3 = pointFeatureBuilder3.Commit()
pointFeatureBuilder3.Destroy()
newPt3 = workPart.Points.CreatePoint(CType(myPointFeature3.GetEntities(0), Point), nullXform, SmartObject.UpdateOption.WithinModeling)
'''
Dim pointFeatureBuilder4 As Features.PointFeatureBuilder
pointFeatureBuilder4 = workPart.BaseFeatures.CreatePointFeatureBuilder(nullFeatures_Feature)

pointFeatureBuilder4.Point = newPt4

Dim myPointFeature4 As Features.Feature
myPointFeature4 = pointFeatureBuilder4.Commit()

pointFeatureBuilder4.Destroy()
newPt4 = workPart.Points.CreatePoint(CType(myPointFeature4.GetEntities(0), Point), nullXform, SmartObject.UpdateOption.WithinModeling)

'make point on part navigation(connect point A and B)
Dim nullFeatures_AssociativeLine As Features.AssociativeLine = Nothing

Dim associativeLineBuilder1 As Features.AssociativeLineBuilder
associativeLineBuilder1 = workPart.BaseFeatures.CreateAssociativeLineBuilder(nullFeatures_AssociativeLine)

associativeLineBuilder1.StartPointOptions =Features.AssociativeLineBuilder.StartOption.Point
associativeLineBuilder1.StartPoint.Value = newPt1

associativeLineBuilder1.EndPointOptions = Features.AssociativeLineBuilder.EndOption.Point
associativeLineBuilder1.EndPoint.Value = newPt2

Dim myLineFeature As Features.AssociativeLine
myLineFeature = associativeLineBuilder1.CommitFeature()

associativeLineBuilder1.Destroy()

'make point on part navigation(connect point C and D)
Dim associativeLineBuilder2 As Features.AssociativeLineBuilder
associativeLineBuilder2 = workPart.BaseFeatures.CreateAssociativeLineBuilder(nullFeatures_AssociativeLine)

associativeLineBuilder2.StartPoint.Value = newPt3
associativeLineBuilder2.StartPointOptions = Features.AssociativeLineBuilder.StartOption.Point

associativeLineBuilder2.EndPoint.Value = newPt4
associativeLineBuilder2.EndPointOptions = Features.AssociativeLineBuilder.EndOption.Point

Dim myLineFeature2 As Features.AssociativeLine
myLineFeature2 = associativeLineBuilder2.Commit()

associativeLineBuilder2.Destroy()

lw.Close()

End Sub

Public Function GetUnloadOption(ByVal dummy As String) As Integer

'Unloads the image when the NX session terminates
GetUnloadOption = NXOpen.Session.LibraryUnloadOption.AtTermination

End Function

End Module

so thanks

can you answer few questions?
1. where do you learn this?
2. what is the difference between your and my code, why my code didn't work?

thanks again

I'll answer the questions in reverse order.

The difference in the code that I posted is it creates 4 additional points that are later used to define the line end points. Internally, NX uses "smart objects" to define and maintain associativity between objects. Points, xforms, offsets, and directions are all examples of smart objects (there are others, as well). You'll see that my code has some additional lines of code that look like:

newPt1 = workPart.Points.CreatePoint(CType(myPointFeature1.GetEntities(0), Point), nullXform, SmartObject.UpdateOption.WithinModeling)

This code finds the point object from the point feature and creates a new "smart object" point on top of it. When the point object moves, NX updates the position of the smart point as well. This new smart point is used as one of the line end points. So, why did I do this? Why not use the point object from the point feature directly? I recorded a journal then created 2 points and a line between them and studied the output code. I emulated the approach taken by the journal recorder; I don't know all the inner workings of NX, so I can only guess as to why you cannot use the feature points directly (you'll get an error if you try). Some other smart objects are discussed in this article:
http://nxjournaling.com/content/point3d-and-point-objects-part-2

Which leads me to your first question: "where do I learn this stuff?". Studying the output code from the journal recorder has taught me the most about using NXOpen. Other good learning resources are the help files (programmer's guide, SNAP guide, API reference, etc) and participating in various forums.