/// <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 {} }
private void Form1_Load(object sender, EventArgs e) { try { catia = (INFITF.Application)Marshal.GetActiveObject("CATIA.Application"); } catch { catia = (INFITF.Application)Activator.CreateInstance(Type.GetTypeFromProgID("CATIA.Application")); catia.Visible = true; } }
public static bool InitializeCatia() { try { _catia = (INFITF.Application)Marshal.GetActiveObject(_applicationName); }catch (Exception e) { //Add logging return(false); } return(true); }
public Form1() { InitializeComponent(); try { Catia = (INFITF.Application)Marshal.GetActiveObject("CATIA.Application"); } catch { Catia = (INFITF.Application)Activator.CreateInstance(Type.GetTypeFromProgID("CATIA.Application")); Catia.Visible = true; } }
//// CATIA 관련 함수 public bool InitializeCATIA(string filePath, int mode) { try { cApp = (INFITF.Application)Marshal.GetActiveObject("CATIA.Application"); } catch { cApp = (INFITF.Application)Activator.CreateInstance(Type.GetTypeFromProgID("CATIA.Application")); } if (cApp == null) { return(false); } cDocs = cApp.Documents; if (mode == 0) { cPartDoc = (MECMOD.PartDocument)cDocs.Read(filePath); } else if (mode == 1) { cPartDoc = (MECMOD.PartDocument)cDocs.Add("Part"); } cApp.Visible = true; cPart = cPartDoc.Part; cBodies = cPart.Bodies; cFactory = cPart.ShapeFactory; cShapeFactory = (PARTITF.ShapeFactory)cFactory; cHybridShapeFactory = (HybridShapeTypeLib.HybridShapeFactory)cPart.HybridShapeFactory; cCurrentBody = cBodies.Item(1); cShapes = cCurrentBody.Shapes; cSketches = cCurrentBody.Sketches; cOriginalElements = cPart.OriginElements; if (ReferenceManager == null) { ReferenceManager = new Reference(this); } return(true); }
//form 실행과 동시에 카티아 실행한다--------------------------------- private void Form1_Load(object sender, EventArgs e) { try { catia = (INFITF.Application)Marshal.GetActiveObject("CATIA.Application"); } catch (Exception) { catia = (INFITF.Application)Activator.CreateInstance(Type.GetTypeFromProgID("CATIA.Application")); catia.Visible = true; } try { PartDocument prtDoc = (PartDocument)catia.ActiveDocument; } catch (Exception ex) { PartDocument prtDoc = (PartDocument)catia.Documents.Open(@"C:\Users\517-11\Desktop\saori\Automation\Catia-v5-Automation\TestingSelectionusingScription2\Part1.CATPart"); } }
//run the farm & catia private void Form1_Load(object sender, EventArgs e) { try { catia = (INFITF.Application)Marshal.GetActiveObject("CATIA.Application"); } catch (Exception) { catia = (INFITF.Application)Activator.CreateInstance(Type.GetTypeFromProgID("CATIA.Application")); catia.Visible = true; } try { prtDoc = (PartDocument)catia.ActiveDocument; } catch (Exception) { MessageBox.Show("Please open a document."); } }
private void Form1_Load(object sender, EventArgs e) { try { Catia = (INFITF.Application)Marshal.GetActiveObject("CATIA.Application"); } catch { Catia = (INFITF.Application)Activator.CreateInstance(Type.GetTypeFromProgID("CATIA.Application")); Catia.Visible = true; } try { doc = (MECMOD.PartDocument)Catia.ActiveDocument; } catch (Exception) { MessageBox.Show("활성 문서가 없습니다"); } }
private void Form1_Load(object sender, EventArgs e) { try { catia = (INFITF.Application)Marshal.GetActiveObject("CATIA.Application"); } catch (Exception) { catia = (INFITF.Application)Activator.CreateInstance(Type.GetTypeFromProgID("CATIA.Application")); catia.Visible = true; } /* try * { * prtDoc = (PartDocument)catia.ActiveDocument; * } * catch (Exception) * { * prtDoc = (PartDocument)catia.Documents.Add("Part"); * }*/ }
//// CATIA 관련 함수 public bool InitializeCATIA(string filePath, int mode) { /* * 어셈블리 특화 함수 구현 */ try { cApp = (INFITF.Application)Marshal.GetActiveObject("CATIA.Application"); } catch { cApp = (INFITF.Application)Activator.CreateInstance(Type.GetTypeFromProgID("CATIA.Application")); } if (cApp == null) { return(false); } cDocs = cApp.Documents; if (mode == 0) { cProductDoc = (ProductStructureTypeLib.ProductDocument)cDocs.Read(filePath); //CATProduct read } //cProductDoc = null; else if (mode == 1) { cProductDoc = (ProductStructureTypeLib.ProductDocument)cDocs.Add("Product"); //new CATProduct 생성 } cApp.Visible = true; cProduct = cProductDoc.Product; cProducts = cProduct.Products; cConstraints = (MECMOD.Constraints)cProduct.Connections("CATIAConstraints"); return(true); }
//래그 실행과 동시에 catia실행한다------------------------------ private void Form1_Load(object sender, EventArgs e) { try { catia = (INFITF.Application)Marshal.GetActiveObject("CATIA.Application"); } catch { catia = (INFITF.Application)Activator.CreateInstance(Type.GetTypeFromProgID("CATIA.Application")); catia.Visible = true; } //partDOcument 실행하기----------------- try { prtDoc = (PartDocument)catia.ActiveDocument; } catch (Exception) { MessageBox.Show("활성된 문서가 없습니다."); //PartDocument prtDoc = (PartDocument)catia.Documents.Add("Part"); } }
/// <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 {} }
public static void createAll(List <myRectangle> myRectanglesList, MECMOD.Sketch oSketch, INFITF.Application catiaInstance) { MECMOD.Factory2D oFactory2D = oSketch.OpenEdition(); double count = 0; foreach (myRectangle obl in myRectanglesList) { MECMOD.Line2D oLine2D1 = oFactory2D.CreateLine(obl.P1x, obl.P1y, obl.P2x, obl.P1y); MECMOD.Line2D oLine2D2 = oFactory2D.CreateLine(obl.P2x, obl.P1y, obl.P2x, obl.P2y); MECMOD.Line2D oLine2D3 = oFactory2D.CreateLine(obl.P2x, obl.P2y, obl.P1x, obl.P2y); MECMOD.Line2D oLine2D4 = oFactory2D.CreateLine(obl.P1x, obl.P2y, obl.P1x, obl.P1y); catiaInstance.set_StatusBar(Math.Round(count / myRectanglesList.Count * 100) + "%"); count++; } oSketch.CloseEdition(); }