RE: Save or Release a Part from CATIA
September 17, 2007 12:55 AM
(in response to Hale Pringle)
Eduardo,
Thanks for the code snippets. I've done a ton of Java work and more
recently VB6 and CATIA VBA. I haven't ever needed to get into
either C# or .net. I was interested in the stiEngine since it gives
VBA code access to the current SmarTeam Engine. If we got the
current session, we would have a good bit of what is needed to
write a number of untility functions. I can access a new engine and
a new session with VB, VBA, and SmarTeam Scripts. I just wanted to
access the current session if possible.
I did find in the VBA code more functionality associated with the
stiEngine: I was looking up the functionality and decided to go
ahead and share the methods and parameters.
Dim stiEngine As stiEngine
Dim myDBItem As StiDBItem
Dim myVB As StiVB
Dim lObjectId as Long
Dim newFileName as String
Err.Clear
'Initialize the Engine (if you are connected to SmarTeam, then the
stiEngine
' is connected)
Set stiEngine = CATIA.GetItem("CAIEngine"
If Err.Number 0 Then
MsgBox "Aborting - Not stiEngine could not be created"
End
End If
Err.Clear
'initialize the VB functionality
Set myVB = stiEngine.GetItem("CATStiVB"
lObjectId = 44444
newFileName = "TestPart.CATDrawing"
err.clear
' Copy and Item out of SmarTeam into your work folder and register
it with the
' SMARTEAM.FileCatalog (This is a read-only open)
myVb.FastCopyDocument "CATIA Drawing", lObjectId
If Err.Number 0 Then
msgbox "File could not be copied out ObjectID: "
+ cstr(lObjectID)
Else
Set drwDocument = documents1.Open("C:\AWork" +
newFileName)
' Set the DBItem which eposes more functionality
Set myDBitem =
stiEngine.GetStiDBItemFromAnyObject(CATIA.activeDocument)
End If
' Now you can check things etc. If you had checked the item
out instead of
' obtaining a read-only copy then you could check it back in or
release it.
Here are the methods and their parameters
myVB.BulkLoading (no Paramaters)
myVB.CAIOpen (FilePath as String)
myVB.ClearListOfVisitedPoints (no Parameters)
myVB.CompareASCIIFiles ASCIFilePath1 as String, ASCIfilePath2 as
String, outTXTfilePath as String) as Boolean
myVB.CopyFilemy(ClassName as String, ObjectId as Long) as
String ??
myVB.DumpDocDescriptors (FilePath as String)
myVB.FastCopyDocument (ClassName as String, jObjectId as Long)
myVB.FindDocument (iFileName as String, iUUID as String,
iSTClassBehavior as String, iSTFileType as String,ClassID as
Integer) as Long
myVB.GenerateXMLReport(jCATIADoc as Document, XMLFilePath as
String)
myVB.GetClassName (DocumentSelected as Document) as String
myVB.GetItem (jDName as String) as CATBaseDispatch
myVB.GetObjectID (DocumentSelected as Document) as Long
myVB.GetRevisionObjectID (DocumentSelected as Document,
RevisionSelected as String) as Long
myVB.GetWork (no parameters)
myVB.GlobalRefresh (DocumentSelected as Document) as Document
myVB.InsertComponent(jProduct as AnyObject, ClassName as String,
ObjectId as Long, DialogueBox as Boolean)
myVB.IsDocUnloadable (jdoc as Document, oAnswer as Integet,
oisModified as Integer)
myVB.LoadPropertiesFromDB (DocumentSelected as Document)
myVB.MarkPointAsVisited (PointName as String)
myVB.Name (name of VBA beind used. "CATIAStiVB0" for now)
myVB.myVb.NewRelease (DocumentSelected as Document, DialogueBox as
Boolean)
myVB.OpenInReadOnly (ClassName as String, ObjectId as Long) as
Document
myVB.OpenInReadOnlyRevision(ClassName as String, DcoumentId as
String, DocumentRevision as String) as Document
myVB.Parent (no Parameters)
myVB.PerfoDisplayAllResults (pathToFile as String)
myVB.PerfoDisplayResults (PathtoFile as String)
myVB.PerfoStart (no parameters)
myVB.PerfoStop (no parameters)
myVB.ProcessCOOTFlyList (no parameters) ...hmmmm...
myVB.ReleaseDocument (DocumentSelected as Document, DialogueBox as
Boolean)
myVB.ReplaceWithSelectedRevision (DocumentSelected as Document,
RevisionWanted as String) as Document
myVB.SaveAs (Document as Document)
myVB.SavePropertiesInDB (Document as Document)
myVB.SynchronizeFileWithDB (ClassId as Integer, ObjectId as
Long)
myVB.WasPointVisited (PointName as String) as Long
stiEngine.BuildDocDBItemFromSmarTeamID(jObjectID as Long, iClassId
as Integer) as StdDbItem
stiEngine.BuildFileDBItemFromSmarTeamID(jObjectID as Long, iClassId
as Integer) as StdDbItem
stiEngine.Connect (jUserLogin as String, iUserPassword as
String)
stiEngine.Disconnect (no Parameters)
stiEngine.GetItem (jDName as String) as CATBaseDispatch
stiEngine.GetSMARTEAMClassID (iStdDBItem as StiDBItem) as
Integer
stiEngine.GetSMARTEAMObjectID (iStdDBItem as StiDBItem) as Long
stiEngine.GetStiDBItemFromAnyObject (iAnyObject as AnyObject) as
StiDBItem
stiEngine.GetStiDBItemFromCATBSTR (iFullPath as String) as
StiDBItem
stiEngine.GetTeamPDMURL (iStiDBItem as StiDBItem) as String
stiEngine.IntegrationType (no parameters)
stiEngine.IsConnected (no parameters)
stiEngine.LifeCycleCheckIn (iStiDBItem as StiDBItem)
stiEngine.LifeCycleCheckOut (iStiDBItem as StiDBItem)
stiEngine.LifeCycleCheckOutPropagated (iStiDBItem as StiDBItem)
stiEngine.LifeCycleNewRelease (iStiDBItem as StiDBItem)
stiEngine.LifeCycleNewReleasePropagated (iStiDBItem as
StiDBItem)
stiEngine.LifeCycleRelease (iStiDBItem as StiDBItem)
stiEngine.LifeCycleUndoCheckOut (iStiDBItem as StiDBItem)
stiEngine.name (no parameters)
stiEngine.Parent (no parameters)
stiEngine.RefreshInfo (no parameters)
stiEngine.Save (iStiDBItem as StiDBItem)
stiEngine.UseGraphicalUI
myDBitem.Application
myDBitem.GetChildren
myDBitem.GetDocument
myDBitem.GetDocumentFullPath
myDBitem.GetItem (iDName as String) as CATBaseDispatch
myDBitem.IsCFOType
myDBitem.IsRoot (no parameters)
myDBitem.name (no parameters)
myDBitem.Parent (no parameters)
Without documentation I have to try each one to figure out what it
does. For example the SavePropertiesInDB takes a Document as a
Parameter. I suspect it invokes the automatic linking we set up in
the Application Integration Screen, but I haven't tried it.
I have used the FastCopyDocument.(ClassName as String, jOjbectId as
Long)
myVb.FastCopyDocument("CATIA Drawing", 4444) will copy the drawing
with objectId = 4444 from SmarTeam into the work directory. It also
adds the document to the SmarTeam-FileCatalog folder. I wasn't able
to do this fully with SmarTeam Script code.
I wrote a Quick and Dirty SmarTeam Script to read a list of file
names, queried SmarTeam and wrote a text file of ObjectIds and
CAD_REF_FILE_NAMEs (the file name written to the work folder). Then
I used VBA to read this file and use the stiEngine and stiVB code
to copy each file out of SmarTeam, open it, do some checking and
then close the document. Its nice to do that with VBA and have
CATIA closely involved in the whole process.
I see some real possibilities for using the stiEngine and the stiVB
objects for quick and dirty utility functions.
Thanks again for you help!
Regards,
Hale