Option Explicit
Sub CATMain()
Dim oDoc
Set oDoc = CATIA.Documents
Dim oDrawingDoc As DrawingDocument
On Error Resume Next
Err.Clear
Set oDrawingDoc = CATIA.Documents.Item("Drawing1.CATDrawing")
If Err.Number <> 0 Then
Set oDrawingDoc = oDoc.Add("Drawing")
End If
Dim windows1 As Windows
Dim specsAndGeomWindow1 As SpecsAndGeomWindow
Dim specsAndGeomWindow2 As SpecsAndGeomWindow
Set windows1 = CATIA.Windows
Set specsAndGeomWindow1 = windows1.Item(1)
Set specsAndGeomWindow2 = windows1.Item("Drawing1")
Dim oDSheets As DrawingSheets
Set oDSheets = oDrawingDoc.Sheets
Dim oDSheet As DrawingSheet
Set oDSheet = oDSheets.Item("Sheet.1")
Dim oDViews As DrawingViews
Set oDViews = oDSheet.Views
Dim oStr() As String
ReDim oStr(2)
oStr(0) = "RS": oStr(1) = "RR": oStr(2) = "PL"
Dim i
For i = 0 To 2
Dim oDView As DrawingView
Set oDView = oDViews.Add(oStr(i))
Next
specsAndGeomWindow1.Activate
Dim documents1 As Documents
Set documents1 = CATIA.Documents
Dim partDocument1 As PartDocument
Set partDocument1 = documents1.Item(specsAndGeomWindow1.Name & ".CATPart")
Dim product1 As Product
Set product1 = partDocument1.GetItem(Left(partDocument1.Name, InStr(partDocument1.Name, ".") - 1))
specsAndGeomWindow2.Activate
Dim vX1(), vY1(), vZ1()
Dim vX2(), vY2(), vZ2()
ReDim vX1(2), vY1(2), vZ1(2)
ReDim vX2(2), vY2(2), vZ2(2)
vX1(0) = 1: vY1(0) = 0: vZ1(0) = 0: vX2(0) = 0: vY2(0) = 0: vZ2(0) = 1
vX1(1) = 0: vY1(1) = -1: vZ1(1) = 0: vX2(1) = 0: vY2(1) = 0: vZ2(1) = 1
vX1(2) = -1: vY1(2) = 0: vZ1(2) = 0: vX2(2) = 0: vY2(2) = 1: vZ2(2) = 0
For i = 0 To 2
Set oDView = oDViews.Item(oStr(i))
Dim oDViewGB As DrawingViewGenerativeBehavior
Set oDViewGB = oDView.GenerativeBehavior
oDViewGB.Document = product1
oDViewGB.DefineIsometricView vX1(i), vY1(i), vZ1(i), vX2(i), vY2(i), vZ2(i)
oDView.X = 300
oDView.Y = 150
oDViewGB.Update
Next
End Sub
Sub CATMain()
Dim oDoc
Set oDoc = CATIA.Documents
Dim oDrawingDoc As DrawingDocument
On Error Resume Next
Err.Clear
Set oDrawingDoc = CATIA.Documents.Item("Drawing1.CATDrawing")
If Err.Number <> 0 Then
Set oDrawingDoc = oDoc.Add("Drawing")
End If
Dim windows1 As Windows
Dim specsAndGeomWindow1 As SpecsAndGeomWindow
Dim specsAndGeomWindow2 As SpecsAndGeomWindow
Set windows1 = CATIA.Windows
Set specsAndGeomWindow1 = windows1.Item(1)
Set specsAndGeomWindow2 = windows1.Item("Drawing1")
Dim oDSheets As DrawingSheets
Set oDSheets = oDrawingDoc.Sheets
Dim oDSheet As DrawingSheet
Set oDSheet = oDSheets.Item("Sheet.1")
Dim oDViews As DrawingViews
Set oDViews = oDSheet.Views
Dim oStr() As String
ReDim oStr(2)
oStr(0) = "RS": oStr(1) = "RR": oStr(2) = "PL"
Dim i
For i = 0 To 2
Dim oDView As DrawingView
Set oDView = oDViews.Add(oStr(i))
Next
specsAndGeomWindow1.Activate
Dim documents1 As Documents
Set documents1 = CATIA.Documents
Dim partDocument1 As PartDocument
Set partDocument1 = documents1.Item(specsAndGeomWindow1.Name & ".CATPart")
Dim product1 As Product
Set product1 = partDocument1.GetItem(Left(partDocument1.Name, InStr(partDocument1.Name, ".") - 1))
specsAndGeomWindow2.Activate
Dim vX1(), vY1(), vZ1()
Dim vX2(), vY2(), vZ2()
ReDim vX1(2), vY1(2), vZ1(2)
ReDim vX2(2), vY2(2), vZ2(2)
vX1(0) = 1: vY1(0) = 0: vZ1(0) = 0: vX2(0) = 0: vY2(0) = 0: vZ2(0) = 1
vX1(1) = 0: vY1(1) = -1: vZ1(1) = 0: vX2(1) = 0: vY2(1) = 0: vZ2(1) = 1
vX1(2) = -1: vY1(2) = 0: vZ1(2) = 0: vX2(2) = 0: vY2(2) = 1: vZ2(2) = 0
For i = 0 To 2
Set oDView = oDViews.Item(oStr(i))
Dim oDViewGB As DrawingViewGenerativeBehavior
Set oDViewGB = oDView.GenerativeBehavior
oDViewGB.Document = product1
oDViewGB.DefineIsometricView vX1(i), vY1(i), vZ1(i), vX2(i), vY2(i), vZ2(i)
oDView.X = 300
oDView.Y = 150
oDViewGB.Update
Next
End Sub
댓글
댓글 쓰기