I get the TxUnknownErrorException by trying to read the color of the Tx2Or3DimensionalGeometry.
This is my code, with which I can reproduce the exception:
Dim devices As TxObjectList = TxApplication.ActiveDocument.PhysicalRoot.GetAllDescendants(New TxTypeFilter(GetType(TxDevice)))
Dim deviceObj As ITxObject = devices.First()
Dim testDevice As TxDevice = deviceObj
Dim geometries As TxObjectList = testDevice.GetAllDescendants(New TxTypeFilter(GetType(Tx2Or3DimensionalGeometry)))
For Each geometryobj As ITxObject In geometries
Dim geometry As Tx2Or3DimensionalGeometry = geometryobj
Dim color As TxColor = geometry.Color
Message: Error in the application.
at Tecnomatix.Engineering.Implementation.TxRose.GetObjectColor(TxObjectImpl objImpl)
at ASE.... (my code)
What is wrong with this device?
Solved! Go to Solution.
Just by examining your code I'm uncertain why this should not work. Might be it relates to some specific geometry your device contains. Does this happen with any device?
I can suggest to turn on Tecnomatix Application Logs via Tx Doctor, and post the last log errors after you run your code.
Another suggestion (might not work, but worth a try) is to try the ITxDisplayableObject interface instead of Tx2Or3DimensionalGeometry. I.e.:
Dim geometries As TxObjectList = testDevice.GetAllDescendants(NewTxTypeFilter(GetType(ITxDisplayableObject)))
For Each displayableObj As ITxDisplayableObject In geometries
Dim color As TxColor = displayableObj.Color
I apologize for a delay. I have done some experiments with this issue. I get the error with ITxDisplayableObject also.
Please find the application log to the error in the attachment.
Color property returns only the instance (engineering) color of the object (if any), otherwise it throws exception (the one that you got).
Instead you can use the GetColors() method of ITxDisplayableObject that returns also the prototype colors if no instance colors are defined for the object.
how can I check is the geometry an instance object or no before I try to get a color? Just put this operatio in try catch block? I n case of many geometries it wil make a performance problem.