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); }
public static bool SetVisibilityOn(this Document doc) { var sel = SelectionExt.SelectInvisible(); sel.VisProperties.SetShow(CatVisPropertyShow.catVisPropertyShowAttr); sel.Clear(); return(true); }
public Selection SelectUnderNode() { if (!SelectNode()) { throw new NotFoundException(); } return(SelectionExt.SelectUnderSelection()); }
public static bool PasteSelection(this Selection sel, string destination) { sel.Copy(); sel = SelectionExt.SelectPart(destination); sel.Paste2(); sel.Clear(); return(true); }
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); }
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); }
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); }
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); }
public static Product GetLeafProduct(string instance) { var sel = SelectionExt.SelectInstances(instance); return((Product)sel.GetLeafProducts().FirstOrDefault()); }
public static Document GetDocument(string instance) { var sel = SelectionExt.SelectInstances(instance); return(sel.GetDocuments().FirstOrDefault()); }