CadCaeCam.com是目前CAD/CAE/CAM/PLM类专业网站中,用户最多,技术含量最高的网站之一, 涵盖目前所有常用的C3P类软件技术讨论。

C3P专业门户

 找回密码
 注册

QQ登录

只需一步,快速开始

扫一扫,访问微社区

查看: 43734|回复: 140

[推荐] [转帖]用VBScript 做的CATIA标题栏和工程图框

  [复制链接]
发表于 2000-7-6 11:59:18 | 显示全部楼层 |阅读模式

'COPYRIGHT DASSAULT SYSTEMES 2001

; y9 w: I6 I& z9 p# u

' ****************************************************************************
' Purpose: To draw a Frame and TitleBlock
' Assumptions: A Drafting document should be active
' Author: 庞军杰,王晓军
' Languages: VBScript
' Version: V5R7
' ****************************************************************************

8 h5 u2 x4 F" w4 s3 i4 p

;Public DrwDocument As DrawingDocument
;Public DrwSheets As DrawingSheets
;Public DrwSheet As DrawingSheet
;Public DrwView As DrawingView
;Public DrwTexts As DrawingTexts
;Public Text As DrawingText
;Public Fact As Factory2D
;Public Point As Point2D
;Public Line As Line2D
;Public Cicle As Circle2D
;Public Selection As Selection
;Public GeomElems As GeometricElements
;Public Height As Double 'Sheet height
;Public Width As Double 'Sheet width
;Public Offset As Double 'Distance between the sheet edges and the frame borders
;Public OH As Double 'Horizontal origin for drawing the titleblock
;Public OV As Double 'Vertical origin for drawing the titleblock
;Public Col(16) As Double 'Columns coordinates
;Public Row(6) As Double 'Rows coordinates
;Public colRev(4) As double 'Columns coordinates of revision block
;Public TranslationX As Double 'Horizontal translation to operate when changing standard
;Public TranslationY As Double 'Vertical translation to operate when changing standard
;Public displayFormat As String 'Sheet format according to standard
;Public sheetFormat As catPaperSize 'Sheet format as integer value

1 H2 `) P* n* m# [

'new variable
;Public RowWidth As Double 'Sheet width
;Public ObjAmount As Double
;Public Coll(8) As Double 'Collumns coordinates
;Public Rowl(53) As Double 'Rowls coordinates ObjAmount=i+3
'end

8 Q" h6 s- u0 c, l4 _


Const mm = 1
Const Inch = 254
Const RulerLength = 200
Const MacroID = "Drawing_Titleblock_JUNJIE"
Const RevRowHeight = 10

! c. g' h) Z" e6 B" e( W A


Sub CATMain()
CATInit
On Error Resume Next
name = DrwTexts.GetItem("Reference_" + MacroID).Name
If Err.Number <> 0 Then
Err.Clear
name = "none"
End If
On Error Goto 0
If (name = "none") Then
CATDrw_Creation
End If
End Sub

$ D7 b1 q" g" L% a& j! a7 a6 k

Sub CATDrw_Creation()
'-------------------------------------------------------------------------------
'How to create the FTB
'-------------------------------------------------------------------------------
CATInit 'To init public variables & work in the background view
If CATCheckRef(1) Then Exit Sub 'To check whether a FTB exists already in the sheet
CATStandard 'To compute standard sizes
CATReference 'To place on the drawing a reference point
CATFrame 'To draw the frame
CATTitleBlock 'To draw the TitleBlock and fill in it

$ W2 ?& X( k4 ~; F7 [/ c- ^


'******************************
'If ObjAmount>0 Then
' CATTitleObjBlock 'To draw the TitleBlock and fill in it
' Else Exit Sub
' End If
'******************************

+ q. m- t/ ?( {' e2 o


End Sub

Sub CATInit()
'-------------------------------------------------------------------------------
'How to init the dialog and create main objects
'-------------------------------------------------------------------------------
Set DrwDocument = CATIA.ActiveDocument
Set DrwSheets = DrwDocument.Sheets
Set Selection = DrwDocument.Selection
Set DrwSheet = DrwSheets.ActiveSheet
Set DrwView = DrwSheet.Views.ActiveView
Set DrwTexts = DrwView.Texts
Set Fact = DrwView.Factory2D
Set GeomElems = DrwView.GeometricElements

5 w" k- x& `3 W! K8 b$ {$ e

End Sub

% m6 I! z9 Y$ ?+ G) k$ H

