/// <summary> /// Get the name of the picked object /// </summary> /// <param name="obj">The picked object</param> /// <returns>The name of the picked object</returns> public string GetText(ITxObject obj) { string name = string.Empty; try { if (obj != null) { name = obj.Name; } } catch (TxPlanningObjectNotLoadedException) { if (obj is ITxPlanningObject planningObject) { if (planningObject.PlanningType.Equals(planningType) && planningObject.HasFields) { name = planningObject.GetField("name").ToString(); } } } catch (TxPlanningObjectFieldNotLoadedException) { name = "Error"; } return(name); }
public override void OnInitTxForm() { base.OnInitTxForm(); TxObjectList selectedObjects = TxApplication.ActiveSelection.GetItems(); if (selectedObjects.Count > 0) { ITxObject firstObject = selectedObjects[0]; if (firstObject is TxRobot) { m_robotPicker.Object = firstObject; UpdateUI(); } } m_robotPicker.Focus(); }
/// <summary> /// Check the picked object if it is of valid type /// </summary> /// <param name="obj">The picked object</param> /// <param name="errorMessage">An errormessage</param> /// <returns>True if the picked object is valid otherwise false</returns> public bool IsValidObject(ITxObject obj, out string errorMessage) { bool isValid = false; errorMessage = null; if (obj != null) { if (obj is ITxPlanningObject planningObject) { if (planningObject.PlanningType.Equals(planningType)) { isValid = true; } else { errorMessage = errorMessageInvalid; } } } return(isValid); }