How to make a Simple Strait extrude using 2 curves

Hello,

I'm trying to make a simple strait extrude using two curves which I know the journalling identifier or the curve tag which one is better.

I can't figure it out.

I recorded a journal, but it is a massive list of things for just a simple extrude.
create a extrudebuilder etc

I can't believe there isn't a simple command to extrude 2 curves.

thanks for you help

Are you extruding both curves a given distance? Or are you sweeping one of the curves along the other?

Extruding 2 curves in Z to make a solid

The journal recorder is a great starting point; it faithfully records all the dialog options and your actions within the dialog box. This can be a double-edged sword, however, as you often only want/need about 30% of what it gives you. In situations like this, I'll record a journal, cut out the cruft and turn it into a function that I can reuse. I'll post an example using the extrude command later.

Here's a quick example of converting the journal recorder output to a reusable function. Pass the function an array of curves, a direction, and an end distance and the extrude feature will be returned. Other features such as draft and offset are not used. I was working on an inch file when I wrote and tested the code, if you run it on a metric part, you may need to change some of the hardcoded values (especially the tolerance values).

Option Strict Off
Imports System
Imports System.Collections.Generic
Imports NXOpen

Module Module1

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

Sub Main()

If IsNothing(theSession.Parts.BaseWork) Then
'active part required
Return
End If

lw.Open()

Const undoMarkName As String = "NXJ journal"
Dim markId1 As Session.UndoMarkId
markId1 = theSession.SetUndoMark(Session.MarkVisibility.Visible, undoMarkName)

Dim myCurves As New List(Of Curve)
Dim i As Integer = 0
For Each temp As Curve In workPart.Curves
myCurves.Add(temp)
i += 1
'grab the first two curves in the curve collection for this example
If i = 2 Then
Exit For
End If
Next

Dim dirPoint As Point = workPart.Points.CreatePoint(New Point3d(0, 0, 0))
'use +Z direction for this example
Dim dirVector As Vector3d
dirVector = New Vector3d(0, 0, 1)

Dim extrudeDir As Direction = workPart.Directions.CreateDirection(dirPoint, dirVector)

Dim myExtrude As Features.Extrude = MakeExtrude(myCurves.ToArray, extrudeDir, 2.5)

'do something with the extrude feature
lw.WriteLine("extrude feature: " & myExtrude.GetFeatureName)

lw.Close()

End Sub

Function MakeExtrude(ByVal theCurves() As Curve, ByVal theDirection As Direction, ByVal endLimit As Double) As Features.Extrude

Dim nullFeatures_Feature As Features.Feature = Nothing

Dim extrudeBuilder1 As Features.ExtrudeBuilder
extrudeBuilder1 = workPart.Features.CreateExtrudeBuilder(nullFeatures_Feature)

Dim section1 As Section
section1 = workPart.Sections.CreateSection(0.00038, 0.0004, 0.5)
section1.SetAllowedEntityTypes(Section.AllowTypes.OnlyCurves)

extrudeBuilder1.Section = section1
extrudeBuilder1.AllowSelfIntersectingSection(True)
extrudeBuilder1.DistanceTolerance = 0.0004
extrudeBuilder1.BooleanOperation.Type = GeometricUtilities.BooleanOperation.BooleanType.Create
extrudeBuilder1.Limits.StartExtend.Value.RightHandSide = "0"
extrudeBuilder1.Limits.EndExtend.Value.RightHandSide = endLimit.ToString
extrudeBuilder1.Direction = theDirection

Dim curveDumbRule1 As CurveDumbRule
curveDumbRule1 = workPart.ScRuleFactory.CreateRuleBaseCurveDumb(theCurves)

Dim rules1(0) As SelectionIntentRule
rules1(0) = curveDumbRule1

For Each temp As Curve In theCurves
Dim helpPoint1 As Point3d = New Point3d(0.0, 0.0, 0.0)
section1.AddToSection(rules1, temp, Nothing, Nothing, helpPoint1, Section.Mode.Create, False)
Next

section1.AllowSelfIntersection(True)

extrudeBuilder1.BooleanOperation.Type = GeometricUtilities.BooleanOperation.BooleanType.Create

extrudeBuilder1.ParentFeatureInternal = False

Dim feature1 As Features.Extrude
feature1 = extrudeBuilder1.CommitFeature()

extrudeBuilder1.Destroy()

Return feature1

End Function

Public Function GetUnloadOption(ByVal dummy As String) As Integer

'Unloads the image immediately after execution within NX
GetUnloadOption = NXOpen.Session.LibraryUnloadOption.Immediately

End Function

End Module

> I can't believe there isn't a simple command to extrude 2 curves.

There is, but it's in SNAP, not in NX/Open.

Option Infer On
Imports Snap, Snap.Create

Public Class MyProgram

Public Shared Sub Main()

Dim c1 = Arc({1,0,0}, {0,1,0}, {-1,0,0}) ' Semi-circle
Dim c2 = Line({1,0,0}, {-1,0,0}) ' Line

' Extrude 3 units along the z-axis
Dim ext = Extrude( {c1,c2}, {0,0,1}, 3)

End Sub

End Class