Autor
|
Thema: Zeichnungsrahmen in aktives Drawing einfügen (5251 mal gelesen)
|
HOnKeY Mitglied
Beiträge: 20 Registriert: 23.01.2006
|
erstellt am: 02. Feb. 2006 16:39 <-- editieren / zitieren --> Unities abgeben:
Hallo, wieder mal ein Prob. Habe ein fertiges Script in der Catia Doku gefunden, in dem ein Drawing als Zeichnungsrahmen in ein neues Drawing eingefügt wird. Möchte nun dieses Script umändern, so dass es den Zeichnungsrahmen nicht in ein neues Drawing einfügt, sondern in das aktive. Hier erstmal das unveränderte Script: Code: Option Explicit ' COPYRIGHT DASSAULT SYSTEMES 2003' *********************************************************************** ' Purpose: This macro allows you to copy a view from an ' existing drawing document into a new drawing ' document ' Author: ' Languages: VBScript ' Locales: English ' CATIA Level: V5R11 ' *********************************************************************** Sub CATMain() ' Set the CATIA popup file alerts to False ' It prevents to stop the macro at each alert during its execution CATIA.DisplayFileAlerts = False ' Optional: allows to find the sample wherever it's installed dim sDocPath As String sDocPath=CATIA.SystemService.Environ("CATDocView") If (Not CATIA.FileSystem.FolderExists(sDocPath)) Then Err.Raise 9999,,"No Doc Path Defined" End If ' Open the Drawing document Dim oDrawingSource As DrawingDocument Set oDrawingSource = CATIA.Documents.Open(sDocPath & _ "\online\CAAScdDriUseCases\samples\CAADriDuplicateAView.CATDrawing") ' Fit in window the opened document CATIA.ActiveWindow.ActiveViewer.Reframe ' Retrieve the sheet containing the view to be duplicated Dim oSheetSource As DrawingSheet Set oSheetSource = oDrawingSource.Sheets.Item("Sheet.1") ' Retrieve the view to be duplicated Dim oViewSource As DrawingView Set oViewSource = oSheetSource.Views.Item("Front view") ' Create an object of selection for the source document Dim oSelectionSource As Selection Set oSelectionSource = oDrawingSource.Selection ' Clear the selection oSelectionSource.Clear ' Add the view to be duplicated in the selection oSelectionSource.Add oViewSource ' Copy the view oSelectionSource.Copy ' Clear the selection oSelectionSource.Clear ' Create the Drawing document where the view will be pasted Dim oDrawingTarget As DrawingDocument Set oDrawingTarget = CATIA.Documents.Add("Drawing") ' Retrieve the where the view will be pasted Dim oSheetTarget As DrawingSheet Set oSheetTarget = oDrawingTarget.Sheets.Item("Sheet.1") ' Set the sheet paper size oSheetTarget.PaperSize = catPaperA0 ' Create an object of selection for the source document Dim oSelectionTarget As Selection Set oSelectionTarget = oDrawingTarget.Selection ' Clear the selection oSelectionTarget.Clear ' Add the sheet where the view will be pasted in the selection oSelectionTarget.Add oSheetTarget ' Paste the clipboard oSelectionTarget.Paste ' Clear the selection oSelectionTarget.Clear ' Fit in window the active document CATIA.ActiveWindow.ActiveViewer.Reframe ' Clear the variables Set oSelectionTarget = Nothing Set oSheetTarget = Nothing Set oDrawingTarget = Nothing Set oSelectionSource = Nothing Set oViewSource = Nothing Set oSelectionSource = Nothing Set oDrawingSource = Nothing End Sub
Hier meine Version. Hängt jedesmal beim oSelectionTarget.Paste. Der einzige unterschied zum obrigen ist, dass ich das ActiveDocument schon ganz oben in oDrawingTarget speicher anstatt unten ein neues Drawing zu erzeugen und oDrawingSource wird unten wieder geschloßen, aber so weit komtm es ja garnicht. Code: Private Sub Form_Load() Dim oCatia As Application Set oCatia = GetObject(, "CATIA.Application") ' Set the CATIA popup file alerts to False ' It prevents to stop the macro at each alert during its execution oCatia.DisplayFileAlerts = False ' Create the Drawing document where the view will be pasted Dim oDrawingTarget As DrawingDocument Set oDrawingTarget = oCatia.ActiveDocument ' Open the Drawing document Dim oDrawingSource As DrawingDocument Set oDrawingSource = oCatia.Documents.Open("F:\xxxPFAD zu DRAWINGxxx\RAHMEN-A3.CATDrawing") ' Fit in window the opened document oCatia.ActiveWindow.ActiveViewer.Reframe ' Retrieve the sheet containing the view to be duplicated Dim oSheetSource As DrawingSheet Set oSheetSource = oDrawingSource.Sheets.Item("Sheet.1") ' Retrieve the view to be duplicated Dim oViewSource As DrawingView Set oViewSource = oSheetSource.Views.Item(2) ' Create an object of selection for the source document Dim oSelectionSource As Selection Set oSelectionSource = oDrawingSource.Selection ' Clear the selection oSelectionSource.Clear ' Add the view to be duplicated in the selection oSelectionSource.Add oViewSource ' Copy the view oSelectionSource.Copy ' Clear the selection oSelectionSource.Clear ' Retrieve the where the view will be pasted Dim oSheetTarget As DrawingSheet Set oSheetTarget = oDrawingTarget.Sheets.Item("Sheet.1") ' Set the sheet paper size oSheetTarget.PaperSize = catPaperA3 ' Create an object of selection for the source document Dim oSelectionTarget As Selection Set oSelectionTarget = oDrawingTarget.Selection ' Clear the selection oSelectionTarget.Clear ' Add the sheet where the view will be pasted in the selection oSelectionTarget.Add oSheetTarget ' Paste the clipboard oSelectionTarget.Paste ' Hier stürzt das Programm ab ' Clear the selection oSelectionTarget.Clear ' Fit in window the active document oCatia.ActiveWindow.ActiveViewer.Reframe ' Clear the variables Call oDrawingSource.Close Set oSelectionTarget = Nothing Set oSheetTarget = Nothing Set oDrawingTarget = Nothing Set oSelectionSource = Nothing Set oViewSource = Nothing Set oSelectionSource = Nothing Set oDrawingSource = Nothing
Eine Antwort auf diesen Beitrag verfassen (mit Zitat/Zitat des Beitrags) IP |
HOnKeY Mitglied
Beiträge: 20 Registriert: 23.01.2006
|
erstellt am: 03. Feb. 2006 11:25 <-- editieren / zitieren --> Unities abgeben:
Des Rätzels Lösung: Ein Code: Call oDrawingTarget.Activate
vor dem Zuweisen des Sheets vollbringt wahre Wunder. Code: ' Clear the selection oSelectionSource.Clear ' Add the view to be duplicated in the selection oSelectionSource.Add oViewSource ' Copy the view oSelectionSource.Copy ' Clear the selection oSelectionSource.Clear ' Sets new Drawing active HIER DIE LÖSUNG Call oDrawingTarget.Activate ' Retrieve the where the view will be pasted Dim oSheetTarget As DrawingSheet Set oSheetTarget = oDrawingTarget.Sheets.Item("Sheet.1")
Eine Antwort auf diesen Beitrag verfassen (mit Zitat/Zitat des Beitrags) IP |
KlausXP Mitglied Dipl.-Ing.
Beiträge: 70 Registriert: 17.09.2004 CATIA V5 R19 SP9 HF78 Ansys Mechanical WB14.5 /Cadnexus 3.15 WIN XP64 SP2
|
erstellt am: 06. Dez. 2010 13:33 <-- editieren / zitieren --> Unities abgeben: Nur für HOnKeY
Hallo Forum, gerade versuche ich dieses Makro an unsere Umgebung anzupassen. Unsere Zeichnungsrahmen und Schriftköpfe sind in einem Katalog abgelegt. Wenn ich das Makro starte, läuft es ebenfalls nur bis zum Einfügen, es kommt die Fehlermeldung "Nothing could be pasted in the selected item". Kann mir jemand einen Tip geben, woran es liegen könnte? Vielen Dank. Grüße Klaus Sub CATMain() Dim documents1 As Documents Set documents1 = CATIA.Documents Dim drawingDocument1 As DrawingDocument 'Hier wird die Startzeichnung geöffnet, in die kopiert werden soll Set drawingDocument1 = documents1.NewFrom("xx\#CATIAV5.TEMPLATES\Startdrawing.CATDrawing") Dim viewBackground As DrawingView drawingDocument1.Sheets.Item(1).Views.Item(2).Activate 'Background aktivieren Dim oDrawingSource As DrawingDocument 'Hier wird der Katalog geöffnet, aus dem Kopiert werden soll Set oDrawingSource = CATIA.Documents.Open(sDocPath & _ "Z:\work\SCHRIFTKOPF.CATDrawing") 'Retrieve the sheet containing the view to be dublicated Dim oSource As DrawingView 'Hier wird die Ansicht ausgewählt, in der sich der Zeichnungsrahmen befindet. Set oSource = oDrawingSource.Sheets.Item(1).Views.Item(5) 'Rahmen DINA4 ' 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 drawingDocument1.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 = drawingDocument1.Selection oSelectionTarget.Clear ' Add the drawing where the sheet will be pasted in the selection oSelectionTarget.Add drawingDocument1.Sheets.Item(1).Views.Item(1) ' Paste the clipboard oSelectionTarget.Paste oSelectionTarget.Clear ' Clear the variables Call oDrawingSource.Close Set oSelectionTarget = Nothing Set oTarget = Nothing Set oDrawingTarget = Nothing Set oSelectionSource = Nothing Set oDrawingSource = Nothing End Sub
Eine Antwort auf diesen Beitrag verfassen (mit Zitat/Zitat des Beitrags) IP |
bgrittmann Moderator Konstrukteur
Beiträge: 11780 Registriert: 30.11.2006 CATIA V5R19
|
erstellt am: 06. Dez. 2010 14:33 <-- editieren / zitieren --> Unities abgeben: Nur für HOnKeY
Servus Handelt es sich bei der Quell oder Zielzeichnung um ein Detail-Blatt? Fall es unterschiedliche Blatttypen gibt geht das nicht. Ggf erste auf einem Detail-Blatt zwischenspeichern, dann die 2D-Komponente zerlegen und dann rüberkopieren. Gruß bernd ------------------ Warum einfach, wenn es auch kompliziert geht. Eine Antwort auf diesen Beitrag verfassen (mit Zitat/Zitat des Beitrags) IP |
KlausXP Mitglied Dipl.-Ing.
Beiträge: 70 Registriert: 17.09.2004 CATIA V5 R19 SP9 HF78 Ansys Mechanical WB14.5 /Cadnexus 3.15 WIN XP64 SP2
|
erstellt am: 06. Dez. 2010 15:00 <-- editieren / zitieren --> Unities abgeben: Nur für HOnKeY
Danke für den Hinweis. Die Quelle, also der Katalog, ist ein normales Blatt, in das sämlich Rahmen und Schriftköpfe drinnen sind. Das Ziel soll später mal ein Detailblatt sein, ist im Moment aber noch Blat 1. Bedeutet "auf einem Detail-Blatt zwischenspeichern" in der Vorlage ein Detailblatt erzeugen, und da rein speichern? Bisher konnte ich auch manuell über Copy und Paste den Schriftkopf nicht kopieren. Wenn ich den Schriftkopf aber mit "instantiate" verdopple, läßt er sich kopieren. Wäre das auch ein Weg? Eine Antwort auf diesen Beitrag verfassen (mit Zitat/Zitat des Beitrags) IP |
KlausXP Mitglied Dipl.-Ing.
Beiträge: 70 Registriert: 17.09.2004 CATIA V5 R19 SP9 HF78 Ansys Mechanical WB14.5 /Cadnexus 3.15 WIN XP64 SP2
|
erstellt am: 23. Dez. 2010 14:37 <-- editieren / zitieren --> Unities abgeben: Nur für HOnKeY
|
BW78 Mitglied Azubi in Sachen CAD
Beiträge: 21 Registriert: 22.02.2018 Catia V5-6R2014 SP3 Win 7
|
erstellt am: 26. Feb. 2018 09:24 <-- editieren / zitieren --> Unities abgeben: Nur für HOnKeY
Hallo zusammen, ich schaue immer wieder gerne in dieses Forum, da man hin und wieder nicht weiter weiß. Nun habe ich mir mithilfe dieser Informationen auf dieser Seite ein Makro erstellt. Es klappt wunderbar, jedoch habe ich ein Problem, wenn es mehrere Blätter in einer Zeichnung gibt. Möchte ich z.B. das Blatt 3 einen neuen Rahmen geben, so springt das Makro immer zu Blatt 1 und ändert dieses. Ich bin absoluter Neuling in Sache Programmierung und komme deshalb einfach nicht weiter. Ich schaffe es nicht das aktive Blatt zu bestimmen und den Rahmen dann dorthin zu kopieren. Vielleicht kann mir ja jemand einen Hinweis geben. Viele Grüße Max Eine Antwort auf diesen Beitrag verfassen (mit Zitat/Zitat des Beitrags) IP |
bgrittmann Moderator Konstrukteur
Beiträge: 11780 Registriert: 30.11.2006 CATIA V5R19
|
erstellt am: 26. Feb. 2018 09:34 <-- editieren / zitieren --> Unities abgeben: Nur für HOnKeY
Servus Max Willkommen im Forum. Wie definierst du wo der Rahmen eingefügt wird? Etwa über die Blattnaummer bzw den Blattnamen? Code: Set oSheetTarget = oDrawingTarget.Sheets.Item("Sheet.1") 'über Namen Set oSheetTarget = oDrawingTarget.Sheets.Item(1) 'über die Nummer
dann kannst du stattdessen über: Code: Set oSheetTarget = oDrawingTarget.Sheets.ActiveSheet
auf das aktuelle Blatt zugreifen. Gruß Bernd ------------------ Warum einfach, wenn es auch kompliziert geht. Eine Antwort auf diesen Beitrag verfassen (mit Zitat/Zitat des Beitrags) IP |
BW78 Mitglied Azubi in Sachen CAD
Beiträge: 21 Registriert: 22.02.2018 Catia V5-6R2014 SP3 Win 7
|
erstellt am: 26. Feb. 2018 09:43 <-- editieren / zitieren --> Unities abgeben: Nur für HOnKeY
|