Hello,
I am using Nx8.5 and I have some troubles on revolving of lines. I both followed Nxopen manual and recorded journal.
Due to having trouble with this line of code,
Dim r1 As NXOpen.CurveDumbRule = workPart.ScRuleFactory.CreateRuleBaseCurveDumb({c1})
I had to switch to get help from a recorded journal:
curveDumbRule1 = workPart.ScRuleFactory.CreateRuleCurveDumb(curves1)
But having troubles at commit. No section curve or point created error I get.
I could not resolve it.
Thanks
Option Strict Off
Imports System
Imports System.Collections.Generic
Imports System.Linq
Imports System.Text.RegularExpressions
Imports NXOpen
Imports NXOpen.UF
Imports System.IO
Imports System.IO.Directory
Imports System.Runtime.Remoting
Imports System.Runtime.Remoting.Channels
Imports System.Text
Imports System.Diagnostics
Imports System.Collections
Imports NXOpen.Assemblies
Imports NXOpen.Utilities
Imports NXOpen.Features
Module revolvesolid
Sub Main()
Dim line1 As Tag = "33595" ' these will be comming from another loop.
Dim line2 As Tag = "33539"
Dim line3 As Tag = "33573"
Dim line4 As Tag = "33594"
Dim theSession As Session = Session.GetSession()
Dim workPart As Part = theSession.Parts.Work
Dim displayPart As Part = theSession.Parts.Display
Dim lw As ListingWindow = theSession.ListingWindow
Dim ctol = 0.0095 ' Chaining tolerance
Dim dtol = 0.01 ' Distance tolerance
Dim atol = 0.5 ' Angle tolerance
Dim rect As NXOpen.Section = workPart.Sections.CreateSection(ctol, dtol, atol)
Dim section1 As NXOpen.Section = workPart.Sections.CreateSection(ctol, dtol, atol)
Dim helpPoint As New NXOpen.Point3d(0, 0, 0)
Dim helpPoint1 As New NXOpen.Point3d(0, 0, 0)
Dim nullObj As NXOpen.NXObject = Nothing
Dim noChain As Boolean = False
Dim createMode As NXOpen.Section.Mode = Section.Mode.Create
Dim curves1(3) As Curve
Dim c1 As Line = ObjectFromTag(line1)
Dim c2 As Line = ObjectFromTag(line2)
Dim c3 As Line = ObjectFromTag(line3)
Dim c4 As Line = ObjectFromTag(line4)
curves1(0) = c1
curves1(1) = c2
curves1(2) = c3
curves1(3) = c4
section1.AllowSelfIntersection(False)
Dim curveDumbRule1 As CurveDumbRule
'curveDumbRule1 = workPart.ScRuleFactory.CreateRuleCurveDumb(curves1)
curveDumbRule1 = workPart.ScRuleFactory.CreateRuleCurveDumb(curves1)
Dim rules1(0) As SelectionIntentRule
rules1(0) = curveDumbRule1
Dim nullNXObject As NXObject = Nothing
rect.AddToSection(rules1, c1, nullObj, nullObj, helpPoint, createMode, noChain)
rect.AddToSection(rules1, c2, nullObj, nullObj, helpPoint, createMode, noChain)
rect.AddToSection(rules1, c3, nullObj, nullObj, helpPoint, createMode, noChain)
rect.AddToSection(rules1, c4, nullObj, nullObj, helpPoint, createMode, noChain)
Dim builder = workPart.Features.CreateRevolveBuilder(Nothing)
Dim axisPoint3d As New NXOpen.Point3d(0, 0, 0)
Dim axisVector As New NXOpen.Vector3d(1, 0, 0)
Dim updateOption = SmartObject.UpdateOption.WithinModeling
Dim direction = workPart.Directions.CreateDirection(axisPoint3d, axisVector, updateOption)
Dim axisPoint As NXOpen.Point = workPart.Points.CreatePoint(axisPoint3d)
builder.Axis = workPart.Axes.CreateAxis(axisPoint, direction, updateOption)
builder.Limits.StartExtend.Value.RightHandSide = "0"
builder.Limits.EndExtend.Value.RightHandSide = "180"
Dim revolveFeature As NXOpen.Features.Revolve = builder.CommitFeature
builder.Destroy()
End Sub
Public Function ObjectFromTag(tag As NXOpen.Tag) As NXOpen.NXObject
Dim obj As NXOpen.TaggedObject = NXOpen.Utilities.NXObjectManager.Get(tag)
Dim nxObject As NXOpen.NXObject = CType(obj, NXOpen.NXObject)
Return nxObject
End Function
End Module
maybe?
maybe?
Dim curves1(4) As Curve
...
curves1[0] = c1
curves1[1] = c2
curves1[2] = c3
curves1[3] = c4
NX 11, C/C++ or VB (sometimes)
re: revolve
The section that you have created, "rect", needs to be assigned to the revolve builder. Right now, you are creating the section, but not using it in the revolve builder. Add the following before calling the .CommitFeature method:
builder.Section = rect
It worked thanks
It worked thanks