⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 boltjavascript.js

📁 CATIA二次开发
💻 JS
字号:
  var CATIA 
    
  CATIA = WScript.GetObject("","CATIA.Application");
  if ( CATIA == null) {
    CATIA = WScript.CreateObject("CATIA.Application");
  }
  CATIA.Visible = true;
  
  // Add a new Part
  MyDocument = CATIA.Documents.Add("Part");
  PartFactory = MyDocument.Part.ShapeFactory ; //  Retrieve the Part Factory.
  MyBody1 = MyDocument.Part.Bodies.Item("PartBody");
  CATIA.ActiveDocument.Part.InWorkObject = MyBody1; // Activate "PartDesign"
  
// Creating the Shaft
  ReferencePlane1 = MyDocument.Part.CreateReferenceFromGeometry(MyDocument.Part.OriginElements.PlaneYZ);
  
  // Create the sketch1 on ReferencePlane1
  Sketch1 = MyBody1.Sketches.Add(ReferencePlane1);
  MyFactory1 = Sketch1.OpenEdition();// Define the sketch

  h1 = 80; // height of the bolt
  h2 = 300; // total height
  r1 = 120; // external radius
  r2 = 60; // Internal radius
  s1 = 20; // Size of the chamfer
  
  l101 = MyFactory1.CreateLine(0, 0, r1 - 20, 0);
  l102 = MyFactory1.CreateLine(r1 - 20, 0, r1, -20);
  l103 = MyFactory1.CreateLine(r1, -20, r1, -h1 + 20);
  l104 = MyFactory1.CreateLine(r1, -h1 + 20, r1 - 20, -h1);
  l105 = MyFactory1.CreateLine(r1 - 20, -h1, r2, -h1);
  l106 = MyFactory1.CreateLine(r2, -h1, r2, -h2 + s1);
  l107 = MyFactory1.CreateLine(r2, -h2 + s1, r2 - s1, -h2);
  l108 = MyFactory1.CreateLine(r2 - s1, -h2, 0, -h2);
  l109 = MyFactory1.CreateLine(0, -h2, 0, 0);
  Sketch1.CenterLine = l109;
  
  Sketch1.CloseEdition();
  AxisPad1 = PartFactory.AddNewShaft(Sketch1);
  
// Creating the Pocket
  ReferencePlane2 = MyDocument.Part.CreateReferenceFromGeometry(MyDocument.Part.OriginElements.PlaneXY);
    
  // Create the sketch2 on ReferencePlane2
  Sketch2 = MyBody1.Sketches.Add(ReferencePlane2);
  MyFactory2 = Sketch2.OpenEdition(); // Define the sketch
  D = 1 / 0.866;
  
  l201 = MyFactory2.CreateLine(D * 100, 0, D * 50, D * 86.6);
  l202 = MyFactory2.CreateLine(D * 50, D * 86.6, D * -50, D * 86.6);
  l203 = MyFactory2.CreateLine(D * -50, D * 86.6, D * -100, 0);
  l204 = MyFactory2.CreateLine(D * -100, 0, D * -50, D * -86.6);
  l205 = MyFactory2.CreateLine(D * -50, D * -86.6, D * 50, D * -86.6);
  l206 = MyFactory2.CreateLine(D * 50, D * -86.6, D * 100, 0);

  // Create a big circle around the form to get a Hole
  c2 = MyFactory2.CreateClosedCircle(0, 0, 300);
  
  Sketch2.CloseEdition();
  AxisHole2 = PartFactory.AddNewPocket(Sketch2, h1);
  
  MyDocument.Part.Update();

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -