Tecnomatix PDPS 开发 显示所选物体类型
2020-03-27 本文已影响0人
锦囊喵
以下为相关代码,PDPS开发入门必备:
需要入门视频的小伙伴可以私信我!
public class testSelectionType:TxButtonCommand
{
private string messageFormat = ".Net API type={0}";
public testSelectionType() { }
public override string Category
{
get { throw new NotImplementedException(); }
}
public override void Execute(object cmdParams)
{
getTypeLarge();
}
private void getTypeLarge()
{
TxObjectList selectedObjects = TxApplication.ActiveSelection.GetItems();//[0] as ITxObject;
if (selectedObjects.Count > 0)
{
ITxObject selectedObject = selectedObjects[0];
TxMessageBox.Show(string.Format(messageFormat, selectedObject.GetType().ToString()), Name, MessageBoxButtons.OK, MessageBoxIcon.Information);
if (selectedObject is ITxGroup)
{
TxGroup group = selectedObject as TxGroup;
TxObjectList list = group.GetDirectDescendants(new TxNoTypeFilter());
foreach(ITxObject objectInList in list)
{
MessageBox.Show(objectInList.Name);
}
}
var externalId = "external-id-of-the-object";
var txObject = TxApplication.ActiveDocument.GetObjectByProcessModelId(new TxProcessModelId(externalId)) as Tecnomatix.Planning.ITxPlanningObject;
var prototypeObject = txObject.GetField("prototype") as Tecnomatix.Planning.ITxPlanningObject;
var planningType = prototypeObject.PlanningType;
//string planningType = planningObject.PlanningType;
TxMessageBox.Show(string.Format(messageFormat, planningType.ToString()), Name, MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
public override string Name
{
get { return StringTable1.Name_Type; }
}
}