cancel
Showing results for 
Search instead for 
Did you mean: 

how to Add new Component into Library

Creator
Creator

hi:

    i have put a cojt file to Sysroot Folder,and i want to add this model to ResourceLibrary.

    My code is as follows:

    

string path2= "E:\\Sysroot\\LIB_ROOT\\Project_Library\\test.cojt";
TxInsertComponentCreationData insertData = new TxInsertComponentCreationData("test", path);


insertData.Prototype=?????  // I  do not know how to set prototype;
ITxComponentCreation compCreate = TxApplication.ActiveDocument.PhysicalRoot;
ITxComponent comp = compCreate.InsertComponent(insertData);

ITxStorable scomp = comp as ITxStorable;
TxLocalStorage storage;
if (scomp.StorageObject is TxLibraryStorage)
{
storage = (scomp.StorageObject as TxLibraryStorage).CopyToLocal();
}
else
{
storage = scomp.StorageObject as TxLocalStorage;
}

TxLibraryData libraryData = new TxLibraryData(""E:\\Sysroot\\LIB_ROOT\\Project_Library\\", "test.cojt");
storage.SaveToLibrary(libraryData);

 

There is some content, I do not know how to write。

I don't know if my whole method is correct,Are there any other ways of achieving my goal?

my tecnomatix version is 12.1.1

14 REPLIES

Re: how to Add new Component into Library

Siemens Phenom Siemens Phenom
Siemens Phenom

Hello Dongyang,

 

You can check this article, there is an example on how to create prototype data for .cojt and how to insert that .cojt to Process Simulate.

 

Best Regards,

DianaG

Re: how to Add new Component into Library

Creator
Creator
Thank you for your reply. i had read that article before,That's Tecnomatix version is 13,but my is 12. The properties and methods are not available.

Re: how to Add new Component into Library

Siemens Phenom Siemens Phenom
Siemens Phenom

Hello Dongyang,

 

If your .cojt already has TuneData.xml, then you need only to insert it, the first part of your code.

 

string path2= "E:\\Sysroot\\LIB_ROOT\\Project_Library\\test.cojt";
TxInsertComponentCreationData insertData = new TxInsertComponentCreationData("test", path);
ITxComponentCreation compCreate = TxApplication.ActiveDocument.PhysicalRoot;
ITxComponent comp = compCreate.InsertComponent(insertData);

Best Regards,

DianaG

Re: how to Add new Component into Library

Creator
Creator
It is complex task, I think PS API is not support yet, you must use EmServer COM library to do it,
Step1: Create cojt folder in LIBROOT
Step2: Use EmServer COM Library to create resource library node, also prototype node
Step3: After creating prototype, you get external ID and create associate TuneData.xml in cojt folder
Step4: Using 'TxInsertComponentCreationData' class to insert to cell,

Re: how to Add new Component into Library

The insert component method is a little messy in that the component goes under the root instead of placing it directly where you want. Below will place it under the first active selection.

 

 

You can then use the code you already have here on the component object created below.   (although I am not sure TxLocalStorage is the right class to use, I think there is another storage class for eMs types)

 

 

 

TxNewPartResourceParametersEx txNewPartResourceParametersEx = new TxNewPartResourceParametersEx();

txNewPartResourceParametersEx.Type = "PmToolPrototype";

 

TxApplication.CommandsManager.ExecuteCommand("ComponentOperations.NewResource", txNewPartResourceParametersEx);

 

TxComponent component = txNewPartResourceParametersEx.CreatedObject as TxComponent;

 

storage = component.StorageObject as TxLocalStorage;

TxLibraryData libraryData = new TxLibraryData(""E:\\Sysroot\\LIB_ROOT\\Project_Library\\", "test.cojt");
storage.SaveToLibrary(libraryData);

Re: how to Add new Component into Library

Creator
Creator

thank you ,Cliff_Knasinski,but the “TxNewPartResourceParametersEx” is not supported by Tecnomatix 12.1。

Re: how to Add new Component into Library

Creator
Creator

Hello, Cliff!

Which is this written for? I have not find class TxNewPartResourceParametersEx neither in version 13.0 nor in version 13.0.2.

 

Witalij.

Re: how to Add new Component into Library

I was using this back in 11TR3 version, and is still working in the latest release today.  You have to include additional libraries from the eMpower folder as resources for the solution.  Thye are below.

 

using EngineeringInternalExtension.CommandParameters;

 

Include the EngineeringInternalExtension.dll from eMPower.

Re: how to Add new Component into Library

"It is complex task, I think PS API is not support yet, you must use EmServer COM library to do it,
Step1: Create cojt folder in LIBROOT
Step2: Use EmServer COM Library to create resource library node, also prototype node
Step3: After creating prototype, you get external ID and create associate TuneData.xml in cojt folder
Step4: Using 'TxInsertComponentCreationData' class to insert to cell,"

 

The only problem with this method is the last step.  It will insert the component under the root of the study, but if you have a specific object tree location you want to put it in it does not work.

 

My method above will create a new component which modeling scope can be closed on with the .SaveToLibrary() method.  You must have the compound resource you want to place it in as the ActiveSelection of the ActiveDocument though. You can give it a library path to place it in as well with this method. This also creates the TuneData.xml file correctly in the cojt folder without having to write XML generating code that could have errors and cause crashes.