/// <param name="type">accepting params: {Cross, ZigZag}</param> public static void mainAction(grooveType type, double width, double depth, double edges, bool isolateKeyAuto, bool debugRastr, bool debugInflated) { //all try try { MainAction.isolateKeyAuto = isolateKeyAuto; MainAction.debugRastr = debugRastr; MainAction.debugInflated = debugInflated; MainAction.width = width; MainAction.depth = depth; MainAction.edges = edges; MainAction.type = type; try { catiaInstance = (INFITF.Application)System.Runtime.InteropServices.Marshal.GetActiveObject("Catia.Application"); } catch { return; } oPartDocument = (MECMOD.PartDocument)catiaInstance.ActiveDocument; MECMOD.PlanarFace oPlanarFace = null; INFITF.Reference oReference = null; List <PlanarfaceWithReference> selectedPlanarfaces = new List <PlanarfaceWithReference>(); int selectionCount = Int32.Parse(oPartDocument.Selection.Count2.ToString()); if (selectionCount >= 1) { for (int i = 1; i <= selectionCount; i++) { try { oPlanarFace = (MECMOD.PlanarFace)oPartDocument.Selection.Item2(i).Value; oReference = (INFITF.Reference)oPartDocument.Selection.Item2(i).Value; selectedPlanarfaces.Add(new PlanarfaceWithReference(oPlanarFace, oReference)); } catch { } } } if (selectedPlanarfaces.Count >= 1) { foreach (PlanarfaceWithReference cpl in selectedPlanarfaces) { action(cpl); } } else { MainForm.myForm.Activate(); MessageBox.Show("First select one or more planar faces!"); return; } //all catch } catch {} }
/// <param name="type">accepting params: {Cross, ZigZag}</param> public static void mainAction(grooveType type, double width, double depth, double edges, bool isolateKeyAuto, bool debugRastr, bool debugInflated ) { //all try try { MainAction.isolateKeyAuto = isolateKeyAuto; MainAction.debugRastr = debugRastr; MainAction.debugInflated = debugInflated; MainAction.width = width; MainAction.depth = depth; MainAction.edges = edges; MainAction.type = type; try { catiaInstance = (INFITF.Application)System.Runtime.InteropServices.Marshal.GetActiveObject("Catia.Application"); } catch {return;} oPartDocument = (MECMOD.PartDocument)catiaInstance.ActiveDocument; MECMOD.PlanarFace oPlanarFace = null; INFITF.Reference oReference = null; List<PlanarfaceWithReference> selectedPlanarfaces = new List<PlanarfaceWithReference>(); int selectionCount = Int32.Parse( oPartDocument.Selection.Count2.ToString()); if (selectionCount>=1) { for (int i = 1; i <= selectionCount; i++) { try { oPlanarFace = (MECMOD.PlanarFace )oPartDocument.Selection.Item2(i).Value; oReference = (INFITF.Reference)oPartDocument.Selection.Item2(i).Value; selectedPlanarfaces.Add(new PlanarfaceWithReference( oPlanarFace,oReference)); } catch{ } } } if (selectedPlanarfaces.Count>=1) { foreach (PlanarfaceWithReference cpl in selectedPlanarfaces) { action(cpl); } } else { MainForm.myForm.Activate(); MessageBox.Show("First select one or more planar faces!"); return; } //all catch } catch {} }