cancel
Showing results for 
Search instead for 
Did you mean: 

[.NET C#] Get prototype name

Legend
Legend

Hello,

how can I get the prototype name of a robot?

For example, "KR2210" for a Kuka robot.

 

The solution should also work in offline mode.

 

8 REPLIES

Re: [.NET C#] Get prototype name

Legend
Legend

Hi,

 

what do you exactly mean with "prototype name"?

 

The name of the cojt file or the resource name in PS?

Re: [.NET C#] Get prototype name

Legend
Legend

Hi,

 

Prototype name (name of *.co or *.cojt): kr2210l150_2

The resource name is the instance name, isn't it?

 

I tried something with Tecnomatix.Planning, but it obviously doesn't work in offline.

Maybe there is an approach with the library path, or with Manipulator type.

 

 

 

Re: [.NET C#] Get prototype name

Siemens Phenom Siemens Phenom
Siemens Phenom

This is how to get it on eMS:

                   // get prototype
                    ITxPlanningObject oRobotProto = TxRobot.PlanningRepresentation.GetField("prototype") as ITxPlanningObject;
                    if (oRobotProto == null) return null;

                    // get 3D representation
                    ITxPlanningObject r3d = oRobotProto.GetField("threeDRep") as ITxPlanningObject;
                    if (r3d == null) return null;

                    // get 3D file
                    ITxPlanningObject pmFile = r3d.GetField("file") as ITxPlanningObject;
                    if (pmFile == null) return null;
                    string sPrototypeFile = pmFile.GetField("fileName") as string;

                    // combine it with SYSROOT
                    sPrototypeFile = sPrototypeFile.TrimStart('#', '\\', '/');
                    return Path.Combine(TxApplication.SystemRootDirectory, sPrototypeFile);

I do not know if there is a solution in Disconnected mode or on TeamCenter.

Re: [.NET C#] Get prototype name

Creator
Creator

Hi everyone,

 

i saw this solution, but for me in disconnected mode it is not working !

 

When my app comes to

ITxPlanningObject r3d = value.GetField("threeDRep") as ITxPlanningObject;

 

it crashes with error :

Tecnomatix.Engineering.TxPlanningObjectFieldNotLoadedException: error in application.
   at Tecnomatix.Engineering.Implementation.TxRose.PlanningObjectGetField(TxPlanningObjectImpl assignment, String fieldName)
   at Tecnomatix.Planning.TxPlanningObject.GetField(String fieldName)

 

so my question is, maybe in PS 11.1 there is a new name for "threeDRep" ?

 

or how could i get a list of fieldNames in GetField method ?

 

when i try GetFields method with a string array, PS crashed completly !

 

Thanks in advance

Re: [.NET C#] Get prototype name

Siemens Phenom Siemens Phenom
Siemens Phenom

As mentioned, this solution works only on PS on eMS. I do not know of any solution in PS Disconnected or PS on TC...

Re: [.NET C#] Get prototype name

Creator
Creator

Thanks for your answer,

 

your solution works good with connected to database.

 

OK, now i have a new way to get that information i want, but i need the path and name of the .psz file, that is actually opened in process simulate disconnected.

 

Do you know a way to get that over the api ?

 

Thanks in advance

Re: [.NET C#] Get prototype name

Legend
Legend

Hi,

 

you can get the path with

string systemroot = Tecnomatix.Engineering.TxApplication.SystemRootDirectory;

 

and the studyname with

string studyname = TxApplication.ActiveDocument.CurrentStudy.Name;

 

some other strings

string platform = TxApplication.PlatformType.ToString();
string physicalroot = TxApplication.ActiveDocument.PhysicalRoot.Name;
string logicalroot = TxApplication.ActiveDocument.LogicalRoot.Name;

Re: [.NET C#] Get prototype name

Creator
Creator

Thank you for your answer,

 

but that is not what i am looking for.

TxApplication.ActiveDocument.CurrentStudy.Name (or .caption) is only the internal name shown in PS, but not the name of the study.psz file.

 

Tecnomatix.Engineering.TxApplication.SystemRootDirectory is just the system root, where you put the components and has nothing to do with the study file itself.

 

I see it is just another thing, only possible in Online Mode and not in Disconnected !

 

OK the name of the study i can get with Getwindowtext (Win api function call), but for the path to the file i have to search and that is not what i want, because some of our collegues are in huge networks and that would cause a lot of traffic !

 

I don't understand, why my simple tasks are such a problem, because PS should give me that information also in offline mode !

Everything i need is in the psz file ! (and now i just need the path to that)

 

Just when i look the documentation and find something, i get only a access violation or SoD and have to look another way !

 

So i keep on searching ...

 

Wish you all merry christmas !!!!

 

Enjoy your time with family