Welcome to the COE Discussion Forum! 

 

To participate in the discussion forum, you must be logged in to the website.  If you forget your login information, please contact COE Headquarters at coe@coe.org or (800) 263-2255.

If you are new to the COE Discussion Forum and would like to participate, please register.


Register Today
COE 2009 Annual PLM Conference & TechniFair

COE DISCUSSION FORUM
Subject: Copy File "Quietly" - no user interaction

You are not authorized to post a reply.   
Author Messages
BASH

11 Oct 2007 03:38 PM
Im pulling my hair out trying to figure out how to do a copyfile through the CATIA intergration without the CopyFile dialog appearing.  Here is the code that I have.  Everything works just cannot figure out how to run it silent.

Sub CopyFileObject(SmSession As SmApplic.SmSession, WorkObject As SmApplic.ISmObject)
   
    Dim oIntgTool As SMCADINTERFACELib.SmCADInterface
    Dim FullPath As Variant
    Dim Ret As Integer
   
    Set oIntgTool = SmSession.GetService("SmCad.SmCADInterface"
    Ret = oIntgTool.UserLogin("CATIA", STUser, STPassword)
   
    ' Specify object of file to copy
    ClassId = WorkObject.ClassId
    ObjId = WorkObject.ObjectId
   
    ' Copy file
    Ret = oIntgTool.CopyFile(ObjId, ClassId, FullPath)
    If Ret = 0 Then
        MsgBox FullPath
    Else
        MsgBox "Copy file failed"
    End If

End Sub

Thanks in advance...

Mike
HALE


12 Oct 2007 12:35 AM
0Mike,

This takes you in a slightly different direction, but the following code placed in your routine should give you a read-only copy of the file (registered with the SMARTEAM-FileCatalog). I don't remember which library you have to have referenced right off hand to get the stiEngine (another CATIA integration). There is another thread where Eduardo mentioned it. Just search for stiEngine

I left the comments in so you can see other commands available.

I was looking for "CATIA Drawing" You would use the ObjectID you are already using and "CATIA Part" or "CATIA Product"

Hope this helps.

Regards
Hale

Set stiEngine = CATIA.GetItem("CAIEngine")
If Err.Number <> 0 Then
MsgBox "Aborting - Not Connected to SmarTeam"
End
End If
Err.Clear
Dim myVb As StiVB

Set myVb = stiEngine.GetItem("CATStiVB")

'myVb.BulkLoading
'myVb.CAIOpen (FilePath as String)
'myVb.ClearListOfVisitedPoints (no param)
'myVb.CompareASCIIFiles ASCIFilePath1 as String, ASCIfilePath2 as String, outTXTfilePath
' as String) as Boolean
'myVb.CopyFile (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
'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)
'MsgBox myVb.name (CTIAStiVB0)
' 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.PerfoDisplayAllResults (pathToFile as String)
'myVb.PerfoDisplayResults (PathtoFile as String)
'myVb.PerfoStart
'myVb.PerfoStop
'myVb.ProcessCOOTFlyList (no parameters)
'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
'stiEngine.Parent
'stiEngine.RefreshInfo
'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
' myDBitem.name
' myDBitem.Parent
'Dim smApplic As Object
Dim smSession As Object
Err.Clear
'ISmApplication smApplic =
'(ISmApplication)System.Activator.CreateInstance(System.Type.GetTypeFromProgID("SmarTeam.SmApplication"));
'return smApplic.Engine.get_Sessions(0);
' smApplic = System.Activator.CreateInstance(GetTypeFromProgID("SmarTeam.SmApplication"))
' If Err.Number <> 0 Then
' MsgBox "Applic not set"
' End If
Err.Clear
' smApplic.En
'smApplic.

' smSession = smApplic.Sessions(0)
If Err.Number <> 0 Then
MsgBox "Session not set"
End If




If Err.Number <> 0 Then
MsgBox "Aborting - Not stiVB not loaded"
End
End If

Err.Clear



myVb.FastCopyDocument "CATIA Drawing", lObjectId



Badencorp - CATIA/SmarTeam - Installation, Training and Support!
An hour of hard work can often save you 60 seconds on Google.
BASH

12 Oct 2007 08:44 AM
Hale

Thanks for the info.  I did try that yesterday with no success.  But I did find another way to get the information.  This is something that I am doing in another program.  It is using the SmSessionUtil (have no idea why I didnt think about that yesterday). 

Thanks
Mike

Heres what I did to make it work:

Sub CopyFileObject(SmSession As SmApplic.SmSession, WorkObject As SmApplic.ISmObject)

' Setting the SmarTeam operation to copy the file from SmarTeam to the users work location
    '  metainfo object for smClasses
    Dim MetaInfo As SmApplic.SmMetaInfo
    Set MetaInfo = SmSession.MetaInfo
   
    ' Setting SmarTeam Session Utility
    Dim SessionUtil As SmSessionUtil
    Set SessionUtil = SmSession.GetService("SmUtil.SmSessionUtil"
   
    Dim DefTaskList As Object
    Set DefTaskList = Nothing
    Dim ObjectAndTreeTasks As Object
    Set ObjectAndTreeTasks = Nothing
   
    Dim Operation As SmApplic.ISmOperation
    If Not (WorkObject Is Nothing) Then
        Set Operation = MetaInfo.OperationsForClass(WorkObject.ClassId, False).ItemByName("CopyFile"
        If SessionUtil.OperationAllowedOnObject(WorkObject, Operation, False) Then
            SessionUtil.ExecuteOperationOnObjectTree WorkObject, Operation, True, ObjectAndTreeTasks, DefTaskList
        End If
    End If

End Sub
You are not authorized to post a reply.
Forums > COE Forums > SmarTeam > Copy File "Quietly" - no user interaction



ActiveForums 3.6

    

401 North Michigan Avenue, Chicago, IL 60611-4267 | (312) 321-5153 | (800) COE-CALL (U.S.)