//protected override void OnUpdate(Command command) //{ /* * if (first) * { * directory = Directory.GetCurrentDirectory(); * first = false; * } */ //Window window = Window.ActiveWindow; //command.IsEnabled = window != null && SelectionAllBodies(window); //} protected override void OnExecute(Command command, ExecutionContext context, Rectangle buttonRect) { if (File.Exists(directory)) { // Instance common functions class InstanceClasses.CommonSpaceClaimFunctions FunctionsClass = new InstanceClasses.CommonSpaceClaimFunctions(); // Variables Window window = Window.ActiveWindow; Document doc = window.Document; Part rootPart = doc.MainPart; // Dialogue variables string filePath; double depth; // Get save location & tree depth via user input using (var dialogue = new UI.VolumeAssessorForm()) { if (dialogue.ShowDialog() != DialogResult.OK) { return; } var nameAndRendering = new List <KeyValuePair <string, Graphic> >(); var partToGraphic = new Dictionary <Part, Graphic>(); var style = new GraphicStyle { EnableDepthBuffer = true }; filePath = dialogue.FileName; depth = dialogue.Depth; } if (window == null) { return; } // To pass args to python script var scriptParams = new Dictionary <string, object>(); scriptParams.Add("d", depth); scriptParams.Add("filepath", filePath); // Run the script w/ args SpaceClaim.Api.V18.Application.RunScript(directory, scriptParams); // show txt output Process.Start(filePath); } else { MessageBox.Show("ERROR: Script not found."); } }
//protected override void OnUpdate(Command command) //{ /* * if (first) * { * directory = Directory.GetCurrentDirectory(); * first = false; * } */ //Window window = Window.ActiveWindow; //command.IsEnabled = window != null && SelectionAllBodies(window); //} protected override void OnExecute(Command command, ExecutionContext context, Rectangle buttonRect) { if (File.Exists(directory)) { // Instance common functions class InstanceClasses.CommonSpaceClaimFunctions FunctionsClass = new InstanceClasses.CommonSpaceClaimFunctions(); // Variables Window window = Window.ActiveWindow; Document doc = window.Document; Part rootPart = doc.MainPart; // Dialogue variables int iterations; int maxfaces; // Get iterations & max faces via user input using (var dialogue = new UI.VoidGeneratorForm()) { if (dialogue.ShowDialog() != DialogResult.OK) { return; } var nameAndRendering = new List <KeyValuePair <string, Graphic> >(); var partToGraphic = new Dictionary <Part, Graphic>(); var style = new GraphicStyle { EnableDepthBuffer = true }; iterations = dialogue.Iterations; maxfaces = dialogue.MaxFaces; } if (window == null) { return; } // To pass args to python script var scriptParams = new Dictionary <string, object>(); scriptParams.Add("iter", iterations); scriptParams.Add("mf", maxfaces); // Run the script SpaceClaim.Api.V18.Application.RunScript(directory, scriptParams); MessageBox.Show("Script called successfully"); } else { MessageBox.Show("ERROR: Script not found."); } }
//protected override void OnUpdate(Command command) //{ /* * if (first) * { * directory = Directory.GetCurrentDirectory(); * first = false; * } */ //Window window = Window.ActiveWindow; //command.IsEnabled = window != null && SelectionAllBodies(window); //} protected override void OnExecute(Command command, ExecutionContext context, Rectangle buttonRect) { if (File.Exists(directory)) { // Instance common functions class InstanceClasses.CommonSpaceClaimFunctions FunctionsClass = new InstanceClasses.CommonSpaceClaimFunctions(); // Variables Window window = Window.ActiveWindow; Document doc = window.Document; Part rootPart = doc.MainPart; // Dialogue variables bool planes; bool cut; // Get whether to include planes and cuts via user input using (var dialogue = new UI.MeshTallyCheckerForm()) { if (dialogue.ShowDialog() != DialogResult.OK) { return; } var nameAndRendering = new List <KeyValuePair <string, Graphic> >(); var partToGraphic = new Dictionary <Part, Graphic>(); var style = new GraphicStyle { EnableDepthBuffer = true }; planes = dialogue.Plane; cut = dialogue.Cut; } if (window == null) { return; } // To pass args to python script var scriptParams = new Dictionary <string, object>(); scriptParams.Add("planes", planes); scriptParams.Add("cut", cut); // Run the script SpaceClaim.Api.V18.Application.RunScript(directory, scriptParams); } else { MessageBox.Show("ERROR: Script not found."); } }
//protected override void OnUpdate(Command command) //{ /* * if (first) * { * directory = Directory.GetCurrentDirectory(); * first = false; * } */ //Window window = Window.ActiveWindow; //command.IsEnabled = window != null && SelectionAllBodies(window); //} protected override void OnExecute(Command command, ExecutionContext context, Rectangle buttonRect) { if (File.Exists(directory)) { // Instance common functions class InstanceClasses.CommonSpaceClaimFunctions FunctionsClass = new InstanceClasses.CommonSpaceClaimFunctions(); // Variables Window window = Window.ActiveWindow; Document doc = window.Document; Part rootPart = doc.MainPart; // Run the script SpaceClaim.Api.V18.Application.RunScript(directory); } else { MessageBox.Show("ERROR: Script not found."); } }
//protected override void OnUpdate(Command command) //{ /* * if (first) * { * directory = Directory.GetCurrentDirectory(); * first = false; * } */ //Window window = Window.ActiveWindow; //command.IsEnabled = window != null && SelectionAllBodies(window); //} protected override void OnExecute(Command command, ExecutionContext context, Rectangle buttonRect) { if (File.Exists(directory)) { // Instance common functions class InstanceClasses.CommonSpaceClaimFunctions FunctionsClass = new InstanceClasses.CommonSpaceClaimFunctions(); // Variables Window window = Window.ActiveWindow; Document doc = window.Document; Part rootPart = doc.MainPart; // Dialogue variables string filename; Color coneclr; Color nurbsclr; Color onaclr; Color offaclr; Color procclr; // Get save location via user input //using (var dialogue = new SaveFileDialog()) //{ // dialogue.FileName = "GeometryReport.txt"; // dialogue.DefaultExt = "txt"; // dialogue.Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*"; // dialogue.FilterIndex = 2; // dialogue.OverwritePrompt = true; // // if (dialogue.ShowDialog() != DialogResult.OK) // return; // // var nameAndRendering = new List<KeyValuePair<string, Graphic>>(); // var partToGraphic = new Dictionary<Part, Graphic>(); // // var style = new GraphicStyle // { // EnableDepthBuffer = true // }; // // filePath = dialogue.FileName; //} //if (window == null) // return; using (var form = new UI.GeometryAssessorForm()) { if (form.ShowDialog() != DialogResult.OK) { return; } var nameAndRendering = new List <KeyValuePair <string, Graphic> >(); var partToGraphic = new Dictionary <Part, Graphic>(); var style = new GraphicStyle { EnableDepthBuffer = true }; filename = form.FileName; coneclr = form.color1; nurbsclr = form.color2; onaclr = form.color3; offaclr = form.color4; procclr = form.color5; } if (window == null) { return; } // To pass args to python script var scriptParams = new Dictionary <string, object>(); scriptParams.Add("filepath", filename); scriptParams.Add("conea", Convert.ToInt32(coneclr.A)); scriptParams.Add("coner", Convert.ToInt32(coneclr.R)); scriptParams.Add("coneg", Convert.ToInt32(coneclr.G)); scriptParams.Add("coneb", Convert.ToInt32(coneclr.B)); scriptParams.Add("nurba", Convert.ToInt32(nurbsclr.A)); scriptParams.Add("nurbr", Convert.ToInt32(nurbsclr.R)); scriptParams.Add("nurbg", Convert.ToInt32(nurbsclr.G)); scriptParams.Add("nurbb", Convert.ToInt32(nurbsclr.B)); scriptParams.Add("onaa", Convert.ToInt32(onaclr.A)); scriptParams.Add("onar", Convert.ToInt32(onaclr.R)); scriptParams.Add("onag", Convert.ToInt32(onaclr.G)); scriptParams.Add("onab", Convert.ToInt32(onaclr.B)); scriptParams.Add("offaa", Convert.ToInt32(offaclr.A)); scriptParams.Add("offar", Convert.ToInt32(offaclr.R)); scriptParams.Add("offag", Convert.ToInt32(offaclr.G)); scriptParams.Add("offab", Convert.ToInt32(offaclr.B)); scriptParams.Add("proca", Convert.ToInt32(procclr.A)); scriptParams.Add("procr", Convert.ToInt32(procclr.R)); scriptParams.Add("procg", Convert.ToInt32(procclr.G)); scriptParams.Add("procb", Convert.ToInt32(procclr.B)); // Run the script w/ args SpaceClaim.Api.V18.Application.RunScript(directory, scriptParams); // Show txt output Process.Start(filename); } else { MessageBox.Show("ERROR: Script not found."); } }
protected override void OnExecute(Command command, ExecutionContext context, Rectangle buttonRect) { /* * Provide dialogue box and user inputs what they want to locate * These selections are Tori, Small Holes or Small Volumes * For Small Volumes and Holes the user will need to input a value * Each will be handled seperately and find matching bodies in all part design bodies * All will be then added to a final selection list for the user */ // Instance common functions class InstanceClasses.CommonSpaceClaimFunctions FunctionsClass = new InstanceClasses.CommonSpaceClaimFunctions(); // Variables Window window = Window.ActiveWindow; window.SetTool(new ToolClass()); Document doc = window.Document; Part rootPart = doc.MainPart; InteractionContext interContext = window.ActiveContext; List <IDesignBody> selectionBodies = new List <IDesignBody>(); List <IDesignBody> matchingBodies = new List <IDesignBody>(); List <Face> facesList = new List <Face>(); List <IDesignFace> iFacesList = new List <IDesignFace>(); List <IDesignFace> ifinalFacesList = new List <IDesignFace>(); ICollection <IDesignFace> IcollectionFaces = null; double minradius; double minVolume; double minFace; bool findCone = false; bool findTori = false; bool findHoles = false; bool findVolume = false; bool findFace = false; #pragma warning disable CS0219 // The variable 'faceCounter' is assigned but its value is never used int faceCounter = 0; #pragma warning restore CS0219 // The variable 'faceCounter' is assigned but its value is never used #pragma warning disable CS0219 // The variable 'intMode' is assigned but its value is never used InteractionMode intMode = InteractionMode.Solid; #pragma warning restore CS0219 // The variable 'intMode' is assigned but its value is never used if (window == null) { return; } #region Dialogue // Create dialogue box using (var dialogue = new UI.BodySelectForm()) { if (dialogue.ShowDialog() != DialogResult.OK) { return; } var nameAndRendering = new List <KeyValuePair <string, Graphic> >(); var partToGraphic = new Dictionary <Part, Graphic>(); var style = new GraphicStyle { EnableDepthBuffer = true }; findCone = dialogue.LocateCone; findTori = dialogue.LocateTori; findHoles = dialogue.LocateHoles; findVolume = dialogue.LocateVolume; findFace = dialogue.LocateFace; minradius = dialogue.minRadius; minVolume = dialogue.minVolume; minFace = dialogue.minFace; } #endregion // Gather all design bodies //----------------------------------------------- selectionBodies.AddRange(FunctionsClass.GatherAllVisibleBodies(rootPart, window)); // Check if each body fits wanted criteria //----------------------------------------------- foreach (IDesignBody iDesBod in selectionBodies) { DesignBody master = iDesBod.Master; Body body = master.Shape; var faces = body.Faces; facesList.AddRange(faces); var iFaces = iDesBod.Faces; iFacesList.AddRange(iFaces); Matrix masterTrans = iDesBod.TransformToMaster; Matrix reverseTrans = masterTrans.Inverse; // If body fits volume criteria //---------------------------------------- if (findVolume && body.Volume * 1e6 < minVolume) { matchingBodies.Add(iDesBod); } else { // If body fits tori or hole criteria //---------------------------------------- for (int i = 0; i < iFacesList.Count; i++) { IDesignFace face = iFacesList[i]; if (face.Area * 1e4 < minFace) { ifinalFacesList.Clear(); ifinalFacesList.Add(face); window.ActiveTool.CreateIndicator(ifinalFacesList); } if (face.Shape.GetGeometry <Cone>() != null && findCone) { ifinalFacesList.Clear(); ifinalFacesList.Add(face); window.ActiveTool.CreateIndicator(ifinalFacesList); } if (face.Shape.GetGeometry <Torus>() != null && findTori) { ifinalFacesList.Clear(); ifinalFacesList.Add(face); window.ActiveTool.CreateIndicator(ifinalFacesList); } else if (face.Shape.GetGeometry <Cylinder>() != null && face.Shape.GetGeometry <Cylinder>().Radius * 1e2 < minradius && findHoles) { //FunctionsClass.ColourFace(facesList[i], master); ifinalFacesList.Clear(); ifinalFacesList.Add(face); window.ActiveTool.CreateIndicator(ifinalFacesList); var radius = face.Shape.GetGeometry <Cylinder>().Radius; /* * if (IsHole(face, radius)) * { * ifinalFacesList.Clear(); * ifinalFacesList.Add(face); * window.ActiveTool.CreateIndicator(ifinalFacesList); * } */ } else { // Set all the other face to slightly translucent //FunctionsClass.SetFacetranslucent(face, master); } } } facesList.Clear(); iFacesList.Clear(); } //ICollection<IDocObject> bodyCollection = null; // For each matching body change the colour to red //---------------------------------------------------- foreach (IDesignBody finalBody in matchingBodies) { //bodyCollection.Add(finalBody); DesignBody finalMaster = finalBody.Master; finalMaster.SetColor(null, Color.Red); } var point = Point.Create(1, 1, 1); IcollectionFaces = ifinalFacesList; // Also set them as selected by the user //---------------------------------------------------- //interContext.Selection = bodyCollection; }
//protected override void OnUpdate(Command command) //{ /* * if (first) * { * directory = Directory.GetCurrentDirectory(); * first = false; * } */ //Window window = Window.ActiveWindow; //command.IsEnabled = window != null && SelectionAllBodies(window); //} protected override void OnExecute(Command command, ExecutionContext context, Rectangle buttonRect) { if (File.Exists(directory)) { // Instance common functions class InstanceClasses.CommonSpaceClaimFunctions FunctionsClass = new InstanceClasses.CommonSpaceClaimFunctions(); // Variables Window window = Window.ActiveWindow; Document doc = window.Document; Part rootPart = doc.MainPart; int meshes = 0; foreach (IPart part in WalkParts(rootPart)) { Part partMaster = part.Master; if (GetPartName(partMaster).Equals("MESH")) { meshes = part.Bodies.Count; } } // Dialogue variables string filePath; // mesh tally save location user input using (var dialogue = new SaveFileDialog()) { dialogue.FileName = "meshcard.txt"; dialogue.DefaultExt = "txt"; dialogue.Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*"; dialogue.FilterIndex = 2; dialogue.OverwritePrompt = true; if (dialogue.ShowDialog() != DialogResult.OK) { return; } var nameAndRendering = new List <KeyValuePair <string, Graphic> >(); var partToGraphic = new Dictionary <Part, Graphic>(); var style = new GraphicStyle { EnableDepthBuffer = true }; filePath = dialogue.FileName; } var scriptParams = new Dictionary <string, object>(); string particleType = "n"; int tallyNum = 14; double xRes = 1.0; double yRes = 1.0; double zRes = 1.0; int i = 0; // get mesh properties via user input while (i < meshes) { using (var dialogue = new UI.MeshTallyWriterForm2()) { if (dialogue.ShowDialog() != DialogResult.OK) { return; } var nameAndRendering = new List <KeyValuePair <string, Graphic> >(); var partToGraphic = new Dictionary <Part, Graphic>(); var style = new GraphicStyle { EnableDepthBuffer = true }; particleType = dialogue.ParticleSelection; tallyNum = dialogue.TallyNumber; xRes = dialogue.XResolution; yRes = dialogue.YResolution; zRes = dialogue.ZResolution; scriptParams.Add("tallynum" + i.ToString(), tallyNum); scriptParams.Add("particle" + i.ToString(), particleType); scriptParams.Add("xres" + i.ToString(), xRes); scriptParams.Add("yres" + i.ToString(), yRes); scriptParams.Add("zres" + i.ToString(), zRes); i++; } } if (window == null) { return; } scriptParams.Add("filepath", filePath); scriptParams.Add("meshquant", meshes); // Run the script w/ args SpaceClaim.Api.V18.Application.RunScript(directory, scriptParams); } else { MessageBox.Show("ERROR: Script not found."); } }
protected override void OnExecute(Command command, ExecutionContext context, Rectangle buttonRect) { /* * Max Surface Tool * A. Burns 06/11/2017 * Read user inuput max surfaces per body * Hightlight body with greater number of faces * Optionally can chnage the bodies colour * as well as highlighting */ // Instance common functions class InstanceClasses.CommonSpaceClaimFunctions FunctionsClass = new InstanceClasses.CommonSpaceClaimFunctions(); // Essential Variables Window window = Window.ActiveWindow; Document doc = window.Document; Part rootPart = doc.MainPart; InteractionContext interContext = window.ActiveContext; // Other Variables List <IDesignBody> allBodies = new List <IDesignBody>(); List <IDesignFace> ifinalFacesList = new List <IDesignFace>(); window.SetTool(new ToolClass()); int faceCount; int maxFaces; bool changeColours; string colourString; using (var dialogue = new UI.MaxSurfacesForm()) { if (dialogue.ShowDialog() != DialogResult.OK) { return; } var nameAndRendering = new List <KeyValuePair <string, Graphic> >(); var partToGraphic = new Dictionary <Part, Graphic>(); var style = new GraphicStyle { EnableDepthBuffer = true }; maxFaces = (int)dialogue.MaxSurfaces; changeColours = dialogue.ChangeColour; colourString = dialogue.ColourSelection; } if (window == null) { return; } allBodies.AddRange(FunctionsClass.GatherAllVisibleBodies(rootPart, window)); foreach (IDesignBody iDesBody in allBodies) { DesignBody desBody = iDesBody.Master; Body body = desBody.Shape.Copy(); var faces = body.Faces; var iFaces = iDesBody.Faces; // ifinalFacesList.AddRange(iDesBody.Faces); faceCount = faces.Count; if (faceCount > maxFaces) { window.ActiveTool.CreateIndicator(iFaces); if (changeColours) { if (colourString == "Blue") { desBody.SetColor(null, Color.Blue); } else if (colourString == "Red") { desBody.SetColor(null, Color.Red); } else if (colourString == "Green") { desBody.SetColor(null, Color.Green); } else if (colourString == "Orange") { desBody.SetColor(null, Color.Orange); } else if (colourString == "Black") { desBody.SetColor(null, Color.Black); } else if (colourString == "Yellow") { desBody.SetColor(null, Color.Yellow); } else if (colourString == "Salmon Pink") { desBody.SetColor(null, Color.Salmon); } } } } }
protected override void OnExecute(Command command, ExecutionContext context, Rectangle buttonRect) { /* * Lost Particle Location Highlighter * Prompt user to select the MCNP output file which contains lost particle locations * Read in file and store locations * Highlight the point/plane which the particle loss occurs */ // Instance common functions class InstanceClasses.CommonSpaceClaimFunctions FunctionsClass = new InstanceClasses.CommonSpaceClaimFunctions(); // Variables Window window = Window.ActiveWindow; window.SetTool(new ToolClass()); Document doc = window.Document; Part rootPart = doc.MainPart; Part lostPart = Part.Create(doc, "Lost Particles"); Part vectorPart = Part.Create(doc, "Vector Lines"); Part curvePart = Part.Create(doc, "Lost Particle Curves"); Component lp2c = Component.Create(rootPart, curvePart); string filepath; bool showVectors; bool fileLocated = false; bool maxParticlesBool; double maxParicles; int particleCounter = 0; int particleLineCounter = 0; bool stopParticles = false; bool stopLines = false; string[] lines = null; string lostParticleIndicator = "x,y,z coordinates:"; string vectorIndicator = "u,v,w direction cosines:"; char[] delimeterChars = { ' ', '\t' }; char[] secondDelimChars = { '+', '-' }; int pointCounter = 1; int lineCounter = 1; string pointName; string vectorName; string chosenColour; Point currentPoint = Point.Create(0, 0, 0); Point vectorPoint = Point.Create(0, 0, 0); List <double> xValues = new List <double>(); List <double> yValues = new List <double>(); List <double> zValues = new List <double>(); List <Point> vectorPointList = new List <Point>(); List <Point> pointList = new List <Point>(); List <Line> lineList = new List <Line>(); // Bring up windows form using (var dialogue = new UI.LostParticlesForm()) { if (dialogue.ShowDialog() != DialogResult.OK) { return; } var nameAndRendering = new List <KeyValuePair <string, Graphic> >(); var partToGraphic = new Dictionary <Part, Graphic>(); var style = new GraphicStyle { EnableDepthBuffer = true }; filepath = dialogue.FileName; showVectors = dialogue.ShowVectors; maxParticlesBool = dialogue.MaxParticleBool; maxParicles = dialogue.MaxParticle; chosenColour = dialogue.ColourSelection; } if (window == null) { return; } //Debug.WriteLine(filepath); try { lines = File.ReadAllLines(filepath); fileLocated = true; } catch { MessageBox.Show("File Could Not Be Located"); //SpaceClaim.Api.V18.Application.Exit(); } // Get x,y,z coordinates of lost particle points //------------------------------------------------------------- if (fileLocated) { // Check if MCNP output or text file if (lines[0].Contains("Code Name & Version") || lines[0].Contains(lostParticleIndicator) || lines[0].Contains(vectorIndicator)) { //Debug.WriteLine("MCNP File"); // MCNP File foreach (string line in lines) { if (line.Contains(lostParticleIndicator)) { //Debug.WriteLine(line); if (!stopParticles) { string[] tempWords = line.Split(delimeterChars, StringSplitOptions.RemoveEmptyEntries); // Convert API values in metres to cm for SpaceClaim currentPoint = Point.Create(Convert.ToDouble(tempWords[2]) / 100, Convert.ToDouble(tempWords[3]) / 100, Convert.ToDouble(tempWords[4]) / 100); pointList.Add(currentPoint); particleCounter++; if (particleCounter >= maxParicles && maxParticlesBool) { stopParticles = true; } } } else if (line.Contains(vectorIndicator)) { string[] tempWords = line.Split(delimeterChars, StringSplitOptions.RemoveEmptyEntries); //Debug.WriteLine(tempWords[3] + " " + tempWords[4] + " " + tempWords[5]); Point origin = Point.Create(0, 0, 0); Direction direction = Direction.Create(Convert.ToDouble(tempWords[3]), Convert.ToDouble(tempWords[4]), Convert.ToDouble(tempWords[5])); vectorPoint = Point.Create(currentPoint.X + Convert.ToDouble(tempWords[3]) / 1, currentPoint.Y + Convert.ToDouble(tempWords[4]) / 1, currentPoint.Z + Convert.ToDouble(tempWords[5]) / 1); if (showVectors && !stopLines) { vectorName = "Lost Particle " + lineCounter.ToString() + " Vector"; LineSegment lineSeg = new LineSegment(currentPoint, vectorPoint); ITrimmedCurve shape = CurveSegment.Create(lineSeg); DesignCurve desCurve = DesignCurve.Create(vectorPart, shape); desCurve.Name = vectorName; desCurve.SetColor(null, Color.Blue); lineCounter++; particleLineCounter++; if (particleLineCounter >= maxParicles && maxParticlesBool) { stopLines = true; } } //Line vectorLine = Line.CreateThroughPoints(currentPoint, origin); Line vectorLine = Line.CreateThroughPoints(currentPoint, vectorPoint); //Line vectorLine = Line.Create(currentPoint, direction); lineList.Add(vectorLine); } #region Old Code /* * else if (lostParticleBool) * { * * if (line.Contains(endLostParticleIndicator)) * { * //string patternOne = @"(\-|\d)\d*\.\d+"; * string patternOne = @"(?<=\d)(\+|\-)"; * string[] tempWords = prevLine.Split(delimeterChars, StringSplitOptions.RemoveEmptyEntries); * string[] xWords = Regex.Split(tempWords[2], patternOne); * string[] yWords = Regex.Split(tempWords[3], patternOne); * string[] zWords = Regex.Split(tempWords[4], patternOne); * //Debug.WriteLine(xWords[0]); * //Debug.WriteLine(yWords[0]); * * string xFinal = xWords[0] + "E" + xWords[1] + xWords[2]; * string yFinal = yWords[0] + "E" + yWords[1] + yWords[2]; * string zFinal = zWords[0] + "E" + zWords[1] + zWords[2]; * * Debug.WriteLine(xFinal); * Debug.WriteLine(yFinal); * Debug.WriteLine(zFinal); * * /* * foreach (string word in xWords) * { * Debug.WriteLine(word); * } * * Debug.WriteLine(" "); * * foreach (string word in yWords) * { * Debug.WriteLine(word); * } * * * xValues.Add(Convert.ToDouble(xFinal)); * yValues.Add(Convert.ToDouble(yFinal)); * zValues.Add(Convert.ToDouble(zFinal)); * * } * * //prevLine = line; * } */ #endregion } //Debug.WriteLine(pointList.Count); // Use values and highlight the positions in SpaceClaim //--------------------------------------------------------------- foreach (Point point in pointList) { pointName = "Lost Particle " + pointCounter.ToString(); window.ActiveTool.CreateIndicator(point); //DatumPoint.Create(lostPart, pointName, point); var pc = PointCurve.Create(point); ITrimmedCurve shapey = CurveSegment.Create(pc); DesignCurve dcurve = DesignCurve.Create(curvePart, shapey); if (chosenColour == "Blue") { dcurve.SetColor(null, Color.Blue); } else if (chosenColour == "Red") { dcurve.SetColor(null, Color.Red); } else if (chosenColour == "Green") { dcurve.SetColor(null, Color.Green); } else if (chosenColour == "Orange") { dcurve.SetColor(null, Color.Orange); } else if (chosenColour == "Black") { dcurve.SetColor(null, Color.Black); } else if (chosenColour == "Yellow") { dcurve.SetColor(null, Color.Yellow); } else if (chosenColour == "Salmon Pink") { dcurve.SetColor(null, Color.Salmon); } pointCounter++; } if (showVectors) { /* * foreach (Line line in lineList) * { * vectorName = "Lost Particle " + lineCounter + " Vector"; * DatumLine dLine = DatumLine.Create(vectorPart, vectorName, line); * lineCounter++; * } */ Component vectorComponent = Component.Create(rootPart, vectorPart); } //Component lostParticleComponent = Component.Create(rootPart, lostPart); } else { // Text file /* * foreach (string line in lines) * { * Debug.Write(String.Format("{0}\n",line)); * } */ bool firstLine = true; int length = 0; foreach (string line in lines) { if (line.Length != 0) { string[] tempWords = line.Split(delimeterChars, StringSplitOptions.RemoveEmptyEntries); if (firstLine) { firstLine = false; length = tempWords.Length; } if (length > 3) { currentPoint = Point.Create(Convert.ToDouble(tempWords[0]) / 100, Convert.ToDouble(tempWords[1]) / 100, Convert.ToDouble(tempWords[2]) / 100); pointList.Add(currentPoint); particleCounter++; Point origin = Point.Create(0, 0, 0); Direction direction = Direction.Create(Convert.ToDouble(tempWords[3]), Convert.ToDouble(tempWords[4]), Convert.ToDouble(tempWords[5])); vectorPoint = Point.Create(currentPoint.X + Convert.ToDouble(tempWords[3]) / 1, currentPoint.Y + Convert.ToDouble(tempWords[4]) / 1, currentPoint.Z + Convert.ToDouble(tempWords[5]) / 1); if (showVectors) { vectorName = "Lost Particle " + lineCounter.ToString() + " Vector"; LineSegment lineSeg = new LineSegment(currentPoint, vectorPoint); ITrimmedCurve shape = CurveSegment.Create(lineSeg); DesignCurve desCurve = DesignCurve.Create(vectorPart, shape); desCurve.Name = vectorName; desCurve.SetColor(null, Color.Blue); lineCounter++; particleLineCounter++; } //Line vectorLine = Line.CreateThroughPoints(currentPoint, origin); Line vectorLine = Line.CreateThroughPoints(currentPoint, vectorPoint); //Line vectorLine = Line.Create(currentPoint, direction); lineList.Add(vectorLine); } else if (length <= 3) { try { currentPoint = Point.Create(Convert.ToDouble(tempWords[0]) / 100, Convert.ToDouble(tempWords[1]) / 100, Convert.ToDouble(tempWords[2]) / 100); pointList.Add(currentPoint); particleCounter++; } catch { } } } } foreach (Point point in pointList) { pointName = "Lost Particle " + pointCounter.ToString(); window.ActiveTool.CreateIndicator(point); //DatumPoint.Create(lostPart, pointName, point); var pc = PointCurve.Create(point); ITrimmedCurve shapey = CurveSegment.Create(pc); DesignCurve dcurve = DesignCurve.Create(curvePart, shapey); if (chosenColour == "Blue") { dcurve.SetColor(null, Color.Blue); } else if (chosenColour == "Red") { dcurve.SetColor(null, Color.Red); } else if (chosenColour == "Green") { dcurve.SetColor(null, Color.Green); } else if (chosenColour == "Orange") { dcurve.SetColor(null, Color.Orange); } else if (chosenColour == "Black") { dcurve.SetColor(null, Color.Black); } else if (chosenColour == "Yellow") { dcurve.SetColor(null, Color.Yellow); } else if (chosenColour == "Salmon Pink") { dcurve.SetColor(null, Color.Salmon); } pointCounter++; } if (showVectors) { Component vectorComponent = Component.Create(rootPart, vectorPart); } //Component lostParticleComponent = Component.Create(rootPart, lostPart); } } }