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


Best way to check connected curves ?

Best way to check connected curves ?

Best way to check connected curves ?

I have a pretty basic question.

I am trying to write a macro to check connected curves in the model, the old way to check is using the project curve feature and select a connected curve. it takes a lot of time if I have many curves.

can you help me another way to improve it

RE: Best way to check connected curves ?

Knowing what version of NX you're using would be quite helpful.

Tim Flater
NX Designer
NX MP11 Rev. A
GM TcE v11.2.3.1
GM GPDL v11-A.3.5.1
Win7 Enterprise x64 SP1
Intel Core i7 2.5GHz 16GB RAM
4GB NVIDIA Quadro K3100M

RE: Best way to check connected curves ?

Are you working with edges on a body? If so, the .AskCnncEdges method might be helpful. It appears that it will only work with edges and won't accept curves (lines, arcs, splines, etc) as input.


RE: Best way to check connected curves ?

Thanks @Cowski ,i will try it

RE: Best way to check connected curves ?

I tried, but it not work, can you help me fix my code, Thanks

I tried to write a demo code, change the color of the connected curve

CODE -->

using System;
using NXOpen;
using NXOpen.UF;

public class NXJournal
    static Session theSession = Session.GetSession();
    static UFSession theUFSession = UFSession.GetUFSession();
    static Part workPart = theSession.Parts.Work;

    public static void Main(string[] args)
		Curve[] theCurves = SelectCurves("Select connected curves");
        if (theCurves.Length == 0) return;
        System.Collections.Generic.List<Curve>[] sortedCurves = sort_by_connectivity(theCurves);
		DisplayModification displayModification1;
        displayModification1 = theSession.DisplayManager.NewDisplayModification();
        displayModification1.ApplyToAllFaces = false;
        displayModification1.ApplyToOwningParts = false;
        displayModification1.NewColor = 11;
    // ----------------------------

    static System.Collections.Generic.List<Curve>[] sort_by_connectivity(Curve[] theCurves)
        NXOpen.Session.UndoMarkId markId1;
        markId1 = theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Invisible, "");

        System.Collections.Generic.List<Tag> theCurveTags =
            new System.Collections.Generic.List<Tag>();
        foreach (Curve aCurve in theCurves) theCurveTags.Add(aCurve.Tag);
        int n_joined;
        Tag[] joined = new Tag[theCurveTags.Count];
        theUFSession.Curve.AutoJoinCurves(theCurveTags.ToArray(), theCurveTags.Count,
            2, joined, out n_joined);

        System.Collections.Generic.List<Curve>[] CurveLists =
            new  System.Collections.Generic.List<Curve>[n_joined];
        for (int ii = 0; ii < n_joined; ii++)
            CurveLists[ii] = new System.Collections.Generic.List<Curve>();

        foreach (Curve aCurve in theCurves)
            double min_dist;
            double[] junk = new double[3];
            double accuracy;
            int which = 0;
            theUFSession.Modl.AskMinimumDist3(2, joined[0], aCurve.Tag, 0, junk, 0, junk,
                out min_dist, junk, junk, out accuracy);

            for (int ii = 1; ii < n_joined; ii++)
                double this_dist;
                theUFSession.Modl.AskMinimumDist3(2, joined[ii], aCurve.Tag, 0, junk, 0, junk,
                    out this_dist, junk, junk, out accuracy);
                if (this_dist < min_dist)
                    min_dist = this_dist;
                    which = ii;

        theSession.UndoToMark(markId1, "");
        theSession.DeleteUndoMark(markId1, "");

        return CurveLists;

    static Curve[] SelectCurves(string prompt)
        TaggedObject[] selobjs = null;

        Selection.Response resp =
            UI.GetUI().SelectionManager.SelectTaggedObjects(prompt, "Select Curves",
            Selection.SelectionScope.WorkPart, false,
            new Selection.SelectionType[] { Selection.SelectionType.Curves },
            out selobjs);

        System.Collections.Generic.List<Curve> theCurves =
            new System.Collections.Generic.List<Curve>();
        foreach (TaggedObject aTO in selobjs)
            if (aTO is Curve) theCurves.Add((Curve)aTO);

        return theCurves.ToArray();

    public static int GetUnloadOption(string arg)
        return System.Convert.ToInt32(Session.LibraryUnloadOption.Immediately);

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! Already a Member? Login


White Paper - Considerations for choosing a 3D printing technology
The adoption of 3D printing into major companies’ product development life cycles is a testament to the technology’s incredible benefits to consumers, designers, engineers and manufacturers. While traditional production methods have limitations in manufacturability, 3D printing provides unparalleled design freedom due to the additive method of building parts layer by layer. Download Now
White Paper - Are all 3D printed metals the same?
With so many different 3D printing metal systems and processes today, how can you know exactly what you’re getting? Today, there are several different methods for manufacturing 3D printed metal components with their own strengths and limits. Download Now

Close Box

Join Eng-Tips® Today!

Join your peers on the Internet's largest technical engineering professional community.
It's easy to join and it's free.

Here's Why Members Love Eng-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close