internal static StapleSection readStapleConfig() { StapleSection sec = config.Sections["staplePath"] as StapleSection; if (sec == null) { sec = new StapleSection(); sec.staplePath.Path = "C:\\local\\autoLabel\\itsowl-tt-autolabel\\autoLabel-Sim-Models\\stl-files\\"; config.Sections.Add("staplePath", sec); config.Save(); } return(sec); }
private void stapleConfig(String stapleComponentName) { StapleSection parameterStaple = ConfigReader.readStapleConfig(); ISimComponent stapleComponent = app.Value.World.FindComponent(stapleComponentName); if (stapleComponentName != "" && stapleComponent == null) { ms.AppendMessage("Failed to find staple component with name\"" + stapleComponentName + "\"! Planning of motion aborted...", MessageLevel.Warning); return; } String stapleFileFolder = parameterStaple.staplePath.Path; if (stapleComponent.GetProperty("stlID") == null) { ms.AppendMessage("Component with name \"" + stapleComponentName + "\" has no property \"stlID\"! Planning of motion aborted...", MessageLevel.Warning); return; } String stlID = (String)stapleComponent.GetProperty("stlID").Value; String obstacleFilePath = stapleFileFolder + stlID + ".stl"; if (!File.Exists(obstacleFilePath)) { ms.AppendMessage("A path planning request requested stlID with \"" + stlID + "\" failed, because file \"" + obstacleFilePath + "\" does not exist...", MessageLevel.Warning); return; } ; if (stapleComponent.GetProperty("StackHeight") == null) { ms.AppendMessage("Failed to find StackHeight property in component with name \"" + stapleComponentName + "\"! Planning of motion aborted!", MessageLevel.Warning); return; } Vector3 staplePosition = stapleComponent.TransformationInWorld.GetP(); IDoubleProperty stackwidth = (IDoubleProperty)stapleComponent.GetProperty("StackWidth"); IDoubleProperty stacklength = (IDoubleProperty)stapleComponent.GetProperty("StackLength"); float translate_x = (float)staplePosition.X - (float)(stacklength.Value / 2.0); float translate_y = (float)staplePosition.Y - (float)(stackwidth.Value / 2.0); IDoubleProperty stackheight = (IDoubleProperty)stapleComponent.GetProperty("StackHeight"); float translate_z = (float)stackheight.Value; // setup staple obstacle int obstacleId = motionPlan.addObstacle(obstacleFilePath, translate_x / 1000.0f, translate_y / 1000.0f, translate_z / 1000.0f, 0.0f, 0.0f, 0.0f); }