protected override bool OnClickStart(ScreenPoint cursorPos, Line cursorRay) { IDocObject selection = null; IDocObject preselection = InteractionContext.Preselection; var desFace = preselection as DesignFace; if (desFace != null) { WriteBlock.ExecuteTask("Create Sphere Set", () => selection = SphereSet.Create(desFace, count, strength, radius, color).Subject); } else { SphereSet sphereSet = SphereSet.GetWrapper(preselection as CustomObject); if (sphereSet != null) { selection = sphereSet.Subject; CountSlider.Value = sphereSet.Count; StrengthSlider.Value = sphereSet.Strength; ColorComboBox.Value = sphereSet.Color; RadiusSlider.Value = sphereSet.Radius; } } Window.ActiveContext.Selection = new[] { selection }; return(false); }
protected override bool OnMouseMove(ScreenPoint cursorPos, Line cursorRay, MouseButtons button) { if (button != MouseButtons.None) { return(false); } IDocObject preselection = InteractionContext.Preselection; DesignFace designFace = preselection as DesignFace; if (designFace == null) // selection filtering is not applied if you (pre)select in the tree { return(false); } CurveSegment innerCurve, outerCurveA, outerCurveB; CreateThreadCurves(designFace.Shape, pitch, angle, positionOffset, out innerCurve, out outerCurveA, out outerCurveB); var primitives = new[] { CurvePrimitive.Create(innerCurve), CurvePrimitive.Create(outerCurveA), CurvePrimitive.Create(outerCurveB) }; var style = new GraphicStyle { LineColor = Color.DarkGray, LineWidth = 2 }; Graphic centerLine = Graphic.Create(style, primitives); style = new GraphicStyle { LineColor = Color.White, LineWidth = 4 }; Graphic highlightLine = Graphic.Create(style, primitives); Rendering = Graphic.Create(style, null, new[] { highlightLine, centerLine }); return(false); // if we return true, the preselection won't update }
protected override bool OnMouseMove(ScreenPoint cursorPos, Line cursorRay, MouseButtons button) { if (button != MouseButtons.None) { return(false); } IDocObject preselection = InteractionContext.Preselection; DesignEdge designEdge = preselection as DesignEdge; if (designEdge == null) // selection filtering is not applied if you (pre)select in the tree { return(false); } Circle edgeCircle = (Circle)designEdge.Shape.Geometry; CurveSegment innerCurve = CurveSegment.Create(Circle.Create(edgeCircle.Frame, apiGroove.InnerDiameter / 2)); CurveSegment outerCurve = CurveSegment.Create(Circle.Create(edgeCircle.Frame, apiGroove.OuterDiameter / 2)); var style = new GraphicStyle { LineColor = Color.DarkGray, LineWidth = 2 }; Graphic centerLine = Graphic.Create(style, new[] { CurvePrimitive.Create(innerCurve), CurvePrimitive.Create(outerCurve) }); style = new GraphicStyle { LineColor = Color.White, LineWidth = 4 }; Graphic highlightLine = Graphic.Create(style, new[] { CurvePrimitive.Create(innerCurve), CurvePrimitive.Create(outerCurve) }); Rendering = Graphic.Create(style, null, new[] { highlightLine, centerLine }); return(false); // if we return true, the preselection won't update }
protected override bool OnMouseMove(System.Drawing.Point cursorPos, Line cursorRay, MouseButtons button) { #if false IDocObject preselection = InteractionContext.Preselection; DesignFace desFace = null; Profile existingProfile = Profile.GetWrapper(preselection as CustomObject); if (existingProfile != null) { desFace = existingProfile.Face; } if (desFace == null) { desFace = preselection as DesignFace; } if (desFace == null) // selection filtering is not applied if you (pre)select in the tree { return(false); } Face face = desFace.Shape; var plane = face.GetGeometry <Plane>(); Point point; if (!plane.TryIntersectLine(cursorRay, out point)) { return(false); // plane is side-on } Fin fin; double offset = GetOffset(face, plane, point, out fin); var style = new GraphicStyle { LineColor = Color.DodgerBlue, LineWidth = 3 }; Graphic datumGraphic = Graphic.Create(style, CurvePrimitive.Create(fin.Edge)); if (existingProfile != null) { Rendering = datumGraphic; } else { style = new GraphicStyle { LineColor = Color.Gray }; Rendering = Graphic.Create(style, null, Profile.GetGraphic(0.5, 1, Math.PI / 2, Vector.Create(0.5, 0, 0)), datumGraphic); } #endif return(false); // if we return true, the preselection won't update }
public static Box GetBoundingBox(this IDocObject iDocObject, Matrix trans) { Box box = Box.Empty; foreach (Box shapeBox in iDocObject.GetDescendants <IHasTrimmedGeometry>().Select(t => t.Shape.GetBoundingBox(Matrix.Identity))) { box |= shapeBox; } return(box); }
public override bool SetValue(IDocObject obj, string value) { Debug.Assert(obj != null); Debug.Assert(!string.IsNullOrEmpty(value)); var iCustomObj = (ICustomObject)obj; var toolPathObj = FaceToolPathObject.GetWrapper(iCustomObj.Master); toolPathObj.ToolPath.Strategy = FaceToolPathObject.TypeNames.Keys.Where(s => FaceToolPathObject.TypeNames[s] == value).First(); toolPathObj.Regenerate(); return(true); }
protected override IDocObject AdjustSelection(IDocObject docObject) { var designEdge = docObject as DesignEdge; if (designEdge != null) { return(designEdge.Shape.GetGeometry <Circle>() != null ? designEdge : null); } Debug.Fail("Unexpected case"); return(null); }
protected override IDocObject AdjustSelection(IDocObject docObject) { #if false var desFace = docObject as DesignFace; if (desFace != null) return desFace.Shape.GetGeometry<Plane>() != null ? desFace : null; var custom = docObject as CustomObject; if (custom != null) return custom.Type == Profile.Type ? custom : null; Debug.Fail("Unexpected case"); #endif return docObject; }
public override string GetValue(IDocObject obj) { Debug.Assert(obj != null); var iCustomObj = obj as ICustomObject; if (iCustomObj != null) { var toolPathObj = FaceToolPathObject.GetWrapper(iCustomObj.Master); if (toolPathObj != null) { return(toolPathObj.Color.Name); } } return(null); }
public override string GetValue(IDocObject obj) { Debug.Assert(obj != null); var iCustomObj = obj as ICustomObject; if (iCustomObj != null) { var toolPathObj = FaceToolPathObject.GetWrapper(iCustomObj.Master); if (toolPathObj != null) // && toolPathObj.HasToolPath) { { return(FaceToolPathObject.TypeNames[toolPathObj.ToolPath.Strategy]); } } return(null); }
public override string GetValue(IDocObject obj) { Debug.Assert(obj != null); var iCustomObj = obj as ICustomObject; if (iCustomObj != null) { var toolPathObj = FaceToolPathObject.GetWrapper(iCustomObj.Master); if (toolPathObj != null) // && toolPathObj.HasToolPath) { { return(Window.ActiveWindow.Units.Length.Format(getValue(toolPathObj))); } } return(null); }
protected override IDocObject AdjustSelection(IDocObject docObject) { if (docObject as ICustomObject == null) { return(null); } FaceToolPathObject toolPathObj = FaceToolPathObject.GetWrapper((docObject as ICustomObject).Master); if (toolPathObj != null && toolPathObj.IDesFace != null) { return(docObject); } return(null); }
protected override bool OnMouseMove(ScreenPoint cursorPos, Line cursorRay, MouseButtons button) { if (button != MouseButtons.None) { return(false); } IDocObject preselection = InteractionContext.Preselection; DesignFace desFace = null; SphereSet existingSphereSet = SphereSet.GetWrapper(preselection as CustomObject); if (existingSphereSet != null) { desFace = existingSphereSet.DesFace; } if (desFace == null) { desFace = preselection as DesignFace; } if (desFace == null) // selection filtering is not applied if you (pre)select in the tree { return(false); } if (SphereSet.AllSphereSets.Where(s => s.DesFace == desFace).Count() > 0) { return(false); } Body body = desFace.Shape.Body; GraphicStyle style = null; if (existingSphereSet == null) { style = new GraphicStyle { EnableDepthBuffer = true, FillColor = color }; Rendering = Graphic.Create(style, null, SphereSet.GetGraphics(SphereSet.GetInitialPositions(body, count, true), radius)); } return(false); // if we return true, the preselection won't update }
protected override IDocObject AdjustSelection(IDocObject docObject) { #if false var desFace = docObject as DesignFace; if (desFace != null) { return(desFace.Shape.GetGeometry <Plane>() != null ? desFace : null); } var custom = docObject as CustomObject; if (custom != null) { return(custom.Type == Profile.Type ? custom : null); } Debug.Fail("Unexpected case"); #endif return(null); }
protected override IDocObject AdjustSelection(IDocObject docObject) { var desFace = docObject as DesignFace; if (desFace != null) { return(desFace); } var custom = docObject as CustomObject; if (custom != null) { return(custom.Type == FaceToolPathObject.Type ? custom : null); } Debug.Fail("Unexpected case"); return(null); }
public override bool SetValue(IDocObject obj, string value) { Debug.Assert(obj != null); Debug.Assert(!string.IsNullOrEmpty(value)); var iCustomObj = (ICustomObject)obj; var toolPathObj = FaceToolPathObject.GetWrapper(iCustomObj.Master); for (int i = 0; i < ColorList.Length; i++) { if (AllowableValues.ToArray()[i] == value) { toolPathObj.Color = ColorList[i]; break; } } // toolPathObj.Regenerate(); return(true); }
protected override IDocObject AdjustSelection(IDocObject docObject) { var iDesignFace = docObject as IDesignFace; if (iDesignFace != null) { return(iDesignFace); } var custom = docObject as CustomObject; if (custom != null) { return(custom.Type == OscillatorPart.Type ? custom : null); } Debug.Fail("Unexpected case"); return(null); }
protected override bool OnClickStart(System.Drawing.Point cursorPos, Line cursorRay) { string urlString = "URL"; IDocObject docObject = InteractionContext.Preselection; if (docObject == null) { return(false); } Document doc = docObject.Document; CustomProperty customProp; if (doc.CustomProperties.TryGetValue(urlString, out customProp)) { OpenURL(customProp.Value as string); } return(false); }
public override bool SetValue(IDocObject obj, string value) { Debug.Assert(obj != null); Debug.Assert(!string.IsNullOrEmpty(value)); double val; if (!Window.ActiveWindow.Units.Length.TryParse(value, out val)) { return(false); } if (Accuracy.LengthIsNegative(val)) { return(false); } var iCustomObj = (ICustomObject)obj; var toolPathObj = FaceToolPathObject.GetWrapper(iCustomObj.Master); setValue(toolPathObj, val); toolPathObj.Regenerate(); return(true); }
protected override bool OnMouseMove(ScreenPoint cursorPos, Line cursorRay, MouseButtons button) { if (button != MouseButtons.None) { return(false); } IDocObject preselection = InteractionContext.Preselection; IDesignFace iDesignFace = null; OscillatorPart existingOscillatorHandle = OscillatorPart.GetWrapper(preselection as CustomObject); if (existingOscillatorHandle != null) { iDesignFace = existingOscillatorHandle.IDesignFace; } if (iDesignFace == null) { iDesignFace = preselection as DesignFace; } if (iDesignFace == null) // selection filtering is not applied if you (pre)select in the tree { return(false); } SurfaceEvaluation eval = iDesignFace.Shape.GetSingleRayIntersection(cursorRay); if (eval == null) { return(false); } Rendering = Graphic.Create(null, null, OscillatorPart.GetGraphics(iDesignFace, eval.Param, 0.05, 0, HandleTypeEnum.All)); return(false); // if we return true, the preselection won't update }
public void HandleSelectionChanged() { IDocObject iDocObj = InteractionContext.SingleSelection; if (iDocObj != null && FaceToolPathObject.SelectedToolPath != null) { return; } UpdatePrototypeObject(); if (iDocObj == null) { return; } var iDesFace = iDocObj as IDesignFace; if (iDesFace != null) { prototypeObj.IDesFace = iDesFace; prototypeObj = null; return; } }
protected override void OnExecute(Command command, ExecutionContext context, Rectangle buttonRect) { if (Window.ActiveWindow.ActiveContext.SingleSelection is IDesignBody) { // reset all necessary parameters Settings.Default.Dimension = 0; // Save that 3D Dimension is chosen Settings.Default.forceCount = 0; Settings.Default.forces = ""; Settings.Default.bearingLoadCount = 0; Settings.Default.bearingLoads = ""; Settings.Default.xLength = 0; Settings.Default.yLength = 0; Settings.Default.zLength = 0; Settings.Default.Save(); Form form = new CreateCrossSectionForm(); form.StartPosition = FormStartPosition.Manual; Screen screen = Screen.PrimaryScreen; Rectangle bounds = screen.Bounds; // Show form in left bottom corner form.Location = (new System.Drawing.Point(bounds.X + (int)(bounds.Width * 0.05), bounds.Height - 258 - (int)(bounds.Height * 0.1))); // 523 = form Width, 258 Form Height DialogResult dr = form.ShowDialog(); // Show testDialog as a modal dialog and determine if DialogResult = OK. Settings set = Settings.Default; double distance = set.distance; if (dr == DialogResult.OK) { //MessageBox.Show("OK, distance : "+ distance); // Create points with selected distance bool teilbar = true; int count = 1; // point number // parameters to find origin of body double Xursprung = double.MaxValue; double Yursprung = double.MaxValue; double Zursprung = double.MaxValue; double Xmax = double.MinValue; double Ymax = double.MinValue; double Zmax = double.MinValue; Part mainPart = Window.ActiveWindow.Document.MainPart; Window.ActiveWindow.InteractionMode = InteractionMode.Solid; Window.ActiveWindow.ZoomSelection(); //var allBodies = new List<IDesignBody>(); //GatherBodies(mainPart, allBodies); // gets all bodies in window IDocObject Ibody = Window.ActiveWindow.ActiveContext.SingleSelection; IDesignBody designBody = (IDesignBody)Ibody; DesignBody body = designBody.Master; body.Name = "DesignSpace"; body.Style = BodyStyle.Transparent; // Make Block transparent body.SetVisibility(null, false); foreach (IDesignFace b in designBody.Faces) { foreach (IDesignEdge e in b.Edges) { SpaceClaim.Api.V19.Geometry.Point p1 = e.Shape.StartPoint; SpaceClaim.Api.V19.Geometry.Point p2 = e.Shape.EndPoint; // Locate minimum point of block if (p1.X < Xursprung) { Xursprung = p1.X; } if (p2.X < Xursprung) { Xursprung = p2.X; } if (p1.Y < Yursprung) { Yursprung = p1.Y; } if (p2.Y < Yursprung) { Yursprung = p2.Y; } if (p1.Z < Zursprung) { Zursprung = p1.Z; } if (p2.Z < Zursprung) { Zursprung = p2.Z; } // Locate max value of x, y and z if (p1.X > Xmax) { Xmax = p1.X; } if (p2.X > Xmax) { Xmax = p2.X; } if (p1.Y > Ymax) { Ymax = p1.Y; } if (p2.Y > Ymax) { Ymax = p2.Y; } if (p1.Z > Zmax) { Zmax = p1.Z; } if (p2.Z > Zmax) { Zmax = p2.Z; } // Check if distance is a factor of length, height or width if ((e.Shape.Length * 1000) % distance > -0.001 && (e.Shape.Length * 1000) % distance < 0.001) { } else { teilbar = false; } } } if (teilbar) { // Create all points in block for (double z = Zursprung; z <= Zmax + 0.001; z += distance / 1000) { for (double y = Yursprung; y <= Ymax + 0.001; y += distance / 1000) { for (double x = Xursprung; x <= Xmax + 0.001; x += distance / 1000) { SpaceClaim.Api.V19.Geometry.Point point = SpaceClaim.Api.V19.Geometry.Point.Create(x, y, z); DatumPoint P1 = DatumPoint.Create(Window.ActiveWindow.Document.MainPart, "P" + count, point); count++; } } } // save length set.xLength = (Xmax - Xursprung) * 1000; set.yLength = (Ymax - Yursprung) * 1000; set.zLength = (Zmax - Zursprung) * 1000; set.Save(); createCSV2(decimal.Parse("" + set.xLength), decimal.Parse("" + set.yLength), decimal.Parse("" + set.zLength), decimal.Parse("" + set.distance), set.csv2Path); // Set camera position Window.ActiveWindow.SetProjection(Frame.Create(SpaceClaim.Api.V19.Geometry.Point.Origin, -Direction.DirZ), 0.1); } else { MessageBox.Show("Distance is not a factor of length, height or width of block!", "Info"); body.Name = "DesignSpace"; body.SetVisibility(null, true); Settings.Default.CrossSecFormOpened = false; Settings.Default.Save(); } } else if (dr == DialogResult.Cancel) { //MessageBox.Show("Canceled!"); } Settings.Default.CrossSecFormOpened = true; Settings.Default.Save(); } else { MessageBox.Show("Select a body in document first!", "Info"); } }
protected override void OnExecute(Command command, ExecutionContext context, Rectangle buttonRect) { Settings set = Settings.Default; if (Window.ActiveWindow.ActiveContext.SingleSelection is DesignFace) { // Reset all necessary parameteres Settings.Default.Dimension = 1; // Save that 2D Dimension is chosen Settings.Default.forceCount = 0; Settings.Default.forces = ""; Settings.Default.bearingLoadCount = 0; Settings.Default.bearingLoads = ""; Settings.Default.xLength = 0; Settings.Default.yLength = 0; Settings.Default.zLength = 0; Settings.Default.Save(); Form form = new CreateCrossSectionForm(); form.StartPosition = FormStartPosition.Manual; Screen screen = Screen.PrimaryScreen; Rectangle bounds = screen.Bounds; // Show form in left bottom corner form.Location = (new System.Drawing.Point(bounds.X + (int)(bounds.Width * 0.05), bounds.Height - 258 - (int)(bounds.Height * 0.1))); // 523 = form Width, 258 Form Height DialogResult dr = form.ShowDialog(); // Show testDialog as a modal dialog and determine if DialogResult = OK. if (dr == DialogResult.OK) { try { int count = 1; // node number double distance = set.distance; // point distance bool teilbar = true; // Values to find origin of face double Xursprung = double.MaxValue; double Zursprung = double.MaxValue; double Xmax = double.MinValue; double Zmax = double.MinValue; double length = 0; double width = 0; IDocObject face = Window.ActiveWindow.ActiveContext.SingleSelection; IDesignFace designFace = (IDesignFace)face; foreach (IDesignEdge e in designFace.Edges) { SpaceClaim.Api.V19.Geometry.Point p1 = e.Shape.StartPoint; SpaceClaim.Api.V19.Geometry.Point p2 = e.Shape.EndPoint; // Locate minimum point of plane if (p1.X < Xursprung) { Xursprung = p1.X; } if (p2.X < Xursprung) { Xursprung = p2.X; } if (p1.Z < Zursprung) { Zursprung = p1.Z; } if (p2.Z < Zursprung) { Zursprung = p2.Z; } // Locate max value of x and z if (p1.X > Xmax) { Xmax = p1.X; } if (p2.X > Xmax) { Xmax = p2.X; } if (p1.Z > Zmax) { Zmax = p1.Z; } if (p2.Z > Zmax) { Zmax = p2.Z; } // Check if distance is a factor of length, height or width if ((e.Shape.Length * 1000) % distance > -0.001 && (e.Shape.Length * 1000) % distance < 0.001) { } else { teilbar = false; } } if (teilbar) { // Create all points in block for (double z = Zursprung; z <= Zmax + 0.001; z += distance / 1000) { for (double x = Xursprung; x <= Xmax + 0.001; x += distance / 1000) { SpaceClaim.Api.V19.Geometry.Point point = SpaceClaim.Api.V19.Geometry.Point.Create(x, 0, z); DatumPoint P1 = DatumPoint.Create(Window.ActiveWindow.Document.MainPart, "P" + count, point); count++; } } // save length set.xLength = (Xmax - Xursprung) * 1000; set.zLength = (Zmax - Zursprung) * 1000; set.Dimension = 1; set.Save(); createCSV2D(decimal.Parse("" + set.xLength), decimal.Parse("" + set.zLength), decimal.Parse("" + distance), set.csv2Path); // Set camera position Window.ActiveWindow.SetProjection(Frame.Create(SpaceClaim.Api.V19.Geometry.Point.Origin, -Direction.DirY), 0.1); } else { MessageBox.Show("Distance is not a factor of length, height or width of face!", "Info"); Settings.Default.CrossSecFormOpened = false; Settings.Default.Save(); } } catch (Exception es) { MessageBox.Show(""); } } else if (dr == DialogResult.Cancel) { //MessageBox.Show("Canceled!"); } } else { MessageBox.Show("Select a face in document first!", "Info"); } }
protected override IDocObject AdjustSelection(IDocObject docObject) { var designEdge = docObject as DesignEdge; if (designEdge != null) return designEdge.Shape.GetGeometry<Circle>() != null ? designEdge : null; Debug.Fail("Unexpected case"); return null; }
protected override IDocObject AdjustSelection(IDocObject docObject) { if (docObject as ICustomObject == null) return null; FaceToolPathObject toolPathObj = FaceToolPathObject.GetWrapper((docObject as ICustomObject).Master); if (toolPathObj != null && toolPathObj.IDesFace != null) return docObject; return null; }