Hello, i need some help here.
I am trying to create macro to paste everything from background view from template drawing to background view of active drawing sheet. Code needs to choose right sheet from template drawing and it does so by creating string from paper size and orientation on active sheet and some selection from combobox. this is pretty simple stuff. now my code opens template and choses right sheet and copies everything from background view but it fails on line where i need to add active sheets background view to selection (see code below). Error message i get is "Object doesnt support this property or method" and i really don't understand why. Also it gives same error if i try to add sheet to selection instead of view. After it pastes it should close template file but that should be simple enough. All objects in code that start with "t" are template ones and "o" are active sheet ones. I am using VBA. Catia V5R21
Thank you for your time
I am trying to create macro to paste everything from background view from template drawing to background view of active drawing sheet. Code needs to choose right sheet from template drawing and it does so by creating string from paper size and orientation on active sheet and some selection from combobox. this is pretty simple stuff. now my code opens template and choses right sheet and copies everything from background view but it fails on line where i need to add active sheets background view to selection (see code below). Error message i get is "Object doesnt support this property or method" and i really don't understand why. Also it gives same error if i try to add sheet to selection instead of view. After it pastes it should close template file but that should be simple enough. All objects in code that start with "t" are template ones and "o" are active sheet ones. I am using VBA. Catia V5R21
Thank you for your time
Code:
Private Sub btnImport_Click()
Dim oDocs As Documents
Set oDocs = CATIA.Documents
Dim oDoc As DrawingDocument
Set oDoc = CATIA.ActiveDocument
Dim oSel As Selection
Set oSel = oDoc.Selection
Dim oSheets As DrawingSheets
Set oSheets = oDoc.Sheets
Dim oSheet As DrawingSheet
Set oSheet = oSheets.ActiveSheet
Dim oViews As DrawingViews
Set oViews = oSheet.Views
Dim obckView As DrawingView
Dim ori As String
Dim size As String
Dim lang As String
Dim SastName As String
Select Case oSheet.Orientation
Case 1
ori = "L"
Case 0
ori = "P"
End Select
Select Case oSheet.PaperSize
Case 2
size = "A0"
Case 3
size = "A1"
Case 4
size = "A2"
Case 5
size = "A3"
Case 6
size = "A4"
End Select
Select Case Me.obLang1.Value
Case True
lang = "HR"
Case False
lang = "EN"
End Select
SastName = size & ori & "-" & lang & "-" & Me.cbSastavnica.Value
Dim tDoc As DrawingDocument
Set tDoc = oDocs.Open("E:\Scripts\Sastavnice.CATDrawing")
Dim tSheets As DrawingSheets
Set tSheets = tDoc.Sheets
Dim tSheet As DrawingSheet
Set tSheet = tSheets.Item(SastName)
Dim tViews As DrawingViews
Set tViews = tSheet.Views
Dim tbckView As DrawingView
Set tbckView = tViews.Item(2)
Dim tSel As Selection
Set tSel = tDoc.Selection
tSel.Clear
Dim tGeoElements As GeometricElements
Set tGeoElements = tbckView.GeometricElements
For Each tElement In tGeoElements
tSel.Add (tElement)
Next
For Each tText In tbckView.Texts
tSel.Add (tText)
Next
tSel.Copy
oDoc.Activate
Set obckView = oDoc.Sheets.ActiveSheet.Views.Item(2)
oSel.Clear
oSel.Add (obckView) **************** BREAKS HERE ******************
oSel.Paste
End Sub