Hi Leute,
so, nachdem fast alle meine Scripts durch die Hilfe vieler von euch hier im Forum fertig geworden sind stehe ich vor einem letzten kleinen Problem.
Ich möchte in eine geöffnete Zeichnung ein Detail Sheet einer Referenzzeichnung einfügen (darauf befinden sich diverse Views).
Mein Script:
Sub CATMain()
CATIA.DisplayFileAlerts = False
' Set the Drawing document where the view will be pasted
Dim oDrawingTarget As DrawingDocument
Set oDrawingTarget = CATIA.ActiveDocument
' Open the Source Drawing document
Dim oDrawingSource As DrawingDocument
Set oDrawingSource = CATIA.Documents.Open("C:\...\startdrawing_reference_r19.CATDrawing")
' Fit in window the opened document
CATIA.ActiveWindow.ActiveViewer.Reframe
' Retrieve the sheet containing the view to be duplicated
Dim oSource As DrawingSheet
Set oSource = oDrawingSource.Sheets.Item("Title Blocks")
' Create an object of selection for the source document
Dim oSelectionSource As Selection
Set oSelectionSource = oDrawingSource.Selection
oSelectionSource.Clear
oSelectionSource.Add oSource ' Add the sheet to be duplicated in the selection
oSelectionSource.Copy
oSelectionSource.Clear
' Sets new Drawing active
Call oDrawingTarget.Activate
' Retrieve the drawing where the sheet will be pasted
Dim oTarget As DrawingDocument
Set oTarget = CATIA.ActiveDocument
' Create an object of selection for the target document
Dim oSelectionTarget As Selection
Set oSelectionTarget = oDrawingTarget.Selection
oSelectionTarget.Clear
' Add the drawing where the sheet will be pasted in the selection
oSelectionTarget.Add oDrawingTarget.Sheets.Item(1)
' Paste the clipboard
oSelectionTarget.Paste
oSelectionTarget.Clear
' Fit in window the active document
CATIA.ActiveWindow.ActiveViewer.Reframe
' Clear the variables
Call oDrawingSource.Close
Set oSelectionTarget = Nothing
Set oTarget = Nothing
Set oDrawingTarget = Nothing
Set oSelectionSource = Nothing
Set oDrawingSource = Nothing
End Sub
Das Ganze hängt hier (Laufzeitfehler):
oSelectionTarget.Add oDrawingTarget.Sheets.Item(1)
Ich muss in der aktiven Zeichnung ja eine Selektion erzeugen, um das kopierte Blatt der Referenzzeichnung einfügen zu können.
Mein Zeile ist definitiv falsch da ich keine Ahnung habe was dort hin gehört. Jemand eine Ahnung?
Weiterhin muss ich irgendwie sicherstellen, dass das Blatt als DetailSheet eingefügt wird und nicht als normales Zeichnungsblatt.
Hat da evtl. auch noch jemand eine Idee wie man dies sicherstellen könnte?
Vielen Dank und Gruß
Sven
Eine Antwort auf diesen Beitrag verfassen (mit Zitat/Zitat des Beitrags) IP