DELETE ALL IN THE BACKGROUND
DELETE ALL IN THE BACKGROUND
(OP)
This code works well with one sheet
But i want to run thru all the sheets and delete everything in the background view.
In spite of For Each DrwSheet ....next, it's not going to next sheet.
Any help will be appreciated.
Cheers.
CODE --> vb
For Each DrwSheet In MyDrawingDoc.Sheets
Selection.Search "Drafting.View.Name='Background View' "
Selection.Search "Type=*,scr"
Selection.Remove (1)
Selection.Delete
drwviews.Item("Main View").Activate
Next In spite of For Each DrwSheet ....next, it's not going to next sheet.
Any help will be appreciated.
Cheers.





RE: DELETE ALL IN THE BACKGROUND
just it seems you don't use anything link to DrwSheet in your loop
maybe a DrwSheet.activate would help....
didn't you get your morning coffee yet or is it me?
indocti discant et ament meminisse periti
RE: DELETE ALL IN THE BACKGROUND
Tried to switch to background view and delete all using the same code to run thru all the sheets and it works but this command removed all the texts in my drawing.
RE: DELETE ALL IN THE BACKGROUND
Dim oDrwView as DrawingView
Set oDrwView = DrwSheet.Views.Item(2)
call oDrwView.Activate
Selection.Add(oDrwView)
Selection.Search "Type=*,sel"
Selection.Remove (1)
Selection.Delete
DrwSheet.Views.Item(1).Activate
Mild Correction above.
RE: DELETE ALL IN THE BACKGROUND
indocti discant et ament meminisse periti
RE: DELETE ALL IN THE BACKGROUND
In my first post i forgot to take out selection to a separate Sub. Now code runs thru all the sheets.
But something definitely going wrong.
I run this code
CODE --> vb
In working views everything is ok. In addition to that i can't access background view on second or whatever sheet.
Jeez what that code done?
RE: DELETE ALL IN THE BACKGROUND
Let me try
For Each DrwSheet In MyDrawingDoc.Sheets
I m not in front of CATIA and this in not tested but the spirit is there, something like that should work
indocti discant et ament meminisse periti
RE: DELETE ALL IN THE BACKGROUND
I remembered Doug's code behavior, it is really strange. That's why I done what you posted, JeniaL.
Hope what is below will work for you.
CODE --> CATScript
Sub CATMain() Set DrwDocument = CATIA.ActiveDocument Set DrwSheets = DrwDocument.Sheets For i = 1 to DrwSheets.count On Error Resume Next Set DrwSheet = DrwSheets.Item(i) DrwSheet.Activate CATIA.StartCommand "Fit All In" Set DrwView = DrwSheet.Views.Item("Background View") DrwView.Activate Dim mySelection As Selection Set mySelection = DrwDocument.Selection mySelection.Search "Drafting.View.Name='Background View' " mySelection.Search "Type=*,scr" mySelection.Delete DrwSheet.Views.Item(1).Activate Next End SubRegards
Fernando
https://picasaweb.google.com/102257836106335725208 - Romania
https://picasaweb.google.com/103462806772634246699... - EU
RE: DELETE ALL IN THE BACKGROUND
RE: DELETE ALL IN THE BACKGROUND
Regards
Fernando
https://picasaweb.google.com/102257836106335725208 - Romania
https://picasaweb.google.com/103462806772634246699... - EU
RE: DELETE ALL IN THE BACKGROUND
Might be worthwhile to construct a query (Advanced Tab) in the CATIA Search tool that will capture all of the items you think may be included in the background views (Geometry, Text, Dimensions, etc) and use that as your search string for the VB method. If you run a CATIA search through the GUI, hit the 'Add to Favorites' icon, the text in the Query section can be used directly in the VB Search Method argument.
--Doug
RE: DELETE ALL IN THE BACKGROUND
With a code you wrote if with several sheets i can switch to background only with a first sheet. I can draw 2D geometry but now text.
For the rest of a sheets i can't access background. Seems like it's gone.
P.S I'll also try to submit this code to DS for their explanation.
RE: DELETE ALL IN THE BACKGROUND
How to delete selection only from current sheet?
p.s How to tell VB not to show me error message?
i know exact reason why macro fails and i'm ok with that. I don't want to see a message about that.
CODE --> VB6
CreateNewFileForMfg: On Error GoTo error_filter dTexts.GetItem("TitleBlock_Text_Title_6").Text = ProductDrawn.ReferenceProduct.UserRefProperties.Item("FILE FOR MANUFACTURING").ValueAsStringRE: DELETE ALL IN THE BACKGROUND
2.
On Error Resume Next
Regards
Fernando
https://picasaweb.google.com/102257836106335725208 - Romania
https://picasaweb.google.com/103462806772634246699... - EU
RE: DELETE ALL IN THE BACKGROUND
Not clearly understand that. Could you please explain.
RE: DELETE ALL IN THE BACKGROUND
Regards
Fernando
https://picasaweb.google.com/102257836106335725208 - Romania
https://picasaweb.google.com/103462806772634246699... - EU
RE: DELETE ALL IN THE BACKGROUND
selection1.Add drawingDocument1.Sheets.ActiveSheet.Views.ActiveView
selection1.Search "Drafting.Text,selection1"
Seems like ActiveSheet doesn't work. Delete command deletes a text from all drawing sheets.
RE: DELETE ALL IN THE BACKGROUND
Regards
Fernando
https://picasaweb.google.com/102257836106335725208 - Romania
https://picasaweb.google.com/103462806772634246699... - EU
RE: DELETE ALL IN THE BACKGROUND
selection1.Search "Drafting.Text,selection1"
This code is from another program where i just replace/delete text. I'm not running thru all drawing sheets and search for text however
Search command tells Catia to search thru the entire document. Google seems to be not really helpful.
What ActiveSheet really tells to Catia?
RE: DELETE ALL IN THE BACKGROUND
Tesak
http://scripts4all.eu/txtoncurve/ - Curved text for Catia V5
RE: DELETE ALL IN THE BACKGROUND
CODE -->
Sub DeleteTexts() Dim doc Set doc = CATIA.ActiveDocument Dim sheet Set sheet = doc.Sheets.ActiveSheet Dim views Set views = sheet.views Dim view, textboxes, i For Each view In views Set textboxes = view.Texts For i = textboxes.Count To 1 Step -1 textboxes.Remove i Next Next End SubTesak
http://scripts4all.eu/txtoncurve/ - Curved text for Catia V5
RE: DELETE ALL IN THE BACKGROUND
RE: DELETE ALL IN THE BACKGROUND
This is works pretty well but requires drawing sheet to be fitted on screen in order to to delete all entities. I tried to add command to fit drawing on screen and here is the issue comes. When fit all command is executed macro keeps to run and doesn't wait for Catia to finish fitting all drawing sheets on screen. Sleep command doesn't helps me. My goal is to delete everything from background except background view.
RE: DELETE ALL IN THE BACKGROUND
Regards
Fernando
https://picasaweb.google.com/102257836106335725208 - Romania
https://picasaweb.google.com/103462806772634246699... - EU
RE: DELETE ALL IN THE BACKGROUND
RE: DELETE ALL IN THE BACKGROUND
CODE --> CATScript
Sub CATMain() Set DrwDocument = CATIA.ActiveDocument Set DrwSheets = DrwDocument.Sheets For j = 1 to DrwSheets.count Set DrwSheet = DrwSheets.Item(j) DrwSheet.Activate CATIA.StartCommand "Fit All In" Next '''''''''''''''''''''''''''''''''''''''''''''' MsgBox "STOP - Give me a break :-)" For i = 1 to DrwSheets.count Set DrwSheet = DrwSheets.Item(i) DrwSheet.Activate CATIA.StartCommand "Fit All In" Set DrwView = DrwSheet.Views.Item("Background View") DrwView.Activate Dim mySelection As Selection Set mySelection = DrwDocument.Selection mySelection.Search "Drafting.View.Name='Background View' " mySelection.Search "Type=*,scr" mySelection.Delete DrwSheet.Views.Item(1).Activate Next '''''''''''''''''''''''''''''''''''''''''''''' MsgBox "Let's fit all in again" For z= 1 to DrwSheets.count Set DrwSheet = DrwSheets.Item(z) DrwSheet.Activate CATIA.StartCommand "Fit All In" Next End SubRegards
Fernando
https://picasaweb.google.com/102257836106335725208 - Romania
https://picasaweb.google.com/103462806772634246699... - EU
RE: DELETE ALL IN THE BACKGROUND
Thanks Ferdo for your help.
Cheers.
RE: DELETE ALL IN THE BACKGROUND
indocti discant et ament meminisse periti
RE: DELETE ALL IN THE BACKGROUND
I want to put a logo on my title block but i don't want to load a picture from local or network drive. Is there a way to store a picture inside VB6 project and then grab and insert it into Catia drawing?