Пример #1
0
        public override bool Execute(ExecutionInfo exInfo = null)
        {
            Result = false;
            if (FilePath.IsValid && Write)
            {
                if (Options == null)
                {
                    Options = new RobotConversionOptions(true);
                }

                Document.Model.GenerateNodes(new NodeGenerationParameters());
                var robot = new RobotController();
                robot.Message += HandleMessage;
                RobotIDMappingTable idMap = null;
                if (Document.IDMappings.ContainsKey(FilePath))
                {
                    idMap = Document.IDMappings[FilePath] as RobotIDMappingTable;
                }
                if (idMap == null)
                {
                    idMap = Document.IDMappings.GetLatest(".rtd") as RobotIDMappingTable;
                }
                if (idMap == null)
                {
                    idMap = new RobotIDMappingTable();
                    Document.IDMappings.Add(FilePath, idMap);
                }
                robot.UpdateRobotFromModel(FilePath, Model, ref idMap, Options);
                //robot.WriteModelToRobot(FilePath, Document.Model, ref idMap);
                robot.Close();
                robot.Release();
                Result = true;
            }
            return(true);
        }
Пример #2
0
        /// <summary>
        /// Read a robot file and write a copy to a new location
        /// </summary>
        /// <param name="readPath"></param>
        /// <param name="writePath"></param>
        public static void ReadWriteTest(FilePath readPath, FilePath writePath)
        {
            var robot = new RobotController();
            RobotIDMappingTable idMap = new RobotIDMappingTable();

            Model.Model model = robot.LoadModelFromRobot(readPath, ref idMap);
            robot.Close();
            robot.Release();
            robot = new RobotController();
            robot.WriteModelToRobot(writePath, model, ref idMap);
        }
Пример #3
0
        public override bool Execute(ExecutionInfo exInfo = null)
        {
            var robot = new RobotController();

            robot.Message += HandleMessage;
            RobotIDMappingTable idMap = new RobotIDMappingTable();
            Model model = robot.LoadModelFromRobot(FilePath, ref idMap);

            Document = new ModelDocument(FilePath, model);
            robot.Close();
            robot.Release();
            Document.IDMappings[FilePath] = idMap;
            return(true);
        }
Пример #4
0
        private void WriteModel(RobotController robot, AlertLog log)
        {
            log?.RaiseAlert("Writing Salamander model to Robot...");
            RobotIDMappingTable idMap = new RobotIDMappingTable();
            bool result = robot.WriteModelToRobot(FilePath, Document.Model, ref idMap, null, log);

            if (result)
            {
                robot.Close();
                log?.RaiseAlert("Robot file written successfully.");
            }
            else
            {
                log?.RaiseAlert("Writing Robot file failed!", Nucleus.Alerts.AlertLevel.Error);
            }
            robot.Release(result);
            idMap.LinkToFile(FilePath);
            Document.IDMappings[FilePath] = idMap;
            idMap.SaveAsCSV(FilePath.AddNameSuffix("_Mapping", ".csv"));
            Result = result;
        }