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!

CATScript - Need Help with Adding to my documents list 1

Status
Not open for further replies.

jmarkus

Mechanical
Jul 11, 2001
377
CA
I have a small routine that I am trying to use to get a text list of unsaved documents in my CATIA V5 session. I think I'm doing something that CATScript doesn't like, but should be okay in Visual Basic. When I run the script it doesn't like my method of adding to the PartList.

Code:
Sub CATMain()

Dim 	AllParts 	
Dim 	OpenPart 		
Dim 	QueryPart as string 			
Dim 	PartList as string
Dim 	J as integer

Set AllParts = CATIA.Documents

J = 0
For Each OpenPart In AllParts
	QueryPart = OpenPart.Name
	If OpenPart.Saved = False Then
		PartList.Add(QueryPart)
		J=J+1
	End If
Next

MsgBox "There are " & J & " unsaved documents"
MsgBox PartList

End Sub

Please point out my (hopefully) simple error.

Thanks,
Jeff
 
Replies continue below

Recommended for you

Does it work if you change the variable declaration to:

Dim PartList as object
 
No, it throws the same error:

"Object required: 'PartList'"

Jeff
 
I also tried just

Dim Partlist

(without declaring a type) but that didn't work either. It gave me the same error. So now I'm wondering if it is related to my use of .Add as opposed to the specific type of variable.

Jeff
 
Hi,

I don't know and I didn't see something like what are you trying to do in CATIA automation documentation but I would try something else.

If you are working with files on hard disk you can check for each file in folder in vbscript which file was saved in last 30 minutes for example

Code:
With CreateObject("Scripting.FileSystemObject")
    For Each File In .GetFolder("c:\Temp\").Files
        If DateDiff("n", File.DateLastModified, Now) < 30 Then
            ' File has been modified in past 30 minutes.
            Msgbox "Got one" & "    " & File.Name
        End If
    Next
End With

Starting with this, you can imagine various scenarios like getting the path and the name for each part or product loaded in CATIA, input the starting time of the session and exclude or include in your DateLastModified calculation criteria what you want.

Regards
Fernando

- Romania
- EU
 
Thanks Ferdo, but I know this code can work, because if I simply report with a MsgBox, it does tell me if the file is unsaved (modified) or not.

Code:
For Each OpenPart In AllParts
	QueryPart = OpenPart.Name
	If OpenPart.Saved = False Then
		MsgBox QueryPart & "Is Unsaved"
		'PartList.Add(QueryPart)
		J=J+1
	End If
Next

But as soon as I uncomment/activate the PartList.Add line it throws the error. That is why I think it is just a programming error on my part, but I don't know how to fix it.

Jeff
 
Okay, as I suspected, I was missing something from VBScript:

Code:
Set PartList = CreateObject("System.Collections.ArrayList")

Once I added this, the error went away. Now to figure out the rest of my code...maybe stay tuned for a new post...

Thanks,
Jeff
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Top