CATScript - Need Help with Adding to my documents list
CATScript - Need Help with Adding to my documents list
(OP)
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.
Please point out my (hopefully) simple error.
Thanks,
Jeff
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





RE: CATScript - Need Help with Adding to my documents list
Dim PartList as object
RE: CATScript - Need Help with Adding to my documents list
"Object required: 'PartList'"
Jeff
RE: CATScript - Need Help with Adding to my documents list
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
RE: CATScript - Need Help with Adding to my documents list
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 --> vbscrpt
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 WithStarting 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
https://picasaweb.google.com/102257836106335725208 - Romania
https://picasaweb.google.com/103462806772634246699... - EU
RE: CATScript - Need Help with Adding to my documents list
CODE
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
RE: CATScript - Need Help with Adding to my documents list
Regards
Fernando
https://picasaweb.google.com/102257836106335725208 - Romania
https://picasaweb.google.com/103462806772634246699... - EU
RE: CATScript - Need Help with Adding to my documents list
Regards
Fernando
https://picasaweb.google.com/102257836106335725208 - Romania
https://picasaweb.google.com/103462806772634246699... - EU
RE: CATScript - Need Help with Adding to my documents list
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
RE: CATScript - Need Help with Adding to my documents list
Regards
Fernando
https://picasaweb.google.com/102257836106335725208 - Romania
https://picasaweb.google.com/103462806772634246699... - EU
RE: CATScript - Need Help with Adding to my documents list
Jeff