3 p$ {- P% |3 a. u4 v+ N

Sub CATStandard()
'-------------------------------------------------------------------------------
'How to compute standard values
'-------------------------------------------------------------------------------
Height = DrwSheet.GetPaperHeight
Width = DrwSheet.GetPaperWidth
sheetFormat = DrwSheet.PaperSize

+ c$ n4 u0 q& W d; q- V

Offset = 10.*mm 'Offset default value = 10.
If (sheetFormat = CatPaperA0 Or sheetFormat = CatPaperA1 Or sheetFormat = CatPaperUser And _
(DrwSheet.GetPaperWidth > 594.*mm Or DrwSheet.GetPaperHeight > 594.*mm)) Then
Offset = 20.*mm
End If

' K* q# ]! K* M

OH = Width - Offset
OV = Offset

1 e9 m, I- U4 S5 k0 p' b: v

documentStd = DrwDocument.Standard
If (documentStd = catISO) Then
If sheetFormat = 13 Then
displayFormat = "USER"
Else
displayFormat = "A" + CStr(sheetFormat - 2)
End IF
Else
Select Case sheetFormat
Case 0
displayFormat = "Letter"
Case 1
displayFormat = "Legal"
Case 7
displayFormat = "A"
Case 8
displayFormat = "B"
Case 9
displayFormat = "C"
Case 10
displayFormat = "D"
Case 11
displayFormat = "E"
Case 12
displayFormat = "F"
Case 13
displayFormat = "J"
End Select
End If

6 Z7 b8 m. J& [5 p# Z" ]

End Sub

Sub CATReference()
'-------------------------------------------------------------------------------
'How to create a reference text
'-------------------------------------------------------------------------------
Set Text = DrwTexts.Add("", Width - Offset, Offset)
Text.Name = "Reference_" + MacroID
End Sub

( S5 B; B$ r+ `( n8 |# E' o

Function CATCheckRef(Mode As Integer) As Integer
'-------------------------------------------------------------------------------
'How to check that the called macro is the right one
'-------------------------------------------------------------------------------
nbTexts = DrwTexts.Count
i = 0
notFound = 0
While (notFound = 0 And i i = i + 1
Set Text = DrwTexts.Item(i)
WholeName = Text.Name
leftText = Left(WholeName, 10)
If (leftText = "Reference_") Then
notFound = 1
refText = "Reference_" + MacroID
If (Mode = 1) Then
MsgBox "Frame and Titleblock already created!"
CATCheckRef = 1
Exit Function
ElseIf (Text.Name <> refText) Then
MsgBox "Frame and Titleblock created using another style:" + Chr(10) + " " + MacroID
CATCheckRef = 1
Exit Function
End If
End If
Wend
CATCheckRef = 0

, a+ V7 W" o8 h; M. U+ l o0 N- [

End Function

1 L Y: n( f6 b


Sub CATFrame()
'-------------------------------------------------------------------------------
'How to create the Frame
'-------------------------------------------------------------------------------
Dim Cst_1 As Double 'Length (in cm) between 2 horinzontal marks
Dim Cst_2 As Double 'Length (in cm) between 2 vertical marks
Dim Nb_CM_H As Integer 'Number/2 of horizontal centring marks
Dim Nb_CM_V As Integer 'Number/2 of vertical centring marks
Dim Ruler As Integer 'Ruler length (in cm)

; n( p: Q8 u4 e

CATFrameStandard Nb_CM_H, Nb_CM_V, Ruler, Cst_1, Cst_2
CATFrameBorder
End Sub

3 H2 M+ @& s5 |$ \* s" t

Sub CATFrameStandard(Nb_CM_H As Integer, Nb_CM_V As Integer, Ruler As Integer, Cst_1 As Double, Cst_2 As Double)
'-------------------------------------------------------------------------------
'How to compute standard values
'-------------------------------------------------------------------------------

- ~5 s* o; t2 B, E- Q

Cst_1 = 74.2*mm '297, 594, 1189 are multiples of 74.2
Cst_2 = 52.5*mm '210, 420, 841 are multiples of 52.2
If DrwSheet.Orientation = CatPaperPortrait And _
(sheetFormat = CatPaperA0 Or _
sheetFormat = CatPaperA2 Or _
sheetFormat = CatPaperA4) Or _
DrwSheet.Orientation = CatPaperLandscape And _
(sheetFormat = CatPaperA1 Or _
sheetFormat = CatPaperA3) Then
Cst_1 = 52.5*mm
Cst_2 = 74.2*mm
End If

3 w$ H9 _" S% r; [

Nb_CM_H = CInt(.5 * Width / Cst_1)
Nb_CM_V = CInt(.5 * Height / Cst_2)

' X" _ X+ H. n* ?0 ]

Ruler = CInt((Nb_CM_H - 1) * Cst_1 / 50) * 100 'here is computed the maximum ruler length
If RulerLength < Ruler Then
Ruler = RulerLength
End If
End Sub

, V& _$ W, E& g$ i


 楼主| 发表于 2000-7-6 12:01:31 | 显示全部楼层
Sub CATFrameBorder()
'-------------------------------------------------------------------------------
'How to draw the frame border
'-------------------------------------------------------------------------------
On Error Resume Next
Set Line = Fact.CreateLine(OV, OV , OH, OV )
Line.Name = "Frame_Border_Bottom"
Set Line = Fact.CreateLine(OH, OV , OH, Height - Offset)
Line.Name = "Frame_Border_Left"
Set Line = Fact.CreateLine(OH, Height - Offset, OV, Height - Offset)
Line.Name = "Frame_Border_Top"
Set Line = Fact.CreateLine(OV, Height - Offset, OV, OV )
Line.Name = "Frame_Border_Right"
If Err.Number <> 0 Then
Err.Clear
End If
On Error Goto 0
End Sub

Sub CATTitleBlock()
'-------------------------------------------------------------------------------
'How to create the TitleBlock
'-------------------------------------------------------------------------------
CATTitleBlockFrame 'To draw the geometry
CATTitleBlockText 'To fill in the title block
If ObjAmount>0 Then
CATTitleObjBlock 'To draw the TitleObjBlock and fill in it
Else Exit Sub
End If
End Sub

Sub CATTitleObjBlock()
'-------------------------------------------------------------------------------
'How to create the TitleObjBlock
'-------------------------------------------------------------------------------
CATTitleObjBlockFrame 'To draw the geometry
CATTitleObjBlockText 'To fill in the title Objblock
End Sub

Sub CATTitleBlockFrame()
'-------------------------------------------------------------------------------
'How to draw the title block geometry
'-------------------------------------------------------------------------------
ObjAmount= InputBox("1.输入“0”或单击“取消” →零件图标题栏; 2.输入零件个数“≥1” →带有明细栏的装配图标题栏" )
If( ObjAmount<2 and ObjAmount>101 )then
ObjAmount= InputBox("请输入零件的数目(不大于101不小于2。):" )
End If
RowWidth = + 7*mm 'Define rows Rowwidth.
const Rows = 7 'Define how many rows .
Col(1) = -180*mm
Col(2) = -170*mm
Col(3) = -168*mm
Col(4) = -160*mm
Col(5) = -156*mm
Col(6) = -146*mm
Col(7) = -140*mm
Col(8) = -128*mm
Col(9) = -116*mm
Col(10) = -100*mm
Col(11) = -93.5*mm
Col(12) = - 87*mm
Col(13) = -80.5*mm
Col(14) = - 74*mm
Col(15) = - 62*mm
Col(16) = - 50*mm
Row(1) = + 9*mm
Row(2) = + 18*mm
Row(3) = + 28*mm
Row(4) = + 42*mm
Row(5) = + 56*mm
Row(6) = + 38*mm 'revised

On Error Resume Next
'Rows
Set Line = Fact.CreateLine(OH + Col(1), OV , OH , OV )
Line.Name = "TitleBlock_Line_Bottom"
Set Line = Fact.CreateLine(OH + Col(1), OV + Row(5), OH , OV + Row(5))
Line.Name = "TitleBlock_Line_Top"
Set Line = Fact.CreateLine(OH +Col(10),OV + Row(1) , OH +Col(16) , OV + Row(1))
Line.Name = "TitleBlock_Line_Row_1"
Set Line = Fact.CreateLine(OH +Col(10), OV + Row(2), OH , OV + Row(2))
Line.Name = "TitleBlock_Line_Row_2"
Set Line = Fact.CreateLine(OH +Col(10), OV + Row(3), OH+Col(16) , OV + Row(3))
Line.Name = "TitleBlock_Line_Row_3"
Set Line = Fact.CreateLine(OH + Col(16), OV + Row(6), OH , OV + Row(6))
Line.Name = "TitleBlock_Line_Row_4"
For i=1 to Rows
Set Line = Fact.CreateLine(OH + Col(1), OV + (7*i), OH+ Col(10) , OV + (7*i))
Line.Name = "TitleBlock_Line_LeftRow_"&i
Next
'Cols
Set Line = Fact.CreateLine(OH + Col(1), OV , OH + Col(1), OV + Row(5))
Line.Name = "TitleBlock_Line_Left"
Set Line = Fact.CreateLine(OH , OV , OH , OV + Row(5))
Line.Name = "TitleBlock_Line_Right"

Set Line = Fact.CreateLine(OH + Col(2), OV+ Row(3) , OH + Col(2), OV + Row(5))
Line.Name = "TitleBlock_Line_Column_1"
Set Line = Fact.CreateLine(OH + Col(3), OV , OH + Col(3), OV + Row(3))
Line.Name = "TitleBlock_Line_Column_2"
Set Line = Fact.CreateLine(OH + Col(4), OV+ Row(3) , OH + Col(4), OV + Row(5))
Line.Name = "TitleBlock_Line_Column_3"
Set Line = Fact.CreateLine(OH + Col(5), OV , OH + Col(5), OV + Row(3))
Line.Name = "TitleBlock_Line_Column_4"
Set Line = Fact.CreateLine(OH + Col(6), OV+ Row(3) , OH + Col(6), OV + Row(5))
Line.Name = "TitleBlock_Line_Column_5"
Set Line = Fact.CreateLine(OH + Col(7), OV , OH + Col(7), OV + Row(3))
Line.Name = "TitleBlock_Line_Column_6"
Set Line = Fact.CreateLine(OH + Col(8), OV , OH + Col(8), OV + Row(5))
Line.Name = "TitleBlock_Line_Column_7"
Set Line = Fact.CreateLine(OH + Col(9), OV , OH + Col(9), OV + Row(5))
Line.Name = "TitleBlock_Line_Column_8"
Set Line = Fact.CreateLine(OH +Col(10), OV , OH +Col(10), OV + Row(5))
Line.Name = "TitleBlock_Line_Column_9"
Set Line = Fact.CreateLine(OH + Col(11), OV+ Row(1), OH + Col(11), OV + Row(2))
Line.Name = "TitleBlock_Line_Column_10"
Set Line = Fact.CreateLine(OH + Col(12), OV+ Row(1), OH + Col(12), OV + Row(2))
Line.Name = "TitleBlock_Line_Column_11"
Set Line = Fact.CreateLine(OH + Col(13), OV+ Row(1), OH + Col(13), OV + Row(2))
Line.Name = "TitleBlock_Line_Column_12"
Set Line = Fact.CreateLine(OH + Col(14), OV+ Row(1), OH + Col(14), OV + Row(3))
Line.Name = "TitleBlock_Line_Column_13"
Set Line = Fact.CreateLine(OH + Col(15), OV+ Row(1), OH + Col(15), OV + Row(3))
Line.Name = "TitleBlock_Line_Column_14"
Set Line = Fact.CreateLine(OH + Col(16), OV , OH + Col(16), OV + Row(5))
Line.Name = "TitleBlock_Line_Column_15"

If Err.Number <> 0 Then
Err.Clear
End If
On Error Goto 0
End Sub

 楼主| 发表于 2000-7-6 13:38:58 | 显示全部楼层
Sub CATTitleBlockText()
'-------------------------------------------------------------------------------
'How to fill in the title block
'-------------------------------------------------------------------------------
CATLinks
'The Left-down subBlock.
Text_01 = "指导教师"
Text_02 = "审核"
Text_03 = "设计"
Text_04 = "张国建"
Text_05 = "03.09.25"
Text_06 = "标准化"
Text_07 = "(签名)"
Text_08 = "(年月日)"
Text_09 = "批准"
Text_001 = " "


'The Left-up subBlock.
Text_10 = "标记"
Text_11 = "处数"
Text_12 = "分区"
Text_13 = "更改文件号"
Text_14 = "(签名)"
Text_15 = "(年月日)"

'The Middle subblock
Text_16 = " 共 张 第 张 "
Text_17 = "比例"
Text_18 = "重量"
Text_19= " 阶 段 标 记"
Text_20 = "(材料标记)"
'The right subblock
Text_21 = "上海方宇工业设计"
Text_22 ="(图样名称)"
Text_23 = "课程设计专用图纸"

 楼主| 发表于 2000-7-6 13:41:01 | 显示全部楼层
'The Left-down subBlockText.
Set Text = DrwTexts.Add(Text_01 , OH + Col(1) , OV+1 )
CATFormatTBText "TitleBlock_Text_Techer" ,catBottomLeft , 4
Set Text = DrwTexts.Add(" ", OH + Col(3) , OV+1 )
CATFormatTBText "TitleBlock_Text_Tec_1" ,catBottomLeft , 5
Set Text = DrwTexts.Add(" ", OH + Col(5) + 3. , OV+1 )
CATFormatTBText "TitleBlock_Text_Tec_2" ,catBottomLeft , 5
Set Text = DrwTexts.Add(Text_02 , OH + Col(1)+2 , OV + Rowwidth )
CATFormatTBText "TitleBlock_Text_checker" ,catBottomLeft , 5
Set Text = DrwTexts.Add(" ", OH + Col(3) + 1. , OV + Rowwidth )
CATFormatTBText "TitleBlock_Text_chec_1" ,catBottomLeft , 5
Set Text = DrwTexts.Add(" ", OH + Col(5) + 1. , OV + Rowwidth )
CATFormatTBText "TitleBlock_Text_chec_2" ,catBottomLeft , 5
Set Text = DrwTexts.Add(Text_03 , OH + Col(1) + 2. , OV + (Rowwidth*3) )
CATFormatTBText "TitleBlock_Text_design" ,catBottomLeft , 5
Set Text = DrwTexts.Add(" " , OH + Col(1) + 1. , OV + (Rowwidth*2) )
CATFormatTBText "TitleBlock_Text_des_1 " ,catBottomLeft , 5
Set Text = DrwTexts.Add(Text_04 , OH + Col(3) + 1. , OV+ (Rowwidth*3) )
CATFormatTBText "TitleBlock_Text_Sign " ,catBottomLeft , 5
Set Text = DrwTexts.Add(" ", OH + Col(3) + 1. , OV+ (Rowwidth*2) )
CATFormatTBText "TitleBlock_Text_Sign_1 " ,catBottomLeft , 5
Set Text = DrwTexts.Add(Text_05 , OH + Col(5) + 1. , OV+ (Rowwidth*3) )
CATFormatTBText "TitleBlock_Text_Date " ,catBottomLeft , 4
Set Text = DrwTexts.Add(" ", OH + Col(5) + 1. , OV+ (Rowwidth*2) )
CATFormatTBText "TitleBlock_Text_Date_1 " ,catBottomLeft , 5
Set Text = DrwTexts.Add(Text_06 , OH + Col(7) + 1. , OV + (Rowwidth*3) )
CATFormatTBText "TitleBlock_Text_Standard" ,catBottomLeft , 5
Set Text = DrwTexts.Add(" ", OH + Col(7) + 1. , OV + (Rowwidth*2) )
CATFormatTBText "TitleBlock_Text_Std_1 " ,catBottomLeft , 5
Set Text = DrwTexts.Add(" ", OH + Col(7) + 1. , OV+ (Rowwidth*1) )
CATFormatTBText "TitleBlock_Text_Std_1 " ,catBottomLeft , 5
Set Text = DrwTexts.Add(Text_07 , OH + Col(8) + 1. , OV+ (Rowwidth*3) )
CATFormatTBText "TitleBlock_Text_Sign2 " ,catBottomLeft , 5
Set Text = DrwTexts.Add(" ", OH + Col(8) + 1. , OV+ (Rowwidth*2) )
CATFormatTBText "TitleBlock_Text_Sign2_1 " ,catBottomLeft , 5
Set Text = DrwTexts.Add(" ", OH + Col(8) + 1. , OV+ (Rowwidth*1) )
CATFormatTBText "TitleBlock_Text_Sign2_2 " ,catBottomLeft , 5
Set Text = DrwTexts.Add(Text_08 , OH + Col(9) + 1. , OV+ (Rowwidth*3) )
CATFormatTBText "TitleBlock_Text_Date2 " ,catBottomLeft , 5
Set Text = DrwTexts.Add(" ", OH + Col(9) + 1. , OV+ (Rowwidth*2) )
CATFormatTBText "TitleBlock_Text_Date2_1 " ,catBottomLeft , 5
Set Text = DrwTexts.Add(" ", OH + Col(9) + 1. , OV+ (Rowwidth*1) )
CATFormatTBText "TitleBlock_Text_Date2_2 " ,catBottomLeft , 5
Set Text = DrwTexts.Add(Text_09 , OH + Col(7) + 3. , OV )
CATFormatTBText "TitleBlock_Text_Allow" ,catBottomLeft , 5
Set Text = DrwTexts.Add(" ", OH + Col(8) + 1. , OV )
CATFormatTBText "TitleBlock_Text_Allow_1" ,catBottomLeft , 5
Set Text = DrwTexts.Add(" ", OH + Col(9) + 1. , OV )
CATFormatTBText "TitleBlock_Text_Allow_2" ,catBottomLeft , 5
'The Left-up subBlockText.
Set Text = DrwTexts.Add(Text_10 , OH + Col(1) + 1. , OV+ (Rowwidth*4) )
CATFormatTBText "TitleBlock_Text_Mark" ,catBottomLeft , 5
Set Text = DrwTexts.Add(" ", OH + Col(1) + 1. , OV+ (Rowwidth*5) )
CATFormatTBText "TitleBlock_Text_Mark_1" ,catBottomLeft , 5
Set Text = DrwTexts.Add(" ", OH + Col(1) + 1. , OV+ (Rowwidth*6) )
CATFormatTBText "TitleBlock_Text_Mark_2" ,catBottomLeft , 5
Set Text = DrwTexts.Add(" ", OH + Col(1) + 1. , OV+ (Rowwidth*7) )
CATFormatTBText "TitleBlock_Text_Mark_3" ,catBottomLeft , 5
Set Text = DrwTexts.Add(Text_11 , OH + Col(2) + 1. , OV+ (Rowwidth*4) )
CATFormatTBText "TitleBlock_Text_Amout" ,catBottomLeft , 5
Set Text = DrwTexts.Add(" ", OH + Col(2) + 1. , OV+ (Rowwidth*5) )
CATFormatTBText "TitleBlock_Text_Amout_1" ,catBottomLeft , 5
Set Text = DrwTexts.Add(" ", OH + Col(2) + 1. , OV+ (Rowwidth*6) )
CATFormatTBText "TitleBlock_Text_Amout_2" ,catBottomLeft , 5
Set Text = DrwTexts.Add(" ", OH + Col(2) + 1. , OV+ (Rowwidth*7) )
CATFormatTBText "TitleBlock_Text_Amout_3" ,catBottomLeft , 5
Set Text = DrwTexts.Add(Text_12 , OH + Col(4) +3. , OV+ (Rowwidth*4) )
CATFormatTBText "TitleBlock_Text_District" ,catBottomLeft , 5
Set Text = DrwTexts.Add(" ", OH + Col(4) + 1. , OV+ (Rowwidth*5) )
CATFormatTBText "TitleBlock_Text_Dis_1" ,catBottomLeft , 5
Set Text = DrwTexts.Add(" ", OH + Col(4) + 1. , OV+ (Rowwidth*6) )
CATFormatTBText "TitleBlock_Text_Dis_2" ,catBottomLeft , 5
Set Text = DrwTexts.Add(" ", OH + Col(4) + 1. , OV+ (Rowwidth*7) )
CATFormatTBText "TitleBlock_Text_Dis_3" ,catBottomLeft , 5
Set Text = DrwTexts.Add(Text_13 , OH + Col(6) + 1. , OV+ (Rowwidth*4) )
CATFormatTBText "TitleBlock_Text_ReviseList" ,catBottomLeft , 5
Set Text = DrwTexts.Add(" ", OH + Col(6) + 1. , OV+ (Rowwidth*5) )
CATFormatTBText "TitleBlock_Text_RevL_1" ,catBottomLeft , 5
Set Text = DrwTexts.Add(" ", OH + Col(6) + 1. , OV+ (Rowwidth*6) )
CATFormatTBText "TitleBlock_Text_RevL_2" ,catBottomLeft , 5
Set Text = DrwTexts.Add(" ", OH + Col(6) + 1. , OV+ (Rowwidth*7) )
CATFormatTBText "TitleBlock_Text_RevL_3" ,catBottomLeft , 5
Set Text = DrwTexts.Add(Text_14 , OH + Col(8) + 1. , OV+ (Rowwidth*4) )
CATFormatTBText "TitleBlock_Text_SignL" ,catBottomLeft , 5
Set Text = DrwTexts.Add(" ", OH + Col(8) + 1. , OV+ (Rowwidth*5) )
CATFormatTBText "TitleBlock_Text_SignL_1" ,catBottomLeft , 5
Set Text = DrwTexts.Add(" ", OH + Col(8) + 1. , OV+ (Rowwidth*6) )
CATFormatTBText "TitleBlock_Text_SignL_2" ,catBottomLeft , 5
Set Text = DrwTexts.Add(" ", OH + Col(8) + 1. , OV+ (Rowwidth*7) )
CATFormatTBText "TitleBlock_Text_SignL_3" ,catBottomLeft , 5
Set Text = DrwTexts.Add(Text_15 , OH + Col(9) + 1. , OV+ (Rowwidth*4) )
CATFormatTBText "TitleBlock_Text_DateL" ,catBottomLeft , 5
Set Text = DrwTexts.Add(" ", OH + Col(9) + 1. , OV+ (Rowwidth*5) )
CATFormatTBText "TitleBlock_Text_DateL_1" ,catBottomLeft , 5
Set Text = DrwTexts.Add(" ", OH + Col(9) + 1. , OV+ (Rowwidth*6) )
CATFormatTBText "TitleBlock_Text_DateL_2" ,catBottomLeft , 5
Set Text = DrwTexts.Add(" ", OH + Col(9) + 1. , OV+ (Rowwidth*7) )
CATFormatTBText "TitleBlock_Text_DateL_3" ,catBottomLeft , 5
 楼主| 发表于 2000-7-6 13:41:50 | 显示全部楼层
'The Middle subblockText.
Set Text = DrwTexts.Add(Text_16 , OH + Col(10) + 1. , OV )
CATFormatTBText "TitleBlock_Text_Acount " ,catBottomLeft , 5
Set Text = DrwTexts.Add(" " , OH + Col(12) -5. , OV )
CATFormatTBText "TitleBlock_Text_Acount_1" ,catBottomLeft , 5
Set Text = DrwTexts.Add(" " , OH + Col(15) + 1. , OV )
CATFormatTBText "TitleBlock_Text_Acount_2" ,catBottomLeft , 5
Set Text = DrwTexts.Add(Text_17 , OH + Col(15) + 2. , OV +(Row(2)+3) )
CATFormatTBText "TitleBlock_Text_Scale" ,catBottomLeft , 5
Set Text = DrwTexts.Add(" " , OH + Col(15) , OV+(Row(1)+3) )
CATFormatTBText "TitleBlock_Text_Scale_1" ,catBottomLeft , 5
Set Text = DrwTexts.Add(Text_18 , OH + Col(14) + 2. , OV +(Row(2)+3) )
CATFormatTBText "TitleBlock_Text_Weight" ,catBottomLeft , 5
Set Text = DrwTexts.Add(" " , OH + Col(14) + 2. , OV+(Row(1)+3) )
CATFormatTBText "TitleBlock_Text_Weight_1" ,catBottomLeft , 5
Set Text = DrwTexts.Add(Text_19 , OH + Col(10) + 1. , OV +(Row(2)+3) )
CATFormatTBText "TitleBlock_Text_PhaseSign" ,catBottomLeft , 5
Set Text = DrwTexts.Add(" " , OH + Col(10) + 1. , OV+(Row(1)+2) )
CATFormatTBText "TitleBlock_Text_Phs_1" ,catBottomLeft , 5
Set Text = DrwTexts.Add(" " , OH + Col(11) + 1. , OV+(Row(1)+2) )
CATFormatTBText "TitleBlock_Text_Phs_1" ,catBottomLeft , 5
Set Text = DrwTexts.Add(" " , OH + Col(12) + 1. , OV+(Row(1)+2) )
CATFormatTBText "TitleBlock_Text_Phs_1" ,catBottomLeft , 5
Set Text = DrwTexts.Add(" " , OH + Col(13) + 1. , OV+(Row(1)+2) )
CATFormatTBText "TitleBlock_Text_Phs_1" ,catBottomLeft , 5
Set Text = DrwTexts.Add(Text_20 , OH + Col(10) + 25. , OV +(Row(3)+5) )
CATFormatTBText "TitleBlock_Text_MaterialSign" ,catBottomCenter, 10
'The right subblockText.
Set Text = DrwTexts.Add(Text_21 , OH + Col(16) +25. , OV +Row(4) )
CATFormatTBText "TitleBlock_Text_School" ,catBottomCenter, 7
Set Text = DrwTexts.Add(Text_22 , OH + Col(16) +25. , OV +(Row(2)+5) )
CATFormatTBText "TitleBlock_Text_DrawingName" ,catBottomCenter, 7
Set Text = DrwTexts.Add(Text_23 , OH + Col(16) +25. , OV +5 )
CATFormatTBText "TitleBlock_Text_Use " ,catBottomCenter, 7

End Sub

 楼主| 发表于 2000-7-6 13:49:00 | 显示全部楼层
Sub CATTitleObjBlockFrame()
'-------------------------------------------------------------------------------
'How to draw the title Objblock geometry
'-------------------------------------------------------------------------------
Coll(1) = -180*mm
Coll(2) = -172*mm
Coll(3) = -134*mm
Coll(4) = -90*mm
Coll(5) = - 82*mm
Coll(6) = - 44*mm
Coll(7) = - 34*mm
Coll(8) = - 24*mm

Rowl(1) = + 56*mm
Rowl(2) = + 63*mm
Rowl(3) = + 70*mm

For i=1 to ObjAmount
Rowl(i+3)= + (70+7*i)*mm
Next

'MsgBox "Frame and Titleblock already created!"
On Error Resume Next
'creat TitleObjBlock RowlLines .
Set Line = Fact.CreateLine(OH + Coll(6), OV +Rowl(2) , OH+ Coll(8) , OV + Rowl(2) )
Line.Name = "TitleObjBlock_Shotest_Bottom"
Set Line = Fact.CreateLine(OH + Coll(1), OV +Rowl(3) , OH , OV + Rowl(3) )
Line.Name = "TitleObjBlock_RowlLine_Bottom"

For i=1 to ObjAmount
Set Line = Fact.CreateLine(OH + Coll(1), OV +Rowl(i+3) , OH , OV + Rowl(i+3))
Line.Name = "TitleObjBlock_RowlLine_No." & i
DrawingDimLine.thickness=1
Next
'creat TitleObjBlock CollLines .

Set Line = Fact.CreateLine(OH + Coll(8), OV +Rowl(1) , OH+ Coll(8) , OV + Rowl( ObjAmount+3) )
Line.Name = "TitleObjBlock_Collline_No.8"
Set Line = Fact.CreateLine(OH + Coll(7), OV +Rowl(2) , OH+ Coll(7) , OV + Rowl( ObjAmount+3) )
Line.Name = "TitleObjBlock_Collline_No.7"
Set Line = Fact.CreateLine(OH + Coll(6), OV +Rowl(1) , OH+ Coll(6) , OV + Rowl( ObjAmount+3) )
Line.Name = "TitleObjBlock_Collline_No.6"
Set Line = Fact.CreateLine(OH + Coll(5), OV +Rowl(1) , OH+ Coll(5) , OV + Rowl( ObjAmount+3) )
Line.Name = "TitleObjBlock_Collline_No.5"
Set Line = Fact.CreateLine(OH + Coll(4), OV +Rowl(1) , OH+ Coll(4) , OV + Rowl( ObjAmount+3) )
Line.Name = "TitleObjBlock_Collline_No.4"
Set Line = Fact.CreateLine(OH + Coll(3), OV +Rowl(1) , OH+ Coll(3) , OV + Rowl( ObjAmount+3) )
Line.Name = "TitleObjBlock_Collline_No.3"
Set Line = Fact.CreateLine(OH + Coll(2), OV +Rowl(1) , OH+ Coll(2) , OV + Rowl( ObjAmount+3) )
Line.Name = "TitleObjBlock_Collline_No.2"
Set Line = Fact.CreateLine(OH + Coll(1), OV +Rowl(1) , OH+ Coll(1) , OV + Rowl( ObjAmount+3) )
Line.Name = "TitleObjBlock_Collline_No.1"

If Err.Number <> 0 Then
Err.Clear
End If
On Error Goto 0

End Sub

 楼主| 发表于 2000-7-6 13:50:15 | 显示全部楼层
用VBScript 做的CATIA标题栏和工程图框

使用方法:drafting--〉edit--〉background--〉tools--〉macro--〉macros中select本文件,run即可。


环境变量设置(很实用)

CATLM_ODTS=1 - Disable license error messages at startup
L_WILSON_LAN=1 - Access to Wilson's spline curves
CGM_ROLLINGOFFSET=1 - Access to the Rolling Offset option in GSD
TAILLE_MEMOIRE_CHOISIE=1 - Optimize IGES export memory
CATNoStartDocument=no - Disable product at startup
CNEXTBACKGROUND = no - Disable sky background at startup
CNEXTSPLASHSCREEN = no - Disable display of planet at startup
SHOW_CST_CHILDREN = 1 - Display stresses in the parents specification tree in sketcher
CNEXTOUTPUT = console - Display Catia's logs in command windows
MM_NO_REPLACE = 1 - Associativty about replacement of components cloned with different

 楼主| 发表于 2000-7-6 13:53:28 | 显示全部楼层
为了大家的方便,把上面的帖子合并为一个压缩包,用CATScript 做的CATIA标题栏和工程图框.rar

回帖哦,好累.



游客,如果您要查看本帖隐藏内容请回复

发表于 2000-7-6 15:38:40 | 显示全部楼层
谢谢,看看。

发表于 2000-7-6 18:49:29 | 显示全部楼层

楼主辛苦

不过我们通常就是每个项目做一个统一的模板

而且不同项目的模板很多都不一样的(有可能包括大小,因为有国外项目)

仍然谢谢你啊

2 h4 \1 q% \4 z% W, n
[此贴子已经被作者于2006-6-5 18:50:22编辑过]
您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|手机版|小黑屋|CadCaeCamPlm专业门户网站 ( 蜀ICP备05008798号 ) 网站速度测试

GMT+8, 2018-9-21 18:49 , Processed in 0.102094 second(s), 22 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表