版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、Catia 百格线生成宏你是否为在Catia 做 2D 图纸的时候,画百格线而伤脑筋呢别担心,接下来我告诉你一个简单的方法1. 新建一个txt 文本文档,比如2. 把以下内容复制到中这里开始,不要复制我Option Explicit' *' Purpose:This macro allows you to create Grid line in CATIAdrawing' Author: chenqa' Languages:VBScript' Locales:English' Developing CATIA Level: V5R12'
2、View mush parallel to system aixes,view angle 0deg,90deg and -90deg' *Sub CATMain()= False' Set the CATIA popup file alerts to FalseIt prevents to stop the macro at each alert during its execution= False' Optional: allows to find the sample wherever it's installed' Variables decl
3、arationDim 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 coordinate select from DrawingDim X1 As In
4、tegerDim Y1 As IntegerDim X2 As IntegerDim Y2 As IntegerDim Pt1 As Point2DDim Pt2 As Point2D'The view scale dAngle for rotate view scale for view scaleDim dScale,dAngle As Double'The view coordinate originDim X As IntDim Y As IntDim xSel AsD= InputBox("Please Input the Distance Value&qu
5、ot;, "input box", "100")D= Cint (D)' Retrive a new drawing documentSet oDrwDocument =' Retrieve the drawing document's sheets collectionSet oDrwSheets =' Retrieve the active sheetSet oDrwSheet =Retrieve the active view of the sheetSet oDrwView ='Retrive the va
6、lue of the viewX=Y=dScale =dAngle=Set oFactory2D ='Get the coordinate from the select two point'On Error Resume NextSet xSel =ReDim sFilter(0)sFilter(0) = "Point2D"MsgBox "Please select the left-bottom point "sStatus = (sFilter, "Select First Point.", false)If (
7、sStatus = "Normal") ThenDim SelectedPoint1 As SelectedElementSet SelectedPoint1 = (1)Dim pt1Coord(2) As Int( pt1Coord )MsgBox "The frst point has been selectedElse MsgBox "Select a 2D Point 1"Exit SubEnd IfMsgBox "Please select the ritht-top point "sStatus = (sFilt
8、er, "Select The Second Point.", false)If (sStatus = "Normal") ThenDim SelectedPoint2 As SelectedElementSet SelectedPoint2 = (1)Dim pt2Coord(2) As Int( pt2Coord )MsgBox "The second point has been selectedElse MsgBox "Select a 2D point 1"Exit SubEnd Ifif dAngle=0 the
9、nX1= Cint( (pt1Coord(0) - X)/dScale)Y1= Cint (pt1Coord(1) - Y)/dScale)X2= Cint (pt2Coord(0) - X)/dScale)Y2= Cint (pt2Coord(1) - Y)/dScale) end if'MsgBox (pt1Coord(0) 'MsgBox Xif dAngle>0 thenX1=Cint(pt1Coord(1)-Y)/dScale)Y1=Cint (pt1Coord(0) -X)/dScale)X2= Cint (pt2Coord(1)-Y)/dScale)Y2=
10、Cint (pt2Coord(0)-X)/dScale) end ifif dAngle<0 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 ifX1 = D * Cint(X1/D)Y1 = D * Cint (Y1/D)X2= D * Cint (X2/D)Y2 = D * Cint (Y2/D)nx = (X2-X1) D 'The number of t
11、he horizontal lineny = (Y2-Y1) D 'The number of the vertical lineDim Line2D1 As Line2DDim Circle2D1 as Circle2DDim MyText as DrawingTextDim iFontsize as DoubleDim i As IntDim j As IntDim R As Doubel 'the radius of the circleiFontSize =R=8R=R / dScale'Dim Di_H,Di_V as intDim Text_XYZ_H as
12、 stringDim Text_XYZ_V as stringDi_H=1Di_V=1Compare the drawing view HV with 3D AixesDim XX1,YY1,ZZ1,XX2,YY2,ZZ2 as intXX1,YY1,ZZ1,XX2,YY2,ZZ2if (XX1=1) thenText_XYZ_H="X"End ifif (XX1=-1) thenText_XYZ_H="X"Di_H=-1End ifif (YY1=1) thenText_XYZ_H="Y"End ifif (YY1=-1) then
13、Text_XYZ_H="Y"Di_H=-1Text_XYZ_H="Z"End ifif (ZZ1=-1) thenText_XYZ_H="Z"Di_H=-1End ifif (XX2=1) thenText_XYZ_V="X"End ifif (XX2=-1) thenText_XYZ_V="X"Di_V=-1End ifif (YY2=1) thenText_XYZ_V="Y"End ifif (YY2=-1) thenText_XYZ_V="Y"Di_
14、V=-1End ifif (ZZ2=1) then Text_XYZ_V="Z"End ifif (ZZ2=-1) thenText_XYZ_V="Z"Di_V=-1End ifif dAngle>0 then Di_V=-Di_V end ifif dAngle<0 then Di_H=-Di_H end ifDim oSel as SelectionDim oVisProps as VisPropertySet set oSel =Dim TextV As intTextV=R/2Draw the horizontall linefor
15、i=0 TO nyif dAngle=0 thenset Line2D1 =(X1-D/3,Y1+D*i,X1+nx*D+D/3,Y1+D*i)Line2D1set Circle2D1=(X1-D/3 -R,Y1+D*i,R)Circle2D1set Line2D1= (X1-D/3-R*2,Y1+D*i,X1-D/3,Y1+D*i)Line2D1Set MyText = -R,Y1+D*i+TextV)= catMiddleCenter0, 0, iFontSizeSet MyText = -R,Y1+D*i-TextV)= catMiddleCenter0, 0, iFontSizeend
16、 ifif dAngle>0 thenset Line2D1 =(X1-D/3,-Y1-D*i,X1+nx*D+D/3,-Y1-D*i)Line2D1set Circle2D1=(X1+nx*D+D/3 +R,-Y1-D*i,R)Circle2D1set Line2D1=(X1+nx*D+D/3+R,-Y1-D*i+R,X1+nx*D+D/3+R,-Y1-D*i-R)Line2D1Set MyText = +TextV,-Y1-D*i)= catMiddleCenter0, 0, iFontSizeSet MyText = -TextV,-Y1-D*i)= catMiddleCenter
17、0, 0, iFontSizeend ifif dAngle<0 thenset Line2D1 =(-X1+D/3,Y1+D*i,-(X1+nx*D+D/3),Y1+D*i)Line2D1set Circle2D1=(-(X1+nx*D+D/3)-R,Y1+D*i,R)Circle2D1set Line2D1=(-X1-nx*D-D/3-R,Y1+D*i+R,-X1-nx*D-D/3-R,Y1+D*i-R)Line2D1Set MyText = +TextV,Y1+D*i)= catMiddleCenter0, 0, iFontSizeSet MyText = -TextV,Y1+D*
18、i)= catMiddleCenternext'Draw the vertical linefor j=0 TO nxif dAngle=0 thenset Line2D1 =(X1+D*j,Y1-D/3,X1+D*j,Y1+ny*D+D/3)Line2D1set Circle2D1=(X1+D*j,Y1+ny*D+D/3+R,R)Circle2D1set Line2D1 =(X1+D*j-R,y1+ny*D+D/3+R,X1+D*J+R,y1+ny*D+D/3+R)Line2D1Set MyText = catMiddleCenter0, 0, iFontSizeSet MyText
19、 = catMiddleCenter0, 0, iFontSizeend ifif dAngle>0 thenset Line2D1 =(X1+D*j,-Y1+D/3,X1+D*j,-Y1-ny*D-D/3)Line2D1set Circle2D1=(X1+D*j,-Y1+D/3+R,R)Circle2D1set Line2D1 = (X1+D*j,-Y1+D/3+R*2,X1+D*J,-Y1+D/3)Line2D1Set MyText = catMiddleCenter0, 0, iFontSizeSet MyText = catMiddleCenter0, 0, iFontSize end ifif dAngle<0 thenset Line2D1 =(-X1-D*j,Y1-D/3,-X1-D*j,Y1+ny*D
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 河北省唐山乐亭县联考2026届初三下学期期末大联考数学试题含解析
- 江苏省徐州市沛县重点达标名校2026年初三下学期第八周检测试题数学试题含解析
- 广西柳州市柳南区、城中区重点达标名校2025-2026学年初三下第一次阶段性检测试题物理试题含解析
- 2026年大学大一(机械电子工程)数控技术应用基础测试题及答案
- 护理礼仪与社区服务
- 2025年前台防疫接待礼仪复习资料
- 护理课件美学素材
- 2025年华杯赛小一组数学试卷(含答案)
- 护理质量改进的激励机制
- 护理微课堂:护理法律法规解读
- 中山市施工合同标准文本
- DB45T 449-2007 城市绿化养护规范及验收要求
- 2025届上海市嘉定区初三一模语文试卷及答案
- GB/T 24498-2025建筑门窗、幕墙用密封胶条
- 2025年二级注册计量师专业实务真题
- 2025年九年级数学复习计划
- 《工业用邻氯苯甲醛、对氯苯甲醛》
- UL263标准中文版-2019版建筑结构和材料的防火测试
- 《道路交通安全评价》课件
- 小学四年级体育下学期教案全册
- 大药房《质量管理体系文件》-管理制度
评论
0/150
提交评论