Let’s Start Programming! Forums CATIA Macro Programming Convert Files from folder except…

This topic contains 5 replies, has 2 voices, and was last updated by  Matt 2 years, 5 months ago.

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #1686

    cadu1981
    Participant

    Hello.
    I am creating a VBscript to convert files from catpart and catdrawing to IGS PDF and DWG.
    I have a general folder and sub-folders with this names
    14805_001
    14805_001_001
    14805_001_003
    14805_001_004
    BUY-PARTS
    CUSTOMER-PARTS

    So this macro creates under each sub-folders 3 new folders with the converted files:
    DWG
    IGS
    PDF

    But for the other folders, “BUY-PARTS” and “CUSTOMER-PARTS” i dont want to covert nothig, and always create IGS from for example a gear-box…

    How can i say something like this:
    I want you to convert all folders, except folders with names “BUY-PARTS” and “CUSTOMER-PARTS”

    #1700

    Matt
    Participant

    Sub ReadFolderExcept()

    ‘Sets user name to the user logged in to the network on this computer
    Dim oNetwork
    Dim sUser As String
    Set oNetwork = CreateObject(“WScript.Network”)
    sUser = oNetwork.UserName

    Dim oFSO ‘As FileSystemObject ‘File System Object grants access to computer files and folders
    Dim oSourceFolder
    Dim oSubFolder
    Dim sSourceFolder As String

    Set oFSO = CreateObject(“Scripting.FileSystemObject”) ‘File System Object grants access to computer files and folders

    sSourceFolder = “C:\Users\” & sUser & “\Desktop\MainFolder” ‘Set the source folder where usage files were stored
    Set oSourceFolder = oFSO.GetFolder(sSourceFolder) ‘Tell File System Object to get a hold of oSourceFolder so you can look into it

    ‘Loop through folders unless they have a specific name
    For Each oSubFolder In oSourceFolder.SubFolders
    If oSubFolder.Name = “BUY-PARTS” Or oSubFolder.Name = “CUSTOMER-PARTS” Then
    ‘do nothing
    Else
    ‘add code to do what you want
    Debug.Print oSubFolder.Name
    End If
    Next

    End Sub

    #2005

    cadu1981
    Participant

    Hello.
    Thanks for your answer.

    Should i ask now here i put that??

    i will send to you PM

    #2006

    cadu1981
    Participant

    How can i contact you?

    #2027

    cadu1981
    Participant

    Hello again. I already have this code that aloud to load all files and folders

    ‘– Load all files in folders and sub-folders
    Function fCarregaListaFicheirosCATIA(CaminhoRaiz As String, FichCATDrawing As Boolean, FichCATPart As Boolean) As Boolean
    Dim FSO As FileSystemObject

    sCriarLOG “Entrei na função ‘fCarregaListaFicheirosCATIA’ – CaminhoRaiz=” & CaminhoRaiz
    On Error GoTo TrataErro

    Set ListaFicheiros_CATDrawing = New Collection
    Set ListaFicheiros_CATPart = New Collection

    Set FSO = CreateObject(“Scripting.FileSystemObject”)
    Call sShowSubFolders(FSO.GetFolder(CaminhoRaiz), FichCATDrawing, FichCATPart)

    fCarregaListaFicheirosCATIA = True
    sCriarLOG “A sair da função ‘fCarregaListaFicheirosCATIA’ com sucesso”
    Exit Function

    TrataErro:
    fCarregaListaFicheirosCATIA = False
    sCriarLOG “A sair da função ‘fCarregaListaFicheirosCATIA’ com erro: ” & Err.Description
    End Function

    What i need to change to load files and folders except folders with names “BUY-PARTS” and “CUSTOMER-PARTS”

    #2041

    Matt
    Participant

    On the line where I put ‘add code to do what you want, you would need to add your code there. I’m sorry, I don’t know what your code is doing exactly and it looks like it is only a portion of the code.

    I found some of this in the v5 automation chm file, maybe try putting this where I have ‘add code…

    Dim iPartDoc As Document
    Dim sDocPath as String

    For each oFile in oSubfolder
    sDocPath = oFile.Path
    If Instr(sDocPath, “CATPart”) <> 0 or Instr(sDocPath, “CATDrawing”) <> 0 then
    Set iPartDoc = CATIA.Documents.Open(sDocPath)
    End if
    Next

Viewing 6 posts - 1 through 6 (of 6 total)

The forum ‘CATIA Macro Programming’ is closed to new topics and replies.