Quantcast
Channel: Dotnet/C# – Xinyustudio
Viewing all articles
Browse latest Browse all 204

Extending Unigraphics NX using C# (III) Accessing entities

$
0
0

In Unigraphics, there are two files which are especially for programmers.

  1. The .net reference, in the folder %UGDir\UGDOC\html_files\nxopen_net_ref.chm, which contains all the class references;
  2. The .net programming guide, in the folder %UGDir\UGDOC\html_files\nxopen_net_ref\index.htm .

The 2nd is esp. useful at the initial programming stages.

For instance, in the programming guide, it is clearlly noted the methods of retrieving the entities:

 

  • NX session → list of parts

  • part → list of solid bodies

  • solid body → list of faces

    solid body → list of edges

  • face → list of associated edges

    face → solid body

  • edge → list of associated faces

    edge → solid body

Using this, it is very easy to access the entities:

            theSession = Session.GetSession();
            FeatureTree.Nodes.Clear();
            PartCollection sessionParts = theSession.Parts;
            foreach (Part p in sessionParts)
            {
                if (p.IsFullyLoaded)
                {
                    TreeNode PartNode =new TreeNode(p.Leaf);
                    FeatureTree.Nodes.Add(PartNode);
                    foreach (Body body in p.Bodies)
                    {
                        TreeNode BodyNode=new TreeNode(body.JournalIdentifier);
                        BodyNode.Tag = body;
                        PartNode.Nodes.Add(BodyNode);
                    }
                }
            }


Filed under: CAD, Dotnet/C#

Viewing all articles
Browse latest Browse all 204

Trending Articles