×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Modl.CreateRuled

Modl.CreateRuled

Modl.CreateRuled

(OP)
Has anyone used the ModlCreateRuled class in NXOpen. I am looking for some code snippets.

RE: Modl.CreateRuled

Have you tried the journal recorder? It is a good teacher (not perfect, but good).

www.nxjournaling.com

RE: Modl.CreateRuled

(OP)
Yes. But journaling results in the using mostly builders. When I journaled creating a ruled surface, it gave me a "CreateRuledBuilder". I want to use the older UFUNC's because they are faster. The modl.createRuled is based on the older UFUNC's. Searching GTAC solution center is not coming up with any code snippets.

RE: Modl.CreateRuled

When a dedicated builder object is provided, I suggest at least trying it out. It will often provide some functionality not provided in the UF functions, such as being able to specify a curve or face selection rule. Also, it has the advantage of returning the object or feature directly as opposed to returning tags which in turn require you to use more functions to get the object you wish.

www.nxjournaling.com

RE: Modl.CreateRuled

Sometimes this goes the other way around, though: You can create a negative ruled feature with CreateRuled, but not with the Features::RuledBuilder (you need to apply a Boolean feature to it separately). But usually yes, it's better to try any use the builders because, in addition to what cowski said, the builders will often create newer "versions" of features (cuts, extrudes, rotates, holes) that have prettier and more functional "edit" dialogs.

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. smile

RE: Modl.CreateRuled

(OP)
One of the diffcult things in Journalling and then scrapping the data out of the Journal is trying to figure out the correlation between the UG dialog, Mouse Clicks, Selection of geometry and so forth. Like in the example below, the journal yielded "curveDumbRule1" and "curveDumbRule2" are these really necessary??? I've been developing in UG since V18 when knowledge fusion first came onto the scene before the journaling API and the only engineering software tool was Knowledge Fusion. I consider myself a mechanical engineer first and a programmer hacker second. I know engineering and manage developing software applications to suit my mechanical engineering design and analysis needs.

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

Quote (EngProgrammer)

the journal yielded "curveDumbRule1" and "curveDumbRule2" are these really necessary???
Yes, these are necessary. A ruled feature requires two sections and each section requires a curve selection intent rule. The curve dumb rules are used to define the selection intent rules in the code.

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

Dim ruled1 As Features.Ruled = ruledBuilder1.CommitFeature() 


The .StartPoint (or .EndPoint) property of a line object will return a Point3d structure; the "helpPoints" can be defined like this:

CODE

Dim helpPoint1 As Point3d = line1.StartPoint 

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

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources