Catia百格线生成宏复习过程.docx

上传人:b****7 文档编号:8691317 上传时间:2023-02-01 格式:DOCX 页数:11 大小:17.52KB
下载 相关 举报
Catia百格线生成宏复习过程.docx_第1页
第1页 / 共11页
Catia百格线生成宏复习过程.docx_第2页
第2页 / 共11页
Catia百格线生成宏复习过程.docx_第3页
第3页 / 共11页
Catia百格线生成宏复习过程.docx_第4页
第4页 / 共11页
Catia百格线生成宏复习过程.docx_第5页
第5页 / 共11页
点击查看更多>>
下载资源
资源描述

Catia百格线生成宏复习过程.docx

《Catia百格线生成宏复习过程.docx》由会员分享,可在线阅读,更多相关《Catia百格线生成宏复习过程.docx(11页珍藏版)》请在冰豆网上搜索。

Catia百格线生成宏复习过程.docx

Catia百格线生成宏复习过程

Catia百格线生成宏

为此,装潢美观,亮丽,富有个性化的店面环境,能引起消费者的注意,从而刺激顾客的消费欲望。

这些问题在今后经营中我们将慎重考虑的。

调研结论:

综上分析,我们认为在学院内开发“DIY手工艺品”商店这一创业项目是完全可行的。

你是否为在Catia做2D图纸的时候,画百格线而伤脑筋呢?

别担心,接下来我告诉你一个简单的方法

1.新建一个txt文本文档,比如Draw-Grid.txt

2.把以下内容复制到Draw-Grid.txt中

=========这里开始,不要复制我========

OptionExplicit

 

'***********************************************************************

'  Purpose:

     ThismacroallowsyoutocreateGridlineinCATIAdrawing

'  Author:

chenqa

'  Languages:

  VBScript

'  Locales:

      English

'  DevelopingCATIALevel:

V5R12

'  Viewmushparalleltosystemaixes,viewangle0deg,90degand-90deg

'***********************************************************************

SubCATMain()

CATIA.RefreshDisplay=False

DimsStatusAsString

   'SettheCATIApopupfilealertstoFalse

   'Itpreventstostopthemacroateachalertduringitsexecution

   CATIA.DisplayFileAlerts=False

   'Optional:

allowstofindthesamplewhereverit'sinstalled

   'Variablesdeclaration

   DimoDrwDocumentAsDrawingDocument

   DimoDrwSheetsAsDrawingSheets

   DimoDrwSheetAsDrawingSheet

   DimoDrwViewAsDrawingView

   DimoFactory2DASFactory2D

  

  'TheDistancebetweenthelines

   DimDAsInteger

   DimnxAsInteger

   DimnyAsInteger

  'ThepointcoordinateselectfromDrawing

   DimX1AsInteger

   DimY1AsInteger

   DimX2AsInteger

   DimY2AsInteger

   DimPt1AsPoint2D

   DimPt2AsPoint2D

   

  'TheviewscaledAngleforrotateviewscaleforviewscale

   DimdScale,dAngleAsDouble

   'Theviewcoordinateorigin

   DimXAsInt

    DimYAsInt

      

   DimxSel  AsINFITF.Selection

   D=InputBox("PleaseInputtheDistanceValue","inputbox","100")

   D=Cint(D)

   'Retriveanewdrawingdocument

   SetoDrwDocument=CATIA.ActiveDocument

   

'Retrievethedrawingdocument'ssheetscollection

   SetoDrwSheets=oDrwDocument.Sheets

'Retrievetheactivesheet

   SetoDrwSheet=oDrwSheets.ActiveSheet

      

   'Retrievetheactiveviewofthesheet

   SetoDrwView=oDrwSheet.Views.ActiveView

   'Retrivethevalueoftheview  

    X=oDrwView.xAxisData

    Y=oDrwView.yAxisData

    dScale=oDrwView.Scale

    dAngle=oDrwView.Angle

    SetoFactory2D=oDrwView.Factory2D

  'Getthecoordinatefromtheselecttwopoint

   'OnErrorResumeNext

    SetxSel=CATIA.ActiveDocument.Selection

    xSel.clear

    ReDimsFilter(0)

    sFilter(0)="Point2D"

    MsgBox"Pleaseselecttheleft-bottompoint"

    sStatus=xSel.SelectElement2(sFilter,"SelectFirstPoint.",false)

    If(sStatus="Normal")Then

     DimSelectedPoint1AsSelectedElement

     SetSelectedPoint1=xSel.Item

(1)

  

     Dimpt1Coord

(2)AsInt

     SelectedPoint1.GetCoordinates(pt1Coord)

     'MsgBox"Thefrstpointhasbeenselected"

     ElseMsgBox"Selecta2DPoint1"

     ExitSub

     EndIf

  

     MsgBox"Pleaseselecttheritht-toppoint"

     sStatus=xSel.SelectElement2(sFilter,"SelectTheSecondPoint.",false)

     If(sStatus="Normal")Then

      DimSelectedPoint2AsSelectedElement

   

      SetSelectedPoint2=xSel.Item

