ImageVerifierCode 换一换
格式:DOCX , 页数:20 ,大小:19.13KB ,
资源ID:5512706      下载积分:3 金币
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.bdocx.com/down/5512706.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(CATIA V5 Automation Detailed Steps基于VB的catia二次开发代码.docx)为本站会员(b****4)主动上传,冰豆网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰豆网(发送邮件至service@bdocx.com或直接QQ联系客服),我们立即给予删除!

CATIA V5 Automation Detailed Steps基于VB的catia二次开发代码.docx

1、CATIA V5 Automation Detailed Steps基于VB的catia二次开发代码CATIA V5 AutomationDetailed StepsTable of ContentsViews.vbp 3PartDesign.vbp 5ShapeDesign.vbp 8Assembly.vbp 12Drafting.vbp 15GetPoint.vbp 18TestSelections.vbp 20Views.vbpOption ExplicitDim CATIA As INFITF.ApplicationDim myDoc As PartDocumentPrivate Su

2、b Command1_Click()On Error Resume NextSet CATIA = GetObject(, CATIA.Application)If Err.Number 0 Then Set CATIA = CreateObject(CATIA.Application) CATIA.Visible = TrueEnd IfOn Error GoTo 0 Opening Bolt.CATPartDim myDir As StringmyDir = App.PathSet myDoc = CATIA.Documents.Open(myDir & Bolt.CATPart)Dim

3、myViewer3 As Viewer3DDim myViewPoint As Viewpoint3D Getting the active ViewerSet myViewer3 = CATIA.ActiveWindow.ActiveViewermyViewer3.RenderingMode = catRenderShadingDim myCam3d As Camera3DDim i As Integer Display the number of defined cameras.MsgBox myDoc.Cameras.Count Scaning all the cameras of th

4、e documentFor i = 1 To myDoc.Cameras.Count Set myCam3d = myDoc.Cameras.Item(i) Modifying the Viewpoint3D of the active viewer myViewer3.Viewpoint3D = myCam3d.Viewpoint3D myViewer3.Reframe myViewer3.ZoomIn myViewer3.Update MsgBox myCam3d.NameNext Selecting the front cameraSet myCam3d = myDoc.Cameras.

5、Item(* front)myViewer3.Viewpoint3D = myCam3d.Viewpoint3D Saving the documentIf MsgBox(Save Bolt2, vbOKCancel) = vbOK Then On Error Resume Next Kill (myDir & Bolt2.CATPart) Call myDoc.SaveAs(myDir & Bolt2.CATPart) Call myDoc.Close On Error GoTo 0End IfEnd SubPartDesign.vbpOption ExplicitDim CATIA As

6、INFITF.ApplicationPrivate Sub Command1_Click() On Error Resume NextSet CATIA = GetObject(, CATIA.Application)If Err.Number 0 Then Set CATIA = CreateObject(CATIA.Application) CATIA.Visible = TrueEnd IfOn Error GoTo 0 Creating a new PartDim MyDoc As PartDocumentSet MyDoc = CATIA.Documents.Add(Part) Ge

7、tting the default Body called MechanicalTool.1 (internal name)Dim myBody As BodySet myBody = MyDoc.Part.Bodies.Item(MechanicalTool.1) Activating the body as the InWorkObjectMyDoc.Part.InWorkObject = myBody Creating a reference on XY planeDim ReferencePlane As ReferenceSet ReferencePlane = MyDoc.Part

8、.CreateReferenceFromGeometry(MyDoc.Part.OriginElements.PlaneXY) Creating mySketch1 on XY PlaneDim mySketch1 As SketchSet mySketch1 = myBody.Sketches.Add(ReferencePlane) Opening mySketch1 and getting the factoryDim MyFactory1 As Factory2DSet MyFactory1 = mySketch1.OpenEdition() Creating 4 linesDim l1

9、 As Line2DDim l2 As Line2DDim l3 As Line2DDim l4 As Line2DSet l1 = MyFactory1.CreateLine(10#, 10#, 10#, 30#)Set l2 = MyFactory1.CreateLine(10#, 30#, 40#, 30#)Set l3 = MyFactory1.CreateLine(40#, 30#, 40#, 10#)Set l4 = MyFactory1.CreateLine(40#, 10#, 10#, 10#)mySketch1.CloseEdition Creating mySketch2

10、on XY PlaneDim mySketch2 As SketchSet mySketch2 = myBody.Sketches.Add(ReferencePlane) Opening mySketch2 and getting the factoryDim MyFactory2 As Factory2DSet MyFactory2 = mySketch2.OpenEdition() Creating 1 CircleDim c1 As Circle2DSet c1 = MyFactory2.CreateClosedCircle(40#, 30#, 10#)mySketch2.CloseEd

11、ition Getting the shapeFactoryDim MyFact As ShapeFactorySet MyFact = MyDoc.Part.ShapeFactory Creating a padDim myPad As PadSet myPad = MyFact.AddNewPad(mySketch1, 20) Creating a PocketDim myPok As PocketSet myPok = MyFact.AddNewPocket(mySketch2, -20)MyDoc.Part.Update Reframing the window on the part

12、CATIA.ActiveWindow.ActiveViewer.ReframeEnd SubShapeDesign.vbpOption ExplicitDim CATIA As INFITF.ApplicationPrivate Sub Command1_Click() On Error Resume NextSet CATIA = GetObject(, CATIA.Application)If Err.Number 0 Then Set CATIA = CreateObject(CATIA.Application) CATIA.Visible = TrueEnd IfOn Error Go

13、To 0Dim myPartDocument As PartDocumentSet myPartDocument = CATIA.Documents.Add(Part)Dim myPart As PartSet myPart = myPartDocument.PartCreating an Open_body if not already existingOn Error Resume NextDim myHybridBody As HybridBodySet myHybridBody = myPart.HybridBodies.Item(Open_body.1)If myHybridBody

14、 Is Nothing Then Set myHybridBody = myPart.HybridBodies.AddEnd IfOn Error GoTo 0Dim MyHSFact As HybridShapeFactorySet MyHSFact = myPart.HybridShapeFactorymyPart.Update Creating 6 PointsDim HyPt1 As HybridShapePointCoordDim HyPt2 As HybridShapePointCoordDim HyPt3 As HybridShapePointCoordDim HyPt4 As

15、HybridShapePointCoordDim HyPt5 As HybridShapePointCoordDim HyPt6 As HybridShapePointCoordSet HyPt1 = MyHSFact.AddNewPointCoord(10#, 60#, 30#)Set HyPt2 = MyHSFact.AddNewPointCoord(70#, 75#, 35#)Set HyPt3 = MyHSFact.AddNewPointCoord(100#, 80#, 30#)Set HyPt4 = MyHSFact.AddNewPointCoord(100#, 80#, 40#)S

16、et HyPt5 = MyHSFact.AddNewPointCoord(95#, 20#, 45#)Set HyPt6 = MyHSFact.AddNewPointCoord(100#, 10#, 50#) Creating references on the pointsDim R1 As ReferenceDim R2 As ReferenceDim R3 As ReferenceDim R4 As ReferenceDim R5 As ReferenceDim R6 As ReferenceSet R1 = myPart.CreateReferenceFromGeometry(HyPt

17、1)Set R2 = myPart.CreateReferenceFromGeometry(HyPt2)Set R3 = myPart.CreateReferenceFromGeometry(HyPt3)Set R4 = myPart.CreateReferenceFromGeometry(HyPt4)Set R5 = myPart.CreateReferenceFromGeometry(HyPt5)Set R6 = myPart.CreateReferenceFromGeometry(HyPt6)Dim myControlPoint As HybridShapeControlPoint We

18、 can reuse the same variable: myControlPoint Creating first SplineDim HyLine1 As HybridShapeSplineSet HyLine1 = MyHSFact.AddNewSplineHyLine1.SetSplineType 0HyLine1.SetClosing 0 Adding the control pointsSet myControlPoint = MyHSFact.AddNewControlPoint(R1)HyLine1.AddControlPoint myControlPointSet myCo

19、ntrolPoint = MyHSFact.AddNewControlPoint(R2)HyLine1.AddControlPoint myControlPointSet myControlPoint = MyHSFact.AddNewControlPoint(R3)HyLine1.AddControlPoint myControlPoint Creating second SplineDim HyLine2 As HybridShapeSplineSet HyLine2 = MyHSFact.AddNewSplineCall HyLine2.SetSplineType(0)Call HyLi

20、ne2.SetClosing(0)Set myControlPoint = MyHSFact.AddNewControlPoint(R4)HyLine2.AddControlPoint myControlPointSet myControlPoint = MyHSFact.AddNewControlPoint(R5)HyLine2.AddControlPoint myControlPointSet myControlPoint = MyHSFact.AddNewControlPoint(R6)HyLine2.AddControlPoint myControlPointDim Ref1 As R

21、eferenceDim Ref2 As Reference Creating a SweepSet Ref1 = myPart.CreateReferenceFromGeometry(HyLine1)Set Ref2 = myPart.CreateReferenceFromGeometry(HyLine2)Dim HybridShapeSweepExplicit1 As HybridShapeSweepExplicitSet HybridShapeSweepExplicit1 = MyHSFact.AddNewSweepExplicit(Ref1, Ref2)myHybridBody.Appe

22、ndHybridShape HyLine1myHybridBody.AppendHybridShape HyLine2myHybridBody.AppendHybridShape HybridShapeSweepExplicit1 Creating a 3D PointDim HyPt7 As HybridShapePointCoordSet HyPt7 = MyHSFact.AddNewPointCoord(50#, 30#, 100#)myHybridBody.AppendHybridShape HyPt7 Creating the projection of HyPt7 on the s

23、urface HybridShapeSweepExplicit1Dim Ref3 As ReferenceDim Ref4 As ReferenceSet Ref3 = myPart.CreateReferenceFromGeometry(HyPt7)Set Ref4 = myPart.CreateReferenceFromGeometry(HybridShapeSweepExplicit1)Dim HybridShapeProject1 As HybridShapeProjectSet HybridShapeProject1 = MyHSFact.AddNewProject(Ref3, Re

24、f4)myHybridBody.AppendHybridShape HybridShapeProject1myPart.UpdateEnd SubAssembly.vbpOption ExplicitDim CATIA As ObjectPrivate Sub Command1_Click()Dim i As IntegerReDim myNames(1) As StringOn Error Resume NextSet CATIA = GetObject(, CATIA.Application)If Err.Number 0 Then Set CATIA = CreateObject(CAT

25、IA.Application) CATIA.Visible = TrueEnd IfOn Error GoTo 0Dim myDir As StringmyDir = App.Path Creating the root productDim Titanic As ProductDocumentSet Titanic = CATIA.Documents.Add(Product) Creating the hull at level 1myNames(0) = myDir + Hull.CATPartCall Titanic.Product.Products.AddComponentsFromF

26、iles(myNames, *)Titanic.Product.PartNumber = TitanicDim assy1 As Product Creating sub-product ass1 at level 1New Product not associated with a ProductDocument fileSet assy1 = Titanic.Product.Products.AddNewProduct(ass1) Creating the Castle under ass1 at level 2myNames(0) = myDir + Castle.CATPartCall

27、 assy1.Products.AddComponentsFromFiles(myNames, *) Creating the Funnel under ass1 at level 2myNames(0) = myDir + Funnel.CATPartCall assy1.Products.AddComponentsFromFiles(myNames, *)Titanic.Product.UpdateDim Ass1RefProduct As ProductSet Ass1RefProduct = assy1.ReferenceProduct Creating 2nd instance of

28、 subproduct ass1 at level 1Dim Product2 As ProductSet Product2 = Titanic.Product.Products.AddComponent(Ass1RefProduct)Creating the transformation matrixReDim var1(11)var1(0) = 1#var1(1) = 0#var1(2) = 0#var1(3) = 0#var1(4) = 1#var1(5) = 0#var1(6) = 0#var1(7) = 0#var1(8) = 1#var1(9) = 60# translation

29、along Xvar1(10) = 0# translation along Yvar1(11) = 0# translation along Z Moving the instanceProduct2.Move.Apply var1 Creating 3rd instance of ass1 at level 1Dim Product3 As ProductSet Product3 = Titanic.Product.Products.AddComponent(Ass1RefProduct)var1(9) = 120# translation along X Moving the insta

30、nceProduct3.Move.Apply var1 Creating the Bill Of Material in the file TitanicBOM.txtCall Titanic.Product.ExtractBOM(catFileTypeText, myDir & TitanicBOM.txt)End SubDrafting.vbpOption ExplicitDim CATIA As INFITF.ApplicationPrivate Sub Command1_Click()Dim i As IntegerOn Error Resume NextSet CATIA = GetObject(, CATIA.Application)If Err.Number 0 Then Set CATIA = CreateObject(CATIA.Application) CATIA.Visible = TrueEnd IfDim myDir As StringmyDir = App.Path Opening Bolt.CATPart fileDim MyPartDoc As PartDocumentSet MyPartDoc =

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1