Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

DELETE ALL IN THE BACKGROUND 2

Status
Not open for further replies.

JeniaL

Mechanical
Jun 3, 2014
547
IL
This code works well with one sheet
Code:
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
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.
 
Replies continue below

Recommended for you

Try this:

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 Sub

Tesak
- Curved text for Catia V5
 
Thanks a lot. This is exactly what i need.
 
Ferdo said:
Set mySelection = DrwDocument.Selection
mySelection.Search "Drafting.View.Name='Background View' "

mySelection.Search "Type=*,scr"
mySelection.Delete

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.
 
Well this works not as i expected. I juts used twice For...Next. To fit all sheets in takes some time in Catia but code keeps to run to next loop that is deletion.
 
How about this?

Code:
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 Sub

Regards
Fernando

- Romania
- EU
 
i tried to use sleep instead of message. for the second example i get macro works much faster that catia and i don't actually get all drawing sheets fitted in. definitely that is because i remotely connected to my work PC. i'll give it a try tomorrow when i get to work.

Thanks Ferdo for your help.

Cheers.
 
if you google shellandwait you can have catia to start another process and wait for the return of the process before continuing... I m using this in some script where I unzip a file in a folder... had to make sure all unzipped before starting to do anything.

Eric N.
indocti discant et ament meminisse periti
 
Thanks itsmyjob for shellandwait. I'll google for that. Don't want to start a new thread so I'm asking this question here.
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?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Top