(1)

  

     Dimpt2Coord

(2)AsInt

   SelectedPoint2.GetCoordinates(pt2Coord)

    'MsgBox"Thesecondpointhasbeenselected"

    ElseMsgBox"Selecta2Dpoint1"

    ExitSub

    EndIf

  

ifdAngle=0then

  X1=Cint((pt1Coord(0)-X)/dScale)

  Y1=Cint((pt1Coord

(1)-Y)/dScale)

  X2=Cint((pt2Coord(0)-X)/dScale)

  Y2=Cint((pt2Coord

(1)-Y)/dScale)

endif

  'MsgBox(pt1Coord(0))

  'MsgBoxX

  ifdAngle>0then

   X1=Cint((pt1Coord

(1)-Y)/dScale)

     Y1=Cint((pt1Coord(0)-X)/dScale)

     X2=Cint((pt2Coord

(1)-Y)/dScale)

     Y2=Cint((pt2Coord(0)-X)/dScale)

endif

ifdAngle<0then

   X1=Cint((pt1Coord

(1)-Y)/dScale)

     Y1=Cint((pt1Coord(0)-X)/dScale)

     X2=Cint((pt2Coord

(1)-Y)/dScale)

     Y2=Cint((pt2Coord(0)-X)/dScale)

endif

   X1=D*Cint(X1/D)

   Y1=D*Cint(Y1/D)

   X2=D*Cint(X2/D)

   Y2=D*Cint(Y2/D)

   

   nx=(X2-X1)\D'Thenumberofthehorizontalline

   ny=(Y2-Y1)\D'Thenumberoftheverticalline

   

   DimLine2D1AsLine2D

   DimCircle2D1asCircle2D

  DimMyTextasDrawingText

  DimiFontsizeasDouble

   DimiAsInt

   DimjAsInt

   DimRAsDoubel'theradiusofthecircle

  

   iFontSize=3.5

   R=8

   R=R/dScale

'------------------------------------------------------

DimDi_H,Di_Vasint

DimText_XYZ_Hasstring

DimText_XYZ_Vasstring

Di_H=1

Di_V=1

'ComparethedrawingviewHVwith3DAixes

DimXX1,YY1,ZZ1,XX2,YY2,ZZ2asint

oDrwView.GenerativeBehavior.GetProjectionPlaneXX1,YY1,ZZ1,XX2,YY2,ZZ2

if(XX1=1)then

   Text_XYZ_H="X"

Endif

if(XX1=-1)then

   Text_XYZ_H="X"

   Di_H=-1

Endif

if(YY1=1)then

   Text_XYZ_H="Y"

Endif

if(YY1=-1)then

   Text_XYZ_H="Y"

   Di_H=-1

Endif

if(ZZ1=1)then

   Text_XYZ_H="Z"

Endif

if(ZZ1=-1)then

   Text_XYZ_H="Z"

   Di_H=-1

Endif

 

if(XX2=1)then

   Text_XYZ_V="X"

Endif

if(XX2=-1)then

   Text_XYZ_V="X"

   Di_V=-1

Endif

if(YY2=1)then

   Text_XYZ_V="Y"

Endif

if(YY2=-1)then

   Text_XYZ_V="Y"

   Di_V=-1

Endif

if(ZZ2=1)then

   Text_XYZ_V="Z"

Endif

if(ZZ2=-1)then

   Text_XYZ_V="Z"

   Di_V=-1

Endif

ifdAngle>0then

   Di_V=-Di_V

endif

ifdAngle<0then

   Di_H=-Di_H

endif

DimoSelasSelection

DimoVisPropsasVisPropertySet

setoSel=oDrwDocument.Selection

oSel.Clear

DimTextVAsint

TextV=R/2

'Drawthehorizontallline

   fori=0TOny

     ifdAngle=0then

         setLine2D1=oFactory2D.CreateLine(X1-D/3,Y1+D*i,X1+nx*D+D/3,Y1+D*i)

         oSel.AddLine2D1

         setCircle2D1=oFactory2D.CreateClosedCircle(X1-D/3-R,Y1+D*i,R)

         oSel.AddCircle2D1

         setLine2D1=oFactory2D.CreateLine(X1-D/3-R*2,Y1+D*i,X1-D/3,Y1+D*i)

         oSel.AddLine2D1

         SetMyText=oDrwView.Texts.Add(Text_XYZ_V,X1-D/3-R,Y1+D*i+TextV)

       MyText.AnchorPosition=catMiddleCenter

        MyText.SetFontSize0,0,iFontSize

         SetMyText=oDrwView.Texts.Add((Y1+D*i)*Di_V,X1-D/3-R,Y1+D*i-TextV)

         MyText.AnchorPosition=catMiddleCenter

         MyText.SetFontSize0,0,iFontSize

      endif

     ifdAngle>0then

         setLine2D1=oFactory2D.CreateLine(X1-D/3,-Y1-D*i,X1+nx*D+D/3,-Y1-D*i)

         oSel.AddLine2D1

         setCircle2D1=oFactory2D.CreateClosedCircle(X1+nx*D+D/3+R,-Y1-D*i,R)

         oSel.AddCircle2D1

         setLine2D1=oFactory2D.CreateLine(X1+nx*D+D/3+R,-Y1-D*i+R,X1+nx*D+D/3+R,-Y1-D*i-R)

         oSel.AddLine2D1

         SetMyText=oDrwView.Texts.Add(Text_XYZ_V,X1+nx*D+D/3+R+TextV,-Y1-D*i)

        MyText.AnchorPosition=catMiddleCenter

        MyText.SetFontSize0,0,iFontSize

         SetMyText=oDrwView.Texts.Add((Y1+D*i)*Di_V,X1+nx*D+D/3+R-TextV,-Y1-D*i)

         MyText.AnchorPosition=catMiddleCenter

         MyText.SetFontSize0,0,iFontSize

      endif

     ifdAngle<0then

         setLine2D1=oFactory2D.CreateLine(-X1+D/3,Y1+D*i,-(X1+nx*D+D/3),Y1+D*i)

         oSel.AddLine2D1

         setCircle2D1=oFactory2D.CreateClosedCircle(-(X1+nx*D+D/3)-R,Y1+D*i,R)

         oSel.AddCircle2D1

         setLine2D1=oFactory2D.CreateLine(-X1-nx*D-D/3-R,Y1+D*i+R,-X1-nx*D-D/3-R,Y1+D*i-R)

         oSel.AddLine2D1

         SetMyText=oDrwView.Texts.Add(Text_XYZ_V,-X1-nx*D-D/3-R+TextV,Y1+D*i)

        MyText.AnchorPosition=catMiddleCenter

         MyText.SetFontSize0,0,iFontSize

         SetMyText=oDrwView.Texts.Add((Y1+D*i)*Di_V,-X1-nx*D-D/3-R-TextV,Y1+D*i)

         MyText.AnchorPosition=catMiddleCenter

        MyText.SetFontSize0,0,iFontSize

      endif

   next

 

    

'Drawtheverticalline

   forj=0TOnx

     ifdAngle=0then

         setLine2D1=oFactory2D.CreateLine(X1+D*j,Y1-D/3,X1+D*j,Y1+ny*D+D/3)

         oSel.AddLine2D1

         setCircle2D1=oFactory2D.CreateClosedCircle(X1+D*j,Y1+ny*D+D/3+R,R)

         oSel.AddCircle2D1

         setLine2D1=oFactory2D.CreateLine(X1+D*j-R,y1+ny*D+D/3+R,X1+D*J+R,y1+ny*D+D/3+R)

         oSel.AddLine2D1

          SetMyText=oDrwView.Texts.Add(Text_XYZ_H,X1+D*j,Y1+ny*D+D/3+R+TextV)

                MyText.AnchorPosition=catMiddleCenter

                MyText.SetFontSize0,0,iFontSize

          SetMyText=oDrwView.Texts.Add((X1+D*j)*Di_H,X1+D*j,y1+ny*D+D/3+R-TextV)

                MyText.AnchorPosition=catMiddleCenter

            MyText.SetFontSize0,0,iFontSize

     endif

     ifdAngle>0then

         setLine2D1=oFactory2D.CreateLine(X1+D*j,-Y1+D/3,X1+D*j,-Y1-ny*D-D/3)

         oSel.AddLine2D1

         setCircle2D1=oFactory2D.CreateClosedCircle(X1+D*j,-Y1+D/3+R,R)

         oSel.AddCircle2D1

         setLine2D1=oFactory2D.CreateLine(X1+D*j,-Y1+D/3+R*2,X1+D*J,-Y1+D/3)

         oSel.AddLine2D1

          SetMyText=oDrwView.Texts.Add(Text_XYZ_H,X1+D*j+TextV,-Y1+D/3+R)

                MyText.AnchorPosition=catMiddleCenter

            MyText.SetFontSize0,0,iFontSize

          SetMyText=oDrwView.Texts.Add((X1+D*j)*Di_H,X1+D*j-TextV,-Y1+D/3+R)

                MyText.AnchorPosition=catMiddleCenter

            MyText.SetFontSize0,0,iFontSize

     endif

     ifdAngle<0then

         setLine2D1=oFactory2D.CreateLine(-X1-D*j,Y1-D/3,-X1-D*j,Y1+ny*D+D/3)

         oSel.AddLine2D1

         setCircle2D1=oFactory2D.CreateClosedCircle(-X1-D*j,Y1-D/3-R,R)

         oSel.AddCircle2D1

         setLine2D1=oFactory2D.CreateLine(-X1-D*j,Y1-D/3-R*2,-X1-D*J,Y1-D/3)

         oSel.AddLine2D1

          SetMyText=oDrwView.Texts.Add(Text_X

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

当前位置:首页 > 初中教育

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1