Quantcast
Channel: NX Journaling - Journaling / NXOpen API
Viewing all articles
Browse latest Browse all 787

[NXOpen VB.NET Journal] Working with Builders

$
0
0

Hello to everyone,

I'm trying to understand how to work with Builder features in NXOpen.
For example, if I want to make a circle with a diameter of 100.00mm, I usually have two ways:

1. Using the following journal VB code:

Option Strict Off
Imports System
Imports NXOpen
Module NXJournal
Sub Main (ByVal args() As String) 
Dim theSession As NXOpen.Session = NXOpen.Session.GetSession()
Dim workPart As NXOpen.Part = theSession.Parts.Work
Dim displayPart As NXOpen.Part = theSession.Parts.Display
 
Dim origin3d As NXOpen.Point3d = New NXOpen.Point3d(0, 0, 0)
Dim arc_test As NXOpen.Arc
Dim Y As NXOpen.Vector3d = New NXOpen.Vector3d(0, 1, 0)
Dim Z As NXOpen.Vector3d = New NXOpen.Vector3d(0, 0, 1)
arc_test = workPart.Curves.CreateArc(origin3d, Y, Z, 50, 0, 2*System.Math.Pi)
MsgBox("Radius value is " & arc_test.Radius)
 
End Sub
End Module

2. Recording a Journal, then editing the code.

If I choose the second option, after tuning the output code of the recorded journal I obtain this result:

Option Strict Off
Imports System
Imports NXOpen
Module NXJournal
Sub Main (ByVal args() As String) 
Dim theSession As NXOpen.Session = NXOpen.Session.GetSession()
Dim workPart As NXOpen.Part = theSession.Parts.Work
Dim displayPart As NXOpen.Part = theSession.Parts.Display
 
Dim nullNXOpen_Features_AssociativeArc As NXOpen.Features.AssociativeArc = Nothing
Dim associativeArcBuilder1 As NXOpen.Features.AssociativeArcBuilder
associativeArcBuilder1 = workPart.BaseFeatures.CreateAssociativeArcBuilder(nullNXOpen_Features_AssociativeArc)
 
associativeArcBuilder1.Associative = False
 
associativeArcBuilder1.Type = NXOpen.Features.AssociativeArcBuilder.Types.ArcFromCenter
associativeArcBuilder1.CenterPointReference = NXOpen.Features.AssociativeArcBuilder.CenterReference.Absolute
Dim origin3d As NXOpen.Point3d = New NXOpen.Point3d(0, 0, 0)
Dim origin As NXOpen.Point = workPart.Points.CreatePoint(origin3d)
associativeArcBuilder1.CenterPoint.Value = origin
 
associativeArcBuilder1.EndPointOptions = NXOpen.Features.AssociativeArcBuilder.EndOption.Radius
associativeArcBuilder1.Radius.RightHandSide = "50"
associativeArcBuilder1.Limits.FullCircle = True
 
Dim arc_test As NXOpen.Arc
arc_test = associativeArcBuilder1.Commit()
associativeArcBuilder1.Destroy()
 
MsgBox("Radius value is " & arc_test.Radius)
 
End Sub
End Module

To test the code, I simply ask for the radius value of the arc through a message box, which does not work in the second case.
If I use the first method, the radius value is correctly shown on a message box.

Now the question is: how to work with builders?
In the second method, I declare "arc_test" as an Arc which is the result of a Commit() of a builder. This should be true. But in the reality I cannot do anythig with that arc (like an extrusion, discover the radius value, etc, etc). I can only simply see the result on the part model.

Is there anyone who can help me?
Thank You in advance, best regards,

kalo86


Viewing all articles
Browse latest Browse all 787

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>