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!

CATIA V5 Catalog creation using .CATScript

Status
Not open for further replies.

EVTCAM

Aerospace
Apr 14, 2016
3
US
Hello,

I'm new to the forums so I need a little direction. I have a .CATScript file that I know worked in either older releases of V5 and/or prior to Windows 7. I am getting errors now and am wondering if this is a place I can get some help with this. I don't have any experience with Visual Basic but need to get this project going while I'm trying to learn. If this is not the forum to get this help, please let me know.

Thank you.
 
Replies continue below

Recommended for you

I've attached the script file with the error. I've found out that there seems to be a problem with opening a file the way the script does in Win 7. I've also attached the error and the area of the file in question.

script1_t1edz8.jpg


script2_fdwhjh.jpg


Thanks.

 
Fernando,

Yes I did. I actually found the first article that shows up in your link. I tried some of the code but being a complete newbie on VB I just couldn't get it to work. I was just hoping to find someone like me, a CATIA user that's already gone through the problem.

Thanks
 
Interesting problem, it took me some time to figure how to do it (with help from Google, of course [smile]).

Is not the whole code, is just that part till changing the extension of the picked file from txt to csv and catalog.

Code:
 Language = "VBSCRIPT"

 Sub CATMain()
 
 Set wShell=CreateObject("WScript.Shell")
Set oExec=wShell.Exec("mshta.exe ""about:<input type=file id=FILE><script>FILE.click();new ActiveXObject('Scripting.FileSystemObject').GetStandardStream(1).WriteLine(FILE.value);close();resizeTo(0,0);</script>""")
sFileSelected = oExec.StdOut.ReadLine

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.GetFile(sFileSelected)

  szOpenFileName = objFSO.GetFileName(objFile)
  
' Check if file name ends with ".txt".
  If (Right(LCase(objFile.Name), 4) = ".txt") Then
    ' Rename the file.
    strOldName = objFile.Path
    strPath = objFile.ParentFolder
    strName = objFile.Name
    
    ' Change name by changing extension to ".csv"
    strName = Left(strName, Len(strName) - 4) & ".csv"
    strNewName = strPath & "\" & strName
    ' Rename the file.
   objFSO.CopyFile strOldName, strNewName
   
       ' Change name by changing extension to ".catalog"
    strName1 = Left(strName, Len(strName) - 4) & ".catalog"
    strNewName1 = strPath & "\" & strName1
    ' Rename the file.
   objFSO.CopyFile strOldName, strNewName1
   
  End If
 
 szSaveFileName = strNewName
 szCatalogFileName = strNewName1
 
 MsgBox szSaveFileName & "     "  & szCatalogFileName

End Sub



Regards
Fernando

- Romania
- EU
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Top