




版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、Catia 百格线生成宏Catia 百格线生成宏你是否为在 Catia 做 2D 图纸的时候,画百格线而伤脑筋呢?别担心,接下 来我告诉你一个简单的方法1. 新建一个 txt 文本文档,比如 Draw-Grid.txt2. 把以下内容复制到 Draw-Grid.txt 中=这里开始,不要复制我=Option ExplicitI *Purpose:This macro allows you to create Grid line in CATIA drawing Author: chenqa Languages: VBScript Locales: English Developing CATI
2、A Level: V5R12View mush parallel to system aixes,view angle 0deg,90deg and -90degI *Sub CATMain()CATIA.RefreshDisplay = FalseCatia 百格线生成宏Dim sStatus As String Set the CATIA popupto FalseIt prevents to stop the macro at each alert during its executionCATIA.Display = False Optional: allows to find the
3、 sample wherever its installed Variables declarationDim oDrwDocument As DrawingDocumentDim oDrwSheets As DrawingSheetsDim oDrwSheet As DrawingSheetDim oDrwView As DrawingViewDim oFactory2D AS Factory2D The Distance between the linesDim D As IntegerDim nx As IntegerDim ny As Integer The point coordin
4、ate select from DrawingDim X1 As IntegerDim Y1 As IntegerCatia 百格线生成宏Dim X2 As IntegerDim Y2 As IntegerDim Pt1 As Point2DDim Pt2 As Point2DThe view scale dAngle for rotate view scale for view scaleDim dScale,dAngle As DoubleThe view coordinate originDim X As IntDim Y As IntDim xSel As INFITF.Selecti
5、onD= InputBox(Please Input the Distance Value, input box, 100)D= Cint (D) Retrive a new drawing documentSet oDrwDocument = CATIA.ActiveDocument Retrieve the drawing documents sheets collectionSet oDrwSheets = oDrwDocument.Sheets Retrieve the active sheetCatia 百格线生成宏Set oDrwSheet = oDrwSheets.ActiveS
6、heet Retrieve the active view of the sheetSet oDrwView = oDrwSheet.Views.ActiveViewRetrive the value of the viewX= oDrwView.xAxisDataY= oDrwView.yAxisDatadScale = oDrwView.ScaledAngle= oDrwView.AngleSet oFactory2D = oDrwView.Factory2DGet the coordinate from the select two pointOn Error Resume NextSe
7、t xSel = CATIA.ActiveDocument.Selection xSel.clearReDim sFilter(0)sFilter(0) = Point2DMsgBox Please select the left-bottom point sStatusxSel.SelectElement2(sFilter, Select First Point., false) If (sStatus = Normal) ThenCatia 百格线生成宏Dim SelectedPoint1 As SelectedElementSet SelectedPoint1 = xSel.Item(1
8、)Dim pt1Coord(2) As IntSelectedPoint1.GetCoordinates ( pt1Coord )MsgBox The frst point has been selected Else MsgBox Select a 2D Point 1Exit SubEnd IfMsgBox Please select the ritht-top point sStatus = xSel.SelectElement2(sFilter, Select The Second Point.,false)If (sStatus = Normal) ThenDim SelectedP
9、oint2 As SelectedElementSet SelectedPoint2 = xSel.Item(1)Dim pt2Coord(2) As IntSelectedPoint2.GetCoordinates ( pt2Coord )Catia 百格线生成宏MsgBox The second point has been selected Else MsgBox Select a 2D point 1Exit SubEnd Ifif dAngle=0 thenX1= Cint( (pt1Coord(0) - X)/dScale)Y1= Cint (pt1Coord(1) - Y)/dS
10、cale)X2= Cint (pt2Coord(0) - X)/dScale)Y2= Cint (pt2Coord(1) - Y)/dScale) end ifMsgBox (pt1Coord(0)MsgBox Xif dAngle0 thenX1=Cint(pt1Coord(1)-Y)/dScale)Y1=Cint (pt1Coord(0) -X)/dScale)X2= Cint (pt2Coord(1)-Y)/dScale)Y2= Cint (pt2Coord(0)-X)/dScale) end ifif dAngle0 then Di_V=-Di_V end ifif dAngle0 t
11、henset Line2D1 = oFactory2D.CreateLine (X1-D/3,-Y1-D*i,X1+nx*D+D/3,-Y1-D*i) oSel.Add Line2D1set Circle2D1=oFactory2D.CreateClosedCircle(X1+nx*D+D/3 +R,-Y1-D*i,R) oSel.Add Circle2D1set Line2D1= oFactory2D.CreateLine(X1+nx*D+D/3+R,-Y1-D*i+R,X1+nx*D+D/3+R,-Y1- D*i-R)oSel.Add Line2D1Set MyText = oDrwVie
12、w.Texts.Add(Text_XYZ_V,X1+nx*D+D/3+RCatia 百格线生成宏+TextV,-Y1-D*i)MyText.AnchorPosition = catMiddleCenterMyText.SetFontSize 0, 0, iFontSizeSet MyText =oDrwView.Texts.Add(Y1+D*i)*Di_V,X1+nx*D+D/3+R-TextV,-Y1-D*i)MyText.AnchorPosition = catMiddleCenterMyText.SetFontSize 0, 0, iFontSizeend ifif dAngle0 th
13、enset Line2D1 = oFactory2D.CreateLine (X1+D*j,-Y1+D/3,X1+D*j,-Y1-ny*D-D/3) oSel.Add Line2D1setCircle2D1=oFactory2D.CreateClosedCircle(X1+D*j,-Y1+D/3+R,R)oSel.Add Circle2D1set Line2D1 = oFactory2D.CreateLine(X1+D*j,-Y1+D/3+R*2,X1+D*J,-Y1+D/3) oSel.Add Line2D1Set MyText =oDrwView.Texts.Add(Text_XYZ_H,X1+D*j+TextV,-Y1+D/3+R)Catia 百格线生成宏MyText.AnchorPosition = catMiddleCenter MyText.SetFontSize 0, 0, iFontSizeSet MyText = oDrwView.Text
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 新能源汽车电池技术的可持续发展试题及答案
- 新能源汽车行业标准的发展与现状试题及答案
- 文物保护往年试题及答案
- 突破商务英语考试试题及答案
- 房地产管理 试题及答案
- 尾矿证考试试题及答案
- 家具设计如何融合多样文化元素与市场需求研究试题及答案
- 工程施工安全试题解答全解析
- 数学试题及答案中考陕西
- 有理数测试卷及答案初一
- 幼儿园食堂主要负责人食品安全岗位职责
- 《散货船结构简介》课件
- 高压设施维修合同范例
- AI新时代算力需求高增长-算力网络建设有望奔向太空
- 2024届考研199管理类综合能力真题及解析完整版
- 肠梗阻合并糖尿病护理查房
- DB32T-无锡水蜜桃标准
- 古诗词诵读《登岳阳楼》公开课一等奖创新教学设计统编版高中语文必修下册
- 2024版工厂并购协议书范本
- 中职班主任培训讲座
- 2024至2030年中国3C电子产品租赁行业市场运行现状及投资战略研究报告
评论
0/150
提交评论