// Ensures we have an active path to edit internal static void EnsurePath() { if (Station.ActiveStation.ActiveTask.ActivePathProcedure != null) { return; } string pathName = Station.ActiveStation.ActiveTask.GetValidRapidName("VrPath", "_", 1); var path = new RsPathProcedure(pathName); Station.ActiveStation.ActiveTask.PathProcedures.Add(path); Station.ActiveStation.ActiveTask.ActivePathProcedure = path; }
public static string CreatePath(string procedureName) { Project.UndoContext.BeginUndoStep("RsPathProcedure Create"); try { //Get the active Station Station station = Project.ActiveProject as Station; // Create a PathProcedure. RsPathProcedure myPath = new RsPathProcedure(procedureName); // Add the path to the ActiveTask. station.ActiveTask.PathProcedures.Add(myPath); myPath.ModuleName = "module1"; myPath.ShowName = true; myPath.Synchronize = true; myPath.Visible = true; //Make the path procedure as active path procedure station.ActiveTask.ActivePathProcedure = myPath; //Create Path foreach (RsTarget target in targets) { RsMoveInstruction moveInstruction = new RsMoveInstruction(station.ActiveTask, "Move", "Default", MotionType.Linear, target.WorkObject.Name, target.Name, station.ActiveTask.ActiveTool.Name); myPath.Instructions.Add(moveInstruction); } ArrayList messages = new ArrayList(); station.ActiveTask.SyncPathProcedure(myPath.ModuleName + "/" + myPath.Name, SyncDirection.ToController, messages); targets.Clear(); } catch (Exception ex) { Project.UndoContext.CancelUndoStep(CancelUndoStepType.Rollback); Logger.AddMessage(new LogMessage(ex.Message.ToString())); } finally { Project.UndoContext.EndUndoStep(); } return("Path " + procedureName + " created"); }
public void Finish() { WithUndo("VR Paint", () => { _path = _stn.ActiveTask.ActivePathProcedure; var transforms = ReduceTransforms(_transforms); foreach (var tf in transforms) { string instrName = _stn.ActiveTask.GetValidRapidName("VrTarget", "_", 1); CreateMoveInstruction(tf, instrName); } _stn.ActiveTask.ActivePathProcedure = _path; }); }
private static void CreatePath(RsToolData SelectedToolData, RsWorkObject SelectedWorkObject, string speed, string zone) { Project.UndoContext.BeginUndoStep("RsPathProcedure Create"); try { //Get the active Station Station station = Project.ActiveProject as Station; // Create a PathProcedure. RsPathProcedure myPath = new RsPathProcedure("AutoPath" + pathnumber); // Add the path to the ActiveTask. station.ActiveTask.PathProcedures.Add(myPath); myPath.ModuleName = "module1"; myPath.ShowName = true; myPath.Synchronize = true; myPath.Visible = true; //Make the path procedure as active path procedure station.ActiveTask.ActivePathProcedure = myPath; int i = 0; //Create Path foreach (RsTarget target in station.ActiveTask.Targets) { if (i == 0) { // new RsMoveInstruction(station.ActiveTask, "Move", "Default", //MotionType.Joint, station.ActiveTask.ActiveWorkObject.Name, target.Name, station.ActiveTask.ActiveTool.Name); RsMoveInstruction moveInstruction = new RsMoveInstruction(station.ActiveTask, "Move", "Default", MotionType.Joint, SelectedWorkObject.Name, target.Name, SelectedToolData.Name); moveInstruction.InstructionArguments["Speed"].Value = speed; moveInstruction.InstructionArguments["Zone"].Value = zone; myPath.Instructions.Add(moveInstruction); } else { RsMoveInstruction moveInstruction = new RsMoveInstruction(station.ActiveTask, "Move", "Default", MotionType.Linear, SelectedWorkObject.Name, target.Name, SelectedToolData.Name); moveInstruction.InstructionArguments["Speed"].Value = speed; moveInstruction.InstructionArguments["Zone"].Value = zone; myPath.Instructions.Add(moveInstruction); } i++; pathnumber++; } } catch (Exception ex) { Project.UndoContext.CancelUndoStep(CancelUndoStepType.Rollback); Logger.AddMessage(new LogMessage(ex.Message.ToString())); } finally { Project.UndoContext.EndUndoStep(); } }