You are on page 1of 3

COE : Forums : How can I replace the "Background View" ?

1 of 3

http://www.coe.org/p/fo/et/thread=23024

Jul 02
2010
How can I replace the "Background View" ?
Jinil Kim
[Nara Mold
& Die]

How can I replace the "Background View" ?


July 2, 2010 05:08 AM

Dear all!
How can I replace the "Background View"?

I always do
"Page Setup"-> Change "Sheet Style" --> "Insert Background View" --> "Browse" -->
Search my template drawing (A4,A3,A2,A1....) --> "Insert" --> O.K.
I recorded that process in to macro but the record was nothing...
Please help me!

Attachments
00002.jpg (40k)

Xavier
Klein
[Staubli]

Jinil Kim
[Nara Mold
& Die]

RE: How can I replace the "Background View" ?


July 2, 2010 09:53 AM (in response to Jinil Kim)

Hello,
If you have a few specific Template File with cartridge and so ...
I advise you to write a short Macro with
CATIA.Documents.NewFrom (MyTemplateDrawFile)

RE: How can I replace the "Background View" ?


July 4, 2010 11:21 PM (in response to Jinil Kim)

Dear X.KLEIN
I know the "Newfrom" function.
I can not use that, because I had already created some views and dimensions.
After creating all components(views,dimensions, etc.), sometimes the paper size was too small or too big.
So, I need to change the papersize and background view(title box) --> every paper size has different title box.
Best Regards!
Jinil

Xavier
Klein
[Staubli]

RE: How can I replace the "Background View" ?


July 5, 2010 04:30 AM (in response to Jinil Kim)

Hello,
here is the way that I manage cartridge with a macro
1) all the cartridge frame is define in one Drawing DETAIL
2) all text from cartridge are define witha specific name : cartridge_title_1 , cartridge_reference , cartridge_date .....
3) according Cartridge size , position HV of each text is define in a TablePosition (TextName, , CartridgeFormat, Position_H , Position_V ,
Size)
4) when I change cartridge size :
- I replace in the background view Cartridge_Detail_A1 by Cratridge_Detail_A0
- update position of each Text with TablePosition
This take a few Time , to fill TablePosition for each text , but the code to do it is very basic !

11-02-2014 12:42

COE : Forums : How can I replace the "Background View" ?

2 of 3

Xavier
Klein

http://www.coe.org/p/fo/et/thread=23024

RE: How can I replace the "Background View" ?


July 5, 2010 08:38 AM (in response to Jinil Kim)

[Staubli]

here is a sample code , to replace the Detail from the Background view :
Sub DeleteCartouche()
Set CATIA = GetObject(, "CATIA.Application")
'1) Ouverture du Model avec le cartouche
Set MyDraw = CATIA.ActiveDocument
Dim MySheet As DrawingSheet
Dim view_car As DrawingView
Dim i As Integer
Dim j As Integer
For i = 1 To MyDraw.Sheets.Count
Set MySheet = MyDraw.Sheets.Item(i)
If MySheet.IsDetail Then
GoTo LaSuite
End If
Set view_car = MySheet.Views.Item(2)
For j = 1 To view_car.Components.Count
If Left(view_car.Components.Item(j).Name, 2) = Left(MySheet.PaperName, 2) Then
view_car.Components.Remove (j)
GoTo prochainevue
End If
Next j
prochainevue:
Dim NbText As Integer
NbText = view_car.Texts.Count
For j = NbText To 1 Step -1
If Left(view_car.Texts.Item(j).Name, 10) = "Texte.car_" Then
view_car.Texts.Remove (j)
End If
Next j
LaSuite:
Next i
Call ModuleCartouche.CreerParametre("", "cartouche")
End Sub

Sub CreerCartouche(SIZE As String)


'creation du cartouche dans le model actif
'Size A0-A1-A2-A3-A4
'initialisation
' Le cartouche est copie depuis un fichier de reference
Dim i As Integer
Dim RefFile As String
If RefDir "" Then
RefFile = RefDir & "Cartridge.CATDrawing"
Else
RefFile = "O:\SCM\ADMIN\STANDARD\Cartridge.CATDrawing"
End If
Set CATIA = GetObject(, "CATIA.Application")
Set MyDraw = CATIA.ActiveDocument
Dim DefaultSheet As DrawingSheet
Set DefaultSheet = MyDraw.Sheets.ActiveSheet
Dim DefaultView As DrawingView
Set DefaultView = DefaultSheet.Views.ActiveView

Dim NbSheet As Integer


NbSheet = NombredeSheet
FormCartouche.Tag = 0
'1) Ouverture du Model avec le cartouche
Dim DocRef As DrawingDocument
Set DocRef = CATIA.Documents.Open(RefFile)
Dim MySheet As DrawingSheet
Set MySheet = DocRef.Sheets.Item(1)
Dim viewnumber As Integer
viewnumber = 0
For i = 1 To MySheet.Views.Count
If Trim(Left(MySheet.Views.Item(i).Name, 2)) = SIZE Then
viewnumber = i
End If
Next
If viewnumber = 0 Then
MsgBox "ERROR select view"
Exit Sub
End If

Dim MyComponentRef As DrawingView


Set MyComponentRef = MySheet.Views.Item(viewnumber)
'3) Coller du cartouche dans toutes les sheets
MyDraw.Activate
For i = 1 To MyDraw.Sheets.Count
Set MySheet = MyDraw.Sheets.Item(i)
'''''''''' cas des vues de detail
If MySheet.IsDetail Then
GoTo LaSuite

11-02-2014 12:42

COE : Forums : How can I replace the "Background View" ?

3 of 3

http://www.coe.org/p/fo/et/thread=23024

All Times America/New_York


Copyright 2013 COE. All Rights Reserved
800-COE-CALL - 330 N. Wabash Ave, Suite 2000 - Chicago, IL 60611 USA
All material, files, logos and trademarks within this site are properties of their respective organizations.
Terms of Service - Privacy Policy - Contact

11-02-2014 12:42

You might also like