Showing results for 
Search instead for 
Did you mean: 

Question about EndModeling method on the ITxComponent

Siemens Legend Siemens Legend
Siemens Legend



From the API view I have a EndModeling method on the ITxComponent Interface but with a path parameter.
From where should I know the path of the component, when before opening into a modeling state it was in the library and I want have it back on the same place in the lib?




You can use the following code to get the filePath:


TxObjectList children = TxApplication.ActiveSelection.GetItems();


if (children.Count > 0)


       ITxComponent obj = children[0] as ITxComponent;

       if (obj != null && !obj.IsOpenForModeling)


              string value = string.Empty;


               ITxStorable storableObject = obj as ITxStorable;

               TxStorage storage = storableObject.StorageObject;


                if (storage is TxLibraryStorage)


                      string filePath  = (storage as TxLibraryStorage).FullPath;



                      //do your changes








Re: Question about EndModeling method on the ITxComponent

Siemens Phenom Siemens Phenom
Siemens Phenom

How could I do end-modelling on Teamcenter?


Re: Question about EndModeling method on the ITxComponent

Siemens Phenom Siemens Phenom
Siemens Phenom

Currently there is no API available method for End Modeling on Teamcenter platform.

The ITxComponent.EndModeling method can be called only in Process Simulate on eMServer or Process Simulate Standalone.

Re: Question about EndModeling method on the ITxComponent


I have a problem with the EndModeling method however:


Sometimes, it is necessary to store the cojt at a different path than we have loaded it from. But, when I try to save the cojt, it always stores the component at the original location.


Here is the code I have so far:


public override void Execute(object cmdParams)
// get the selection
TxObjectList selection = TxApplication.ActiveSelection.GetItems();
if (selection.Count < 1) return;
ITxComponent component = selection.First() as ITxComponent;

if (component == null || !component.IsOpenForModeling) return;

// get the name of the component
string componentName = component.Name;

// init file dialog
SaveFileDialog sfd = new SaveFileDialog
FileName = componentName + ".cojt",
Filter = "Component files (*.cojt)|*.cojt|All files (*.*)|*.*",
InitialDirectory = TxApplication.SystemRootDirectoryNormalized + "LIB_ROOT"

// show file dialog
DialogResult dialogResult = sfd.ShowDialog();
if (dialogResult != DialogResult.OK) return;

// concat jt path and name
string cojtPath = sfd.FileName;
if (!Directory.Exists(cojtPath)) Directory.CreateDirectory(cojtPath);
string jtPath = cojtPath + "\\" + cojtPath.Split('\\').LastOrDefault()?.Replace(".cojt", string.Empty);

if (string.IsNullOrEmpty(jtPath)) return;
Debug.WriteLine(jtPath, "saving component " + componentName + " to");

// this should save the component to the new path
// but the component is saved at the original location
catch (TxComponentSaveAsFailedException ex)
Debug.WriteLine("Couldn't save modeling changes.");
catch (Exception ex)


Everything works as expect, except for the wrong path. It even saves the component, but at the original location. The path parameter given to the EndModeling method would be something like:




Some additional information:

  • We are using Process Simulate 13.0 Hotfix 18
  • We try to save a component that is either loaded in a study or its prototype is dragged from the library into the cell.
  • The component is set to modeling scope by the usual Process Simulate command (not via API)
  • Only one component is set to modeling scope


I'd be very grateful if someone could help me out here. Thanks.


Re: Question about EndModeling method on the ITxComponent

Valued Contributor
Valued Contributor

Hi Zefrank,


you can copy the component to local storage using the function CopyToLocal in TxLibraryStorage class and than save JT using SaveToLibrary function:

'create temporary folder

Dim workPath As String = IO.Path.Combine(TxApplication.SystemRootDirectory, "Temp")

If Not IO.Directory.Exists(workPath) Then


End If

'save the object in the temporary folder

Dim libraryData As TxLibraryData = New TxLibraryData(workPath, cojtFileName)

Dim localStorage As TxLocalStorage = Nothing

If TypeOf obj.StorageObject Is TxLibraryStorage Then

localStorage = DirectCast(obj.StorageObject, TxLibraryStorage).CopyToLocal()


localStorage = DirectCast(obj.StorageObject, TxLocalStorage)

End If




Re: Question about EndModeling method on the ITxComponent

Siemens Phenom Siemens Phenom
Siemens Phenom

Hi zafank,


A-S-E gave you a good example. EndModeling updates the existing cojt and does not make a copy of it. In order to make a copy, you need to use the SaveToLibrary method of TxLocalStorage class. You can use the SaveComponent method to save the modeling changes localy only as a jt file.


Here is the example in C#:

            ITxStorable selectedComponent = TxApplication.ActiveSelection.GetItems()[0] as ITxStorable;

            TxLibraryData libraryData = new TxLibraryData(path, "test.cojt");

            TxLocalStorage storage;
            if (selectedComponent.StorageObject is TxLibraryStorage)
                storage = (selectedComponent.StorageObject as TxLibraryStorage).CopyToLocal();
                storage = selectedComponent.StorageObject as TxLocalStorage;




Best Regards,