CATIA百格线.doc

上传人:laozhun 文档编号:2956004 上传时间:2023-03-05 格式:DOC 页数:8 大小:222KB
返回 下载 相关 举报
CATIA百格线.doc_第1页
第1页 / 共8页
CATIA百格线.doc_第2页
第2页 / 共8页
CATIA百格线.doc_第3页
第3页 / 共8页
CATIA百格线.doc_第4页
第4页 / 共8页
CATIA百格线.doc_第5页
第5页 / 共8页
点击查看更多>>
资源描述

《CATIA百格线.doc》由会员分享,可在线阅读,更多相关《CATIA百格线.doc(8页珍藏版)》请在三一办公上搜索。

1、=从这里开始不要复制我=Option Explicit * Purpose: This macro allows you to create Grid line in CATIA drawing Languages: VBScript Locales: English Developing CATIA Level: V5R14-R17 View mush parallel to system aixes,view angle 0deg,90deg and -90deg *Sub CATMain()CATIA.RefreshDisplay = False Set the CATIA popup

2、file alerts to False It prevents to stop the macro at each alert during its execution CATIA.DisplayFileAlerts = False Optional: allows to find the sample wherever its installed Variables declaration Dim oDrwDocument As DrawingDocument Dim oDrwSheets As DrawingSheets Dim oDrwSheet As DrawingSheet Dim

3、 oDrwView As DrawingView Dim oFactory2D AS Factory2D The Distance between the lines Dim D As Integer Dim nx As Integer Dim ny As Integer The point coordinate select from Drawing Dim X1 As Integer Dim Y1 As Integer Dim X2 As Integer Dim Y2 As Integer Dim Pt1 As Point2D Dim Pt2 As Point2D The view sca

4、le dAngle for rotate view scale for view scale Dim dAngle As Double = 读取间隔距离 = D= InputBox(请输入坐标距离,100的整数倍, input box, 1) D= Cint (D) if Dpt2Coord(0) then pt0Coord(0)=pt1Coord(0) pt1Coord(0)=pt2Coord(0) pt2Coord(0)=pt0Coord(0) end if if pt1Coord(1)pt2Coord(1) then pt0Coord(1)=pt1Coord(1) pt1Coord(1)

5、=pt2Coord(1) pt2Coord(1)=pt0Coord(1) end if=网格线计算= if dAngle=0 then X1= Cint (pt1Coord(0) Y1= Cint (pt1Coord(1) X2= Cint (pt2Coord(0) Y2= Cint (pt2Coord(1) end if X1 = 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 the horizontal line ny =

6、(Y2-Y1) D The number of the vertical line Dim Line2D1 As Line2D Dim Circle2D1 as Circle2D Dim MyText as DrawingText Dim iFontSize as Double Dim iFontName as String Dim i As Int Dim j As Int Dim R As Doubel the radius of the circle iFontSize = 7 iFontName =SICH-Dim Di_H,Di_V as intDim Text_XYZ_H as s

7、tringDim Text_XYZ_V as stringDi_H=1Di_V=1Compare the drawing view HV with 3D Aixes Dim XX1,YY1,ZZ1,XX2,YY2,ZZ2 as intoDrwView.GenerativeBehavior.GetProjectionPlane XX1,YY1,ZZ1,XX2,YY2,ZZ2if (XX1=1) then Text_XYZ_H=XEnd ifif (XX1=-1) then Text_XYZ_H=XDi_H=-1End ifif (YY1=1) then Text_XYZ_H=YEnd ifif

8、(YY1=-1) then Text_XYZ_H=YDi_H=-1End ifif (ZZ1=1) then Text_XYZ_H=ZEnd ifif (ZZ1=-1) then Text_XYZ_H=ZDi_H=-1End ifif (XX2=1) then Text_XYZ_V=XEnd ifif (XX2=-1) then Text_XYZ_V=XDi_V=-1End ifif (YY2=1) then Text_XYZ_V=YEnd ifif (YY2=-1) then Text_XYZ_V=YDi_V=-1End ifif (ZZ2=1) then Text_XYZ_V=ZEnd i

9、fif (ZZ2=-1) then Text_XYZ_V=ZDi_V=-1End ifif dAngle0 thenDi_V=-Di_Vend ifif dAngle0 thenDi_H=-Di_Hend ifDim oSel as SelectionDim oVisProps as VisPropertySetset oSel = oDrwDocument.SelectionoSel.Clearset oVisProps = oSel.VisPropertiesDim TextV As intTextV=R/2 Draw the horizontall line for i=0 TO ny

10、if dAngle=0 then set Line2D1 = oFactory2D.CreateLine (X1-D/8,Y1+D*i,X1+nx*D+D/8,Y1+D*i) oSel.Add Line2D1 set Circle2D1=oFactory2D.CreateClosedCircle(X1-D/3 -R,Y1+D*i,R) oSel.Add Circle2D1 set Line2D1= oFactory2D.CreateLine(X1-D/3-R*2,Y1+D*i,X1-D/3,Y1+D*i) oSel.Add Line2D1 Set MyText = oDrwView.Texts

11、.Add(Text_XYZ_V,X1-D/3 -R,Y1+D*i+TextV) MyText.AnchorPosition = catMiddleCenter MyText.SetFontSize 0, 0, iFontSize MyText.SetFontName 0,0,iFontName oSel.Add MyText Set MyText = oDrwView.Texts.Add(Y1+D*i)*Di_V/100&Text_XYZ_V,X1-D/8 -2,Y1+D*i) MyText.AnchorPosition = catMiddleRight MyText.SetFontSize

12、0, 0, iFontSize MyText.SetFontName 0,0,iFontName oSel.Add MyText end if next Draw the vertical line for j=0 TO nx if dAngle=0 then set Line2D1 = oFactory2D.CreateLine (X1+D*j,Y1-D/8,X1+D*j,Y1+ny*D+D/8) oSel.Add Line2D1 Set MyText = oDrwView.Texts.Add(X1+D*j)*Di_H/100&Text_XYZ_H,X1+D*j,y1+ny*D+D/8+2)

13、 MyText.AnchorPosition = catBottomCenter MyText.SetFontSize 0, 0, iFontSize MyText.SetFontName 0,0,iFontName oSel.Add MyText end if next oVisProps.SetRealWidth 1,0 1st parameter line width 1-63 2nd parameter inheritance flag 1 or 0 oVisProps.SetRealColor 4,155,88,1 oSel.Clear oSel.Clear Set oVisProp

14、s = Nothing Set oSel = Nothing Update drawing table modifications CATIA.ActiveWindow.ActiveViewer.Reframe End Sub=从这里结束不要复制我=以文本形式保存文档,然后将后缀名改为CATScript就可以使用了使用方法: 如何利用Draw-Grid快速绘制百格线操作方法如下: 1、激活需要添加百格线的视图,如下图操作:(双击视图的蓝色边框,或在视图的蓝色边框上右击鼠标,在弹出菜单中选择“Activate View”) 2、按Alt+F8,或者在菜单Tool-Macro中选择macros,出现如下对话框3、在上图菜单中点击“select”,选择Draw-Grid文件,再点击“Run”,出现如下界面,输入百格线的坐标距离。按QC/T 490车身制图标准,百格线可以是50mm、100mm或者200mm。一般我们采用默认的100mm即可。故这里可以使用默认值1。4、在视图点击对角线的第一点、第二点,具体根据零件的尺寸而定。 5、坐标线即可以自动绘制完毕。如下图。

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 教育教学 > 成人教育


备案号:宁ICP备20000045号-2

经营许可证:宁B2-20210002

宁公网安备 64010402000987号