收藏 分销(赏)

Catia百格线生成宏.doc

上传人:w****g 文档编号:3122190 上传时间:2024-06-18 格式:DOC 页数:19 大小:31KB
下载 相关 举报
Catia百格线生成宏.doc_第1页
第1页 / 共19页
Catia百格线生成宏.doc_第2页
第2页 / 共19页
Catia百格线生成宏.doc_第3页
第3页 / 共19页
Catia百格线生成宏.doc_第4页
第4页 / 共19页
Catia百格线生成宏.doc_第5页
第5页 / 共19页
点击查看更多>>
资源描述

1、Catia百格线生成宏你是否为在Catia做2D图纸的时候,画百格线而伤脑筋呢?别担心,接下来我告诉你一个简单的方法1.新建一个txt文本文档,比如Draw-Grid.txt2.把以下内容复制到Draw-Grid.txt中这里开始,不要复制我Option Explicit * Purpose: This macro allows you to create Grid line in CATIA drawing Author: chenqa Languages: VBScript Locales: English Developing CATIA Level: V5R12 View mush p

2、arallel to system aixes,view angle 0deg,90deg and -90deg *Sub CATMain()CATIA.RefreshDisplay = FalseDim sStatus As String Set the CATIA popup 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 where

3、ver its installed Variables declaration Dim oDrwDocument As DrawingDocument Dim oDrwSheets As DrawingSheets Dim oDrwSheet As DrawingSheet Dim 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 s

4、elect 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 scale dAngle for rotate view scale for view scale Dim dScale,dAngle As Double The view coordinate origin Dim X As Int Dim Y As Int Dim xSel As INFITF.Selection D=

5、 InputBox(Please Input the Distance Value, input box, 100) D= Cint (D) Retrive a new drawing document Set oDrwDocument = CATIA.ActiveDocument Retrieve the drawing documents sheets collection Set oDrwSheets = oDrwDocument.Sheets Retrieve the active sheet Set oDrwSheet = oDrwSheets.ActiveSheet Retriev

6、e the active view of the sheet Set oDrwView = oDrwSheet.Views.ActiveView Retrive the value of the view X= oDrwView.xAxisData Y= oDrwView.yAxisData dScale = oDrwView.Scale dAngle= oDrwView.Angle Set oFactory2D = oDrwView.Factory2D Get the coordinate from the select two point On Error Resume Next Set

7、xSel = CATIA.ActiveDocument.Selection xSel.clear ReDim sFilter(0) sFilter(0) = Point2D MsgBox Please select the left-bottom point sStatus = xSel.SelectElement2(sFilter, Select First Point., false) If (sStatus = Normal) Then Dim SelectedPoint1 As SelectedElement Set SelectedPoint1 = xSel.Item(1) Dim

8、pt1Coord(2) As Int SelectedPoint1.GetCoordinates ( pt1Coord ) MsgBox The frst point has been selected Else MsgBox Select a 2D Point 1 Exit Sub End If MsgBox Please select the ritht-top point sStatus = xSel.SelectElement2(sFilter, Select The Second Point., false) If (sStatus = Normal) Then Dim Select

9、edPoint2 As SelectedElement Set SelectedPoint2 = xSel.Item(1) Dim pt2Coord(2) As Int SelectedPoint2.GetCoordinates ( pt2Coord ) MsgBox The second point has been selected Else MsgBox Select a 2D point 1 Exit Sub End If if dAngle=0 then X1= 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 if MsgBox (pt1Coord(0) MsgBox X if dAngle0 then X1=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_Vend ifif dAn

11、gle0 then set Line2D1 = oFactory2D.CreateLine (X1-D/3,-Y1-D*i,X1+nx*D+D/3,-Y1-D*i) oSel.Add Line2D1 set Circle2D1=oFactory2D.CreateClosedCircle(X1+nx*D+D/3 +R,-Y1-D*i,R) oSel.Add Circle2D1 set 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 Line2D1 Set MyText

12、 = oDrwView.Texts.Add(Text_XYZ_V,X1+nx*D+D/3+R +TextV,-Y1-D*i) MyText.AnchorPosition = catMiddleCenter MyText.SetFontSize 0, 0, iFontSize Set MyText = oDrwView.Texts.Add(Y1+D*i)*Di_V,X1+nx*D+D/3+R -TextV,-Y1-D*i) MyText.AnchorPosition = catMiddleCenter MyText.SetFontSize 0, 0, iFontSize end if if dA

13、ngle0 then set Line2D1 = oFactory2D.CreateLine (X1+D*j,-Y1+D/3,X1+D*j,-Y1-ny*D-D/3) oSel.Add Line2D1 set Circle2D1=oFactory2D.CreateClosedCircle(X1+D*j,-Y1+D/3+R,R) oSel.Add Circle2D1 set Line2D1 = oFactory2D.CreateLine(X1+D*j,-Y1+D/3+R*2,X1+D*J,-Y1+D/3) oSel.Add Line2D1 Set MyText = oDrwView.Texts.

14、Add(Text_XYZ_H,X1+D*j+TextV,-Y1+D/3+R) MyText.AnchorPosition = catMiddleCenter MyText.SetFontSize 0, 0, iFontSize Set MyText = oDrwView.Texts.Add(X1+D*j)*Di_H,X1+D*j-TextV,-Y1+D/3+R) MyText.AnchorPosition = catMiddleCenter MyText.SetFontSize 0, 0, iFontSize end if if dAngle“添加现有库”“浏览”,选取刚才创建的Draw-Grid.CATScript,确定后关闭4.点运行确定选左下角点确定选右上角点百格线至此就全部完成了

展开阅读全文
相似文档                                   自信AI助手自信AI助手
猜你喜欢                                   自信AI导航自信AI导航
搜索标签

当前位置:首页 > 包罗万象 > 大杂烩

移动网页_全站_页脚广告1

关于我们      便捷服务       自信AI       AI导航        获赠5币

©2010-2024 宁波自信网络信息技术有限公司  版权所有

客服电话:4008-655-100  投诉/维权电话:4009-655-100

gongan.png浙公网安备33021202000488号   

icp.png浙ICP备2021020529号-1  |  浙B2-20240490  

关注我们 :gzh.png    weibo.png    LOFTER.png 

客服