/// <summary> /// Group the component to a logical group /// </summary> /// <param name="component">The current component</param> private void GroupComponent(TxComponent component) { if (SelectedGrouping == RwLogicalGroupCreationModes.VARIANTNAME) { GroupComponentByVariantName(component); } else if (SelectedGrouping == RwLogicalGroupCreationModes.PROTOTYPENAME) { GroupComponentByPartName(component); } }
/// <summary> /// Add a part to the dictionary /// </summary> /// <param name="key">The variant name of the part</param> /// <param name="component">The part as a component</param> private void AddToDictionary(string key, TxComponent component) { if (!logicalGroups.ContainsKey(key)) { logicalGroups.Add(key, new TxObjectList { component }); } else { logicalGroups[key].Add(component); } }
/// <summary> /// Group the components by the filename of the prototype /// </summary> /// <param name="component">The current component</param> private void GroupComponentByPartName(TxComponent component) { TxStorage storage = component.StorageObject as TxStorage; if (storage is TxLibraryStorage && component.Visibility != TxDisplayableObjectVisibility.CannotBeDisplayed && rules != null && rules.Length > 0) { string filename = RwFileAndDirectoryUtilities.GetFilenameWithoutExtension((storage as TxLibraryStorage).FullPath).ToUpper(); foreach (string rule in rules) { if (filename.Contains(rule)) { AddToDictionary(rule, component); return; } } AddToDictionary("EMPTY", component); } }
/// <summary> /// Group the components by the variant name column of the resource tree /// </summary> /// <param name="component">The current component</param> private void GroupComponentByVariantName(TxComponent component) { /* * Thanks to Siemens API Team for support * https://community.plm.automation.siemens.com/t5/Tecnomatix-Developer-Forum/Variant-name/m-p/550867#M1499 */ ITxPlanningObject planningObject = component.PlanningRepresentation; if (planningObject is ITxPlanningVariantSetAssignable variantSetAssignable && component.Visibility != TxDisplayableObjectVisibility.CannotBeDisplayed) { ITxPlanningVariantSet variantSet = variantSetAssignable.GetVariantSet(); if (variantSet != null) { AddToDictionary(variantSet.Name, component); } else { AddToDictionary("EMPTY", component); } } }
protected void OnDependencyDestroy(TxComponent _component) { }
protected void OnDependencyCreate(TxComponent _component) { CreateIfReady(); }
protected void AddDependency(TxComponent _component) { m_dependencies.Add(_component); _component.onAfterCreate += OnDependencyCreate; _component.onBeforeDestroy += OnDependencyDestroy; }
public TxPlcLogicBehavior CreatNewLB(string name) { TxTypeFilter objF1 = new TxTypeFilter(typeof(TxCompoundResource)); TxObjectList objs = TxApplication.ActiveDocument.PhysicalRoot.GetAllDescendants(objF1); TxObjectList objs1 = new TxObjectList(); bool b = false; foreach (TxCompoundResource c in objs) { if (c.Name == "LB_Main") { b = true; objs1.Add(c); TxTypeFilter objF2 = new TxTypeFilter(typeof(TxComponent)); foreach (ITxObject obj in c.GetAllDescendants(objF2)) { if (obj.Name == "LB_" + name) { obj.Delete(); } } break; } } if (!b) { objs1.Add(TxApplication.ActiveDocument.PhysicalRoot.CreateCompoundResource(new TxCompoundResourceCreationData("LB_Main"))); } TxApplication.ActiveSelection.Clear(); TxApplication.ActiveSelection.AddItems(objs1); ITxObject m_logicResource; TxPlcLogicBehavior txPlcLogicBehavior; TxNewPartResourceParametersEx txNewPartResourceParametersEx = new TxNewPartResourceParametersEx(); txNewPartResourceParametersEx.Type = "PmToolPrototype"; txNewPartResourceParametersEx.TypeNiceName = "LB_" + name; TxApplication.CommandsManager.ExecuteCommand("ComponentOperations.NewResource", txNewPartResourceParametersEx); m_logicResource = txNewPartResourceParametersEx.CreatedObject; TxComponentEx.ConnectComponentToDatabase(m_logicResource); TxLogicResourceEx.ConnectLogicResource(m_logicResource); TxPlcLogicBehaviorCreationData creationData2 = new TxPlcLogicBehaviorCreationData(); TxComponent txComponent = m_logicResource as TxComponent; txPlcLogicBehavior = txComponent.CreateLogicBehavior(creationData2); TxLinearUnitEnumEx linearUnits = TxLinearUnitEnumEx.Milimeter; TxAngularUnitEnumEx angularUnits = TxAngularUnitEnumEx.Radian; TxUnitsOptions.TxLinearUnit linearUnit = TxApplication.Options.Units.LinearUnit; TxUnitsOptions.TxAngularUnit angularUnit = TxApplication.Options.Units.AngularUnit; switch (linearUnit) { case TxUnitsOptions.TxLinearUnit.Millimeter: linearUnits = TxLinearUnitEnumEx.Milimeter; break; case TxUnitsOptions.TxLinearUnit.Centimeter: linearUnits = TxLinearUnitEnumEx.Centimeter; break; case TxUnitsOptions.TxLinearUnit.Meter: linearUnits = TxLinearUnitEnumEx.Meter; break; case TxUnitsOptions.TxLinearUnit.Inch: linearUnits = TxLinearUnitEnumEx.Inch; break; case TxUnitsOptions.TxLinearUnit.Foot: linearUnits = TxLinearUnitEnumEx.Foot; break; } switch (angularUnit) { case TxUnitsOptions.TxAngularUnit.Degree: angularUnits = TxAngularUnitEnumEx.Degree; break; case TxUnitsOptions.TxAngularUnit.Radian: angularUnits = TxAngularUnitEnumEx.Radian; break; } TxLogicBehaviorEx.SetLogicBehaviorUnits(txPlcLogicBehavior, linearUnits, angularUnits); return(txPlcLogicBehavior); }