Exemplo n.º 1
0
        public static void Example_Selection()
        {
            var activeDoc = CatiaApplication.Instance.ActiveDocument;

            Debug.WriteLine(activeDoc.GetName());

            var selection = activeDoc.Selection;

            _ = CatiaApplication.Instance.Documents;


            selection.DebugSelection();

            Tree.ApplyWorkMode();

            var tree = new NodeTree(selection.GetDocuments().FirstOrDefault());

            tree.DebugTree();

            Debug.WriteLine("----------------------------------");

            var sel = SelectionExt.SelectUnderSelection();

            foreach (var doc in sel.GetDocuments())
            {
                Debug.WriteLine(doc.GetName());
            }

            Console.Write("Press any key to continue . . . ");
            Console.ReadKey(true);
        }
Exemplo n.º 2
0
        public static bool SetVisibilityOn(this Document doc)
        {
            var sel = SelectionExt.SelectInvisible();

            sel.VisProperties.SetShow(CatVisPropertyShow.catVisPropertyShowAttr);
            sel.Clear();
            return(true);
        }
Exemplo n.º 3
0
        public Selection SelectUnderNode()
        {
            if (!SelectNode())
            {
                throw new NotFoundException();
            }

            return(SelectionExt.SelectUnderSelection());
        }
Exemplo n.º 4
0
        public static bool PasteSelection(this Selection sel, string destination)
        {
            sel.Copy();

            sel = SelectionExt.SelectPart(destination);

            sel.Paste2();

            sel.Clear();

            return(true);
        }
Exemplo n.º 5
0
        public static bool ActivateInstance(string instance)
        {
            var sel = SelectionExt.SelectInstances(instance);

            if (sel.Count2 > 1)
            {
                throw new MultipleSelectionException("More than one node selected");
            }

            Activate();

            return(true);
        }
Exemplo n.º 6
0
        public static bool CopyPasteBreakLink(string part, string destination)
        {
            var sel = SelectionExt.SelectParts(part);

            sel.Copy();

            sel = SelectionExt.SelectPart(destination);

            sel.PasteBreakLink();

            sel.Clear();

            return(true);
        }
Exemplo n.º 7
0
        public bool SelectNode()
        {
            string tempName = GetProductName();

            var sel = SelectionExt.SelectInstances(tempName);

            if (sel.Count2 == 1)
            {
                return(true);
            }

            // problems if you dont load(design mode) in the entire tree to find the correct one

            bool found = false;
            var  lim   = sel.Count2 + 1;

            for (int i = 1; i < lim; i++)
            {
                var tempLeaf = (Product)sel.Item2(i).LeafProduct;
                var t1       = tempLeaf.GetRootRelationship().RemoveAtWithNegative(-1).ToList();
                var t2       = this.GetRootRelationship().RemoveAtWithNegative(-1).ToList();

                for (int j = t2.Count; j <= t1.Count; j++)
                {
                    t1.RemoveAtWithNegative(-1).ToList();
                }

                if (t1.Compare1(t2))
                {
                    found = true;
                }
                else
                {
                    sel.Remove2(i);
                    i--;
                    lim--;
                }
            }
            return(found);
        }
Exemplo n.º 8
0
        public static void PrintTreeNames()
        {
            Application catia = CatiaApplication.Instance;

            var doc             = catia.ActiveDocument;
            var productDocument = doc.AsProductDocument();
            var product         = productDocument.Product.AsProduct();

            Console.WriteLine(doc.GetName());

            Console.WriteLine(productDocument.GetName());

            Console.WriteLine(product.GetName());

            Console.WriteLine(Feature.GetType2(doc));

            var tree = new NodeTree(productDocument);

            //var names = tree.list.Select(x => x);

            var names = tree.list.Select(x => x.GetProductName());

            Console.WriteLine(names.Join2(" "));

            var sel = SelectionExt.SelectAll();

            var names_sel = sel.GetInstanceNames();

            Console.WriteLine(names_sel.Join2(" "));


            tree.list[0].SelectNode();

            System.Threading.Thread.Sleep(1000);

            tree.list[2].SelectNode();

            System.Threading.Thread.Sleep(1000);
        }
Exemplo n.º 9
0
        public static Product GetLeafProduct(string instance)
        {
            var sel = SelectionExt.SelectInstances(instance);

            return((Product)sel.GetLeafProducts().FirstOrDefault());
        }
Exemplo n.º 10
0
        public static Document GetDocument(string instance)
        {
            var sel = SelectionExt.SelectInstances(instance);

            return(sel.GetDocuments().FirstOrDefault());
        }