




版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認領(lǐng)
文檔簡介
1、汽車行業(yè)CATIA百線圖的構(gòu)造汽車中百位線的作用是能夠快速得知汽車各部分零件相對于汽車坐標系的位置(如圖所示)。在車身質(zhì)量控制,人機工程等方面相當重要。這一用途同樣適用于模具及其它行業(yè),比如汽車玻璃升降器中百線圖的設(shè)計(如圖所示)。對于這樣的百位線圖用AUTOCAD軟件進行設(shè)計的工程師一般都通過一步一步畫直線,陣列,畫圓來實現(xiàn)。當然用CATIA軟件進行三維模型設(shè)計,然后投影成工程圖,也可以用如上的方法一步一步畫出百位線,但這樣工作效率非常低。因此網(wǎng)上很多朋友就詢問有沒有比較好的方法自動生成百位線。那么我在這介紹兩種種CATIA軟件自動生成百位線的方法,這兩種方法在CATIA V5 R16以上的
2、環(huán)境下測試過都沒有問題。首先在裝配體里面新建零件,在為新零件建立新原點時選擇否,新建的三個坐標平面就是整個汽車的坐標平面,這樣整個車的坐標系就出來了,如下圖所示進入CATIA工程制圖界面,新建空白文件進入工程圖紙頁面,然后投影主視圖,但要注意工程圖紙選擇投影品面時要選擇新建零件的坐標平面,也就是坐標原點所在的平面(這個很重要)。投影完成后在投影圖的左下角和右上角分別建立兩點,著兩點的位置所做的矩形能夠?qū)⒄麄€圖紙包含即可,然后選擇工具宏(或Alt+F8)點擊宏庫目錄添加現(xiàn)有庫找到宏所在的文件夾,然后選擇宏點擊運行,如下圖所示確定百線格為100,如下圖所示確定后點擊左下角的點,再確定后點擊右上角的
3、點,完成后白線圖就生成了,如下圖所示:Catia百格線生成宏你是否為在Catia做2D圖紙的時候,畫百格線而傷腦筋呢?別擔心,接下來我告訴你一個簡單的方法1.新建一個txt文本文檔,比如Draw-Grid.txt2.把以下內(nèi)容復制到Draw-Grid.txt中這里開始,不要復制我Option Explicit' *' Purpose: This macro allows you to create Grid line in CATIA drawing' Autho
4、r: chenqa' Languages: VBScript' Locales: English ' Developing CATIA Level: V5R12' View mush parallel to system aixes,view angle 0deg,90deg and -90deg' *Sub CATMain()CATIA.RefreshDispla
5、y = 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 wher
6、ever it's installed ' Variables declaration Dim oDrwDocument As DrawingDocument Dim oDrwSheets As DrawingSheets Dim oDrwSheet As DrawingSheet Dim oDrwView As DrawingView Dim oFactory2D
7、 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
8、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
9、 'The view coordinate origin Dim X As Int Dim Y As Int Dim xSel As INFITF.Selection D= InputBox("Please Input the Distance Value", "inpu
10、t box", "100") D= Cint (D) ' Retrive a new drawing document Set oDrwDocument = CATIA.ActiveDocument ' Retrieve the drawing document's sheets collection Set oDrwSheets = oDrwDocument.S
11、heets' Retrieve the active sheet Set oDrwSheet = oDrwSheets.ActiveSheet ' Retrieve the active view of the sheet Set oDrwView = oDrwSheet.Views.ActiveView 'Retrive the value of the
12、 view X= oDrwView.xAxisData Y= oDrwView.yAxisData dScale = oDrwView.Scale dAngle= oDrwView.Angle Set oFactory2D = oDrwView.Factory2D 'Get the coordina
13、te from the select two point 'On Error Resume Next Set xSel = CATIA.ActiveDocument.Selection xSel.clear ReDim sFilter(0) sFilter(0) = "Point2D" M
14、sgBox "Please select the left-bottom point " sStatus = xSel.SelectElement2(sFilter, "Select First Point.", false) If (sStatus = "Normal") Then Dim SelectedPoint1 As SelectedElement
15、0; Set SelectedPoint1 = xSel.Item(1) Dim pt1Coord(2) As Int SelectedPoint1.GetCoordinates ( pt1Coord ) 'MsgBox "The frst point has been selected "
16、0; Else MsgBox "Select a 2D Point 1" Exit Sub End If MsgBox "Please select the ritht-top point " sStatus = xSel.SelectElement2(sFilte
17、r, "Select The Second Point.", false) If (sStatus = "Normal") Then Dim SelectedPoint2 As SelectedElement Set SelectedPoint2 = xSel.Item(1)
18、 Dim pt2Coord(2) As Int SelectedPoint2.GetCoordinates ( pt2Coord ) 'MsgBox "The second point has been selected " Else MsgBox "Select a 2D point 1" Exit Sub
19、 End If if dAngle=0 then X1= 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)
20、60; 'MsgBox X if dAngle>0 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
21、 dAngle<0 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 if X1 = D * Cint(X1/
22、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 = (Y2-Y1) D 'The number of the vertical line &
23、#160; Dim Line2D1 As Line2D Dim Circle2D1 as Circle2D Dim MyText as DrawingText Dim iFontsize as Double Dim i As Int Dim j As Int Dim R As Doubel 'the radius of the circle
24、0; iFontSize = 3.5 R=8 R=R / dScale'-Dim Di_H,Di_V as intDim Text_XYZ_H as stringDim Text_XYZ_V as stringDi_H=1Di_V=1'Compare the drawing view HV with 3D Aixes Dim XX1,YY1,ZZ1,XX2,YY2,ZZ2 as intoDrwView.GenerativeBehavior.GetProjectionPlane XX1
25、,YY1,ZZ1,XX2,YY2,ZZ2if (XX1=1) then Text_XYZ_H="X"End ifif (XX1=-1) then Text_XYZ_H="X" Di_H=-1End ifif (YY1=1) then Text_XYZ_H="Y"End ifif (YY1=-1) then Text_XYZ_H="Y&quo
26、t; Di_H=-1End ifif (ZZ1=1) then Text_XYZ_H="Z"End ifif (ZZ1=-1) then Text_XYZ_H="Z" Di_H=-1End ifif (XX2=1) then Text_XYZ_V="X"End ifif (XX2=-1) then Text_XYZ
27、_V="X" Di_V=-1End ifif (YY2=1) then Text_XYZ_V="Y"End ifif (YY2=-1) then Text_XYZ_V="Y" Di_V=-1End ifif (ZZ2=1) then Text_XYZ_V="Z"End ifif (ZZ2=-1) then &
28、#160; Text_XYZ_V="Z" Di_V=-1End ifif dAngle>0 then Di_V=-Di_Vend ifif dAngle<0 then Di_H=-Di_Hend ifDim oSel as SelectionDim oVisProps as VisPropertySetset oSel = oDrwDocument.SelectionoSel.ClearDim TextV As intTextV=R/2'Draw
29、the horizontall line for i=0 TO ny if dAngle=0 then set Line2D1 = oFactory2D.CreateLine (X1-D/3,Y1+D*i,X1+nx*D+D/3,Y1+D*i) oSel.Add Line2D1
30、; 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
31、,Y1+D*i) oSel.Add Line2D1 Set MyText = oDrwView.Texts.Add(Text_XYZ_V,X1-D/3 -R,Y1+D*i+TextV) MyText.AnchorPosition = catMiddleCenter
32、0; MyText.SetFontSize 0, 0, iFontSize Set MyText = oDrwView.Texts.Add(Y1+D*i)*Di_V,X1-D/3 -R,Y1+D*i-TextV) MyText.AnchorPosition = catMiddleCenter
33、160; MyText.SetFontSize 0, 0, iFontSize end if if dAngle>0 then set Line2D1 = oFactory2D.CreateLine (X1-D/3,-Y1-D*i,X1+nx*D+D/3,-Y1-D*i)
34、; oSel.Add Line2D1 set Circle2D1=oFactory2D.CreateClosedCircle(X1+nx*D+D/3 +R,-Y1-D*i,R) oSel.Add Circle2D1 &
35、#160; 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 = oDrwView.Texts.Add(Text_XYZ_V,X1+nx*D+D/3+R +TextV,-Y1-D*i)&
36、#160; 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*
37、i) MyText.AnchorPosition = catMiddleCenter MyText.SetFontSize 0, 0, iFontSize end if if dAngle<0 then
38、160; 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
39、*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 &
40、#160; Set MyText = oDrwView.Texts.Add(Text_XYZ_V,-X1-nx*D-D/3-R +TextV,Y1+D*i) MyText.AnchorPosition = catMiddleCenter MyText.SetFontSize 0, 0, iFontSize &
41、#160; 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, iFontSiz
42、e end if next 'Draw the vertical line for j=0 TO nx if dAngle=0 then set Line2D1 = oFactory2D.CreateLine (X1+D*j,Y1-
43、D/3,X1+D*j,Y1+ny*D+D/3) oSel.Add Line2D1 set Circle2D1=oFactory2D.CreateClosedCircle(X1+D*j,Y1+ny*D+D/3+R,R) oSel.Add Circle2D1
44、; set Line2D1 = oFactory2D.CreateLine(X1+D*j-R,y1+ny*D+D/3+R,X1+D*J+R,y1+ny*D+D/3+R) oSel.Add Line2D1 Set MyText = oDrwView.Texts.Add(Text_XYZ_H
45、,X1+D*j,Y1+ny*D+D/3+R+TextV) MyText.AnchorPosition = catMiddleCenter MyText.SetFontSize 0, 0, iFontSize
46、; Set MyText = oDrwView.Texts.Add(X1+D*j)*Di_H,X1+D*j,y1+ny*D+D/3+R-TextV) MyText.AnchorPosition = catMiddleCenter
47、; MyText.SetFontSize 0, 0, iFontSize end if if dAngle>0 then set Line2D1 = oFactory2D.CreateLine (X1+D*j,-Y1+D/3,X1+D*j,-Y1-ny*D-D/3)
48、 oSel.Add Line2D1 set Circle2D1=oFactory2D.CreateClosedCircle(X1+D*j,-Y1+D/3+R,R) oSel.Add Circle2D1
49、160; 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.Add(Text_XYZ_H,X1+D*j+TextV,-Y1+D/3+R)
50、60; MyText.AnchorPosition = catMiddleCenter MyText.SetFontSize 0, 0, iFontSize Set MyText = oDrwVie
51、w.Texts.Add(X1+D*j)*Di_H,X1+D*j-TextV,-Y1+D/3+R) MyText.AnchorPosition = catMiddleCenter MyText.SetFontSize 0, 0, iFontSize
52、 end if if dAngle<0 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 =
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責。
- 6. 下載文件中如有侵權(quán)或不適當內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 物理-福建省莆田市2025屆高中畢業(yè)班第二次教學質(zhì)量檢測試卷(莆田二檢)試題和答案
- 歷史-陜西省安康市2025屆高三下學期第二次質(zhì)量聯(lián)考(安康二模)試題和答案
- 除草布施工方案
- 廣東省肇慶市2024-2025年高中地理 農(nóng)業(yè)和工業(yè)練習評講教學實錄 新人教版必修2
- 個人瓷磚買賣合同范例
- 供貨茶葉合同范例
- 關(guān)于定金合同范例
- 公司合作加盟合同范例
- 構(gòu)建班級共同價值觀的策略計劃
- 學生課外閱讀推廣活動計劃
- 基于實驗教學培養(yǎng)學生物理核心素養(yǎng)的研究
- 2023年漢字聽寫大會漢字聽寫知識競賽題庫及答案
- 退化林修復投標方案
- 鉆孔樁水下混凝土灌注記錄(自動生成)1
- 切削刀具及其材料課件
- 穿刺手術(shù)導航定位系統(tǒng)(CQZ2201581)
- 小學心理健康教育-想法變一變心情換一換教學課件設(shè)計
- 機械加工工藝過程卡片(實例)
- 足球腳內(nèi)側(cè)傳球 課件
- 甲亢的中醫(yī)辨證施治
- 統(tǒng)編教材二年級下冊“寫話”編排特色解析
評論
0/150
提交評論