cancel
Showing results for 
Search instead for 
Did you mean: 

[PS11.1] TxLibraryStorage throws an exception

Legend
Legend

Hello,

i try to get the prototype name from the TxLibraryStorage object with the following code

        /// <summary>
        /// Get prototype file name for a gun
        /// </summary>
        /// <param name="prototype"></param>
        /// <returns></returns>
        internal static string GetPrototypeName(ITxGun prototype)
        {
            string storageName = null;

            if (prototype.GetType() == typeof(TxServoGun))
            {
                TxServoGun servogun = (TxServoGun)prototype;
                TxLibraryStorage servogunStorage = (TxLibraryStorage)servogun.StorageObject;
                TxLibraryData storageData = servogunStorage.LibraryData; //throws an exception in 11.1
                storageName = storageData.Path;

                //storageName = ((TxLibraryStorage)((TxServoGun)prototype).StorageObject).LibraryData.Path;
            }
            else if (prototype.GetType() == typeof(TxGun))
            {
                storageName = ((TxLibraryStorage)((TxGun)prototype).StorageObject).LibraryData.Path;
            }
            else
            {
                return null;
            }

            return getPrototypeName(storageName);
        }

But i get the following exceException.pngption.

 

 

 

 

Is there a problem in 11.1 with the TxLibraryStorage object or is anything wrong in my code?

 

8 REPLIES

Re: [PS11.1] TxLibraryStorage throws an exception

Siemens Phenom Siemens Phenom
Siemens Phenom

Hi,

 

Which platform is that? Is the gun open for modeling?

Re: [PS11.1] TxLibraryStorage throws an exception

Legend
Legend

Hello DianaG,

 

this is Version 11.1 x64 on Windows.

The gun is not open for modelling.

 

In later versions I work with the FullPath-Property of TxLibraryStorage, which was introduced in 11.1TR3.

Re: [PS11.1] TxLibraryStorage throws an exception

Siemens Phenom Siemens Phenom
Siemens Phenom

Is that Process Simulate on eMServer? Then maybe you can use the mechanism to read the field value.

//local members of a class
TxEmsTraversalManager traversalManager = new TxEmsTraversalManager();
TxEmsCacheManager cacheManger = new TxEmsCacheManager();

public object GetValue()
{
                object value = null;

TxObjectList children = TxApplication.ActiveDocument.PhysicalRoot.GetAllDescendants(new TxTypeFilter(typeof(ITxComponent)));
                TxObjectList planingList = children.PlanningRepresentations;

                if (planingList.Count > 0)
                {
                                //you can check if the planning type is of specific eMS type
                                 ITxPlanningObject planning = planingList[0] as ITxPlanningObject;
                
                                cacheManger.Clear();
                                cacheManger["test"].SetRootObject(planning);
                                cacheManger["test"].SetPath("prototype", "threeDRep", "file");
                                cacheManger["test"].SetAttributes("fileName");                             

                
                                traversalManager["test"].SetRootObject(planning);
                                traversalManager["test"].SetPath("prototype", "threeDRep", "file");
                                traversalManager["test"].SetAttributes("fileName");

                                try
                                {
cacheManger.CacheData();
traversalManager.Traverse();
}
catch
{
}                              

                                if (traversalManager["test"].Traversed)
                                 {
                                                TxEmsTraversalObjectResultData data = traversalManager["test"].GetTraversalObjectData(planning);
                                                ArrayList results = data.GetAttributeValues("fileName");
                                                value = results[0];
                                }
            }

                return value;
}

Best Regards,

Diana

Re: [PS11.1] TxLibraryStorage throws an exception

Legend
Legend

Hello DianaG!

Thank you for your support.

The goal is to get the full path name of an component in a disconnected study. the pathname is shown in the 3D File column in the object tree. The disconnected cells were all stored as disconnected studies in Process Simulate on emServer. Does your solution work in disconnected?

Re: [PS11.1] TxLibraryStorage throws an exception

Siemens Phenom Siemens Phenom
Siemens Phenom

Hi MarkusH,

 

It will not work for Disconnected. 

 

Best Regards,

DianaG

Re: [PS11.1] TxLibraryStorage throws an exception

Legend
Legend

Hello DianaG!

 

Final question. Is there no way at all to get the path of a component in disconnected mode?

If no I can stop wasting my time on it!  Smiley Sad

Re: [PS11.1] TxLibraryStorage throws an exception

Siemens Phenom Siemens Phenom
Siemens Phenom

Hello MarkusH,

 

Unfortunately, there is no API for the Path in V11.1 for Disconnected.

 

Best Regards,

DianaG

Re: [PS11.1] TxLibraryStorage throws an exception

Legend
Legend

Thank you!