Modl.CreateRuled
Modl.CreateRuled
(OP)
Has anyone used the ModlCreateRuled class in NXOpen. I am looking for some code snippets.
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS Come Join Us!Are you an
Engineering professional? Join Eng-Tips Forums!
*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail. Posting GuidelinesJobs |
|
RE: Modl.CreateRuled
www.nxjournaling.com
RE: Modl.CreateRuled
RE: Modl.CreateRuled
www.nxjournaling.com
RE: Modl.CreateRuled
Is there really a noticeable speed difference? If I understand this correctly, the UFUNC functions are wrappers for the native C calls and the NXOpen functions are wrappers for the native C++ calls. Although the C calls are faster, the language translation overhead will probably minimize the difference unless you are coding in C/C++ directly.
On topic: I did use the CreateRuled function, but it was for my now rather dated C/C++ application. Not sure if a C code snipped would be of use for you.
RE: Modl.CreateRuled
Anywho.....I did use the CreateRuleBuilder. If anyone is interested here is the final working code. I think it is good when people post working code snippets. Because we all learn from each other. Any Comments???
Private Function ThroatArea(ByVal line1 As Line, ByVal line2 As Line) As Face
Dim nullFeatures_Feature As Features.Feature = Nothing
Dim ruledBuilder1 As Features.RuledBuilder
ruledBuilder1 = workPart.Features.CreateRuledBuilder(Nothing)
ruledBuilder1.PositionTolerance = 0.0004
ruledBuilder1.IsShapePreserved = False
ruledBuilder1.FirstSection.DistanceTolerance = 0.0004
ruledBuilder1.FirstSection.ChainingTolerance = 0.00038
ruledBuilder1.SecondSection.DistanceTolerance = 0.0004
ruledBuilder1.SecondSection.ChainingTolerance = 0.00038
ruledBuilder1.AlignmentMethod.AlignCurve.DistanceTolerance = 0.0004
ruledBuilder1.AlignmentMethod.AlignCurve.ChainingTolerance = 0.00038
ruledBuilder1.FirstSection.SetAllowedEntityTypes(Section.AllowTypes.CurvesAndPoints)
Dim curves1(0) As IBaseCurve
curves1(0) = line1
Dim curveDumbRule1 As CurveDumbRule
curveDumbRule1 = workPart.ScRuleFactory.CreateRuleBaseCurveDumb(curves1)
ruledBuilder1.FirstSection.AllowSelfIntersection(True)
Dim rules1(0) As SelectionIntentRule
rules1(0) = curveDumbRule1
Dim helpPoint1 As Point3d = New Point3d(line1.StartPoint.X, line1.StartPoint.Y, line1.StartPoint.Z)
ruledBuilder1.FirstSection.AddToSection(rules1, line1, Nothing, Nothing, helpPoint1, Section.Mode.Create, False)
ruledBuilder1.SecondSection.SetAllowedEntityTypes(Section.AllowTypes.OnlyCurves)
' Second Line
Dim curves2(0) As IBaseCurve
curves2(0) = line2
Dim curveDumbRule2 As CurveDumbRule
curveDumbRule2 = workPart.ScRuleFactory.CreateRuleBaseCurveDumb(curves2)
ruledBuilder1.SecondSection.AllowSelfIntersection(True)
Dim rules2(0) As SelectionIntentRule
rules2(0) = curveDumbRule2
Dim helpPoint2 As Point3d = New Point3d(line2.StartPoint.X, line2.StartPoint.Y, line2.StartPoint.Z)
ruledBuilder1.SecondSection.AddToSection(rules2, line2, Nothing, Nothing, helpPoint2, Section.Mode.Create, False)
Dim sections1(1) As Section
sections1(0) = ruledBuilder1.FirstSection
sections1(1) = ruledBuilder1.SecondSection
ruledBuilder1.AlignmentMethod.SetSections(sections1)
Dim nXObject1 As NXObject
nXObject1 = ruledBuilder1.Commit()
Dim objects1(0) As DisplayableObject
Dim ruled1 As Features.Ruled = CType(nXObject1, Features.Ruled)
ruledBuilder1.Destroy()
Dim hoop() As Face = ruled1.GetFaces()
Return hoop(0)
End Function
RE: Modl.CreateRuled
If you are using "Option Strict Off", which I believe is the default for the journal recorder, you should be able to replace this code:
CODE
Dim nXObject1 As NXObject nXObject1 = ruledBuilder1.Commit() Dim objects1(0) As DisplayableObject '<--- unused, it can be deleted Dim ruled1 As Features.Ruled = CType(nXObject1, Features.Ruled)With this:
CODE
The .StartPoint (or .EndPoint) property of a line object will return a Point3d structure; the "helpPoints" can be defined like this:
CODE
Technically, the "helpPoints" are not needed; you could just use the line.StartPoint in place of it in the .AddToSection method call. As a matter of personal preference, I'd keep the "helpPoints". It is a bit more verbose, but it would help jog my memory when I look at the code again in the future. Also, it aligns with the API documentation verbage; one could immediately see that you are using the .StartPoint as the helpPoint in the .AddToSection method.
www.nxjournaling.com