/// <summary> Opens our test drawing </summary> /// /// <returns> true if it succeeds, false if it fails. </returns> internal static bool Initialize() { const int ViewNumber = (int)GraphicsViewType.Iso; // Start fresh FileManager.New(false); if (!File.Exists(MoldBase)) { var msg = $"Missing File {MoldBase}. Please copy the included file to the applicable folder."; DialogManager.OK(msg, "Missing File"); return(false); } if (!FileManager.Open(MoldBase)) { return(false); } ViewManager.GraphicsView = SearchManager.GetViews(ViewNumber)[0]; GraphicsManager.FitScreen(); GraphicsManager.Repaint(true); SelectionManager.UnselectAllGeometry(); GraphicsManager.ClearColors(new GroupSelectionMask()); return(true); }
/// <summary> Translate copy group to level. </summary> /// /// <param name="mask"> The mask. </param> /// <param name="level"> The level. </param> public static void TranslateCopyGroupToLevel(QuickMaskType mask, int level) { // Make sure nothing is already selected SelectionManager.UnselectAllGeometry(); // Set the mask SelectionManager.SelectGeometryByMask(mask); // Group on result var result = new GroupSelectionMask(false, true); // Translate in place if (!GeometryManipulationManager.TranslateGeometry(new Point3D { x = 0, y = 0, z = 0 }, new Point3D { x = 0, y = 0, z = 0 }, ViewManager.CPlane, ViewManager.CPlane, true)) { return; } // Move the grouped result to the level GeometryManipulationManager.MoveGroupGeometryToLevel(result, level); LevelsManager.SetLevelName(level, "Created via API"); GraphicsManager.ClearColors(new GroupSelectionMask()); // Hide all other levels HideLevels(level); }
/// <summary> Draws a block on the specified level. </summary> /// /// <param name="topPoint1"> The first top point. </param> /// <param name="topPoint2"> The second top point. </param> /// <param name="depth"> The depth. </param> /// <param name="level"> The level. </param> internal static void DrawBlock(Point3D topPoint1, Point3D topPoint2, double depth, int level) { SelectionManager.UnselectAllGeometry(); // Create the top rectangle var topRectangle = GeometryCreationManager.CreateRectangle(topPoint1, topPoint2); foreach (var element in topRectangle) { element.Color = 48; // Green element.Level = level; element.Commit(); } SelectionManager.SelectGeometryByMask(QuickMaskType.Lines); // Translate a copy down in Z for the bottom rectangle GeometryManipulationManager.TranslateGeometry( new Point3D(0, 0, topPoint1.z), new Point3D(0, 0, depth), ViewManager.GraphicsView, ViewManager.GraphicsView, true); SelectionManager.UnselectAllGeometry(); // Create the vertices var verticalLines = new ArrayList { new LineGeometry(new Point3D(topPoint1.x, topPoint1.y, topPoint1.z), new Point3D(topPoint1.x, topPoint1.y, depth)), new LineGeometry(new Point3D(topPoint1.x, topPoint2.y, topPoint1.z), new Point3D(topPoint1.x, topPoint2.y, depth)), new LineGeometry(new Point3D(topPoint2.x, topPoint2.y, topPoint1.z), new Point3D(topPoint2.x, topPoint2.y, depth)), new LineGeometry(new Point3D(topPoint2.x, topPoint1.y, topPoint1.z), new Point3D(topPoint2.x, topPoint1.y, depth)) }; foreach (Geometry line in verticalLines) { line.Color = 48; // Green line.Level = level; line.Commit(); } const int ViewNumber = (int)GraphicsViewType.Iso; ViewManager.GraphicsView = SearchManager.GetViews(ViewNumber)[0]; GraphicsManager.FitScreen(); GraphicsManager.ClearColors(new GroupSelectionMask()); }
/// <summary> Copies the geometry. </summary> /// /// <param name="mask"> The mask. </param> /// <param name="level"> The level. </param> /// /// <returns> An int. </returns> public static int CopyGeometry(QuickMaskType mask, int level) { SelectionManager.UnselectAllGeometry(); SelectionManager.SelectGeometryByMask(mask); LevelsManager.SetLevelName(level, "Copied geometry via API"); var result = GeometryManipulationManager.CopySelectedGeometryToLevel(level, true); GraphicsManager.ClearColors(new GroupSelectionMask()); HideLevels(level); return(result); }