private void buttonCloseAllViews_Click(object sender, EventArgs e) { var views = ViewHandler.GetAllViews(); while (views.MoveNext()) { var view = views.Current; ViewHandler.HideView(view); } }
/// <summary>Gets all model views from the opened tekla structures model</summary> public static List <View> GetAllModelViews() { var viewEnumerator = ViewHandler.GetAllViews(); var retList = new List <View>(viewEnumerator.Count); while (viewEnumerator.MoveNext()) { retList.Add(viewEnumerator.Current); } return(retList); }
private void InitializeUi() { var views = new List <Tekla.Structures.Model.UI.View>(); var currentViews = ViewHandler.GetAllViews(); while (currentViews.MoveNext()) { views.Add(currentViews.Current); } listBoxViews.DataSource = views.Select(v => v.Name).ToList(); }
private void listBoxViews_DoubleClick(object sender, EventArgs e) { var viewName = listBoxViews.SelectedItem.ToString(); var currentViews = ViewHandler.GetAllViews(); while (currentViews.MoveNext()) { var currentView = currentViews.Current; if (currentView.Name == viewName) { ViewHandler.ShowView(currentView); } } }
private void buttonCloseView_Click(object sender, EventArgs e) { var viewNames = listBoxViews.SelectedItems.OfType <string>().ToList(); var currentViews = ViewHandler.GetAllViews(); while (currentViews.MoveNext()) { var currentView = currentViews.Current; if (viewNames.Contains(currentView.Name)) { ViewHandler.HideView(currentView); } } }
private void buttonControlLines_Click(object sender, System.EventArgs e) { _controlLine = !_controlLine; var currentViews = ViewHandler.GetAllViews(); while (currentViews.MoveNext()) { var currentView = currentViews.Current; currentView.Select(); currentView.VisibilitySettings.ConstructionLinesVisible = _controlLine; currentView.Modify(); } }
private void buttonPart_Click(object sender, EventArgs e) { _part = !_part; var currentViews = ViewHandler.GetAllViews(); while (currentViews.MoveNext()) { var currentView = currentViews.Current; currentView.Select(); currentView.VisibilitySettings.PartsVisible = _part; currentView.VisibilitySettings.PartsVisibleInComponents = _part; currentView.Modify(); } }
private void buttonBaseWeld_Click(object sender, EventArgs e) { _baseWeld = !_baseWeld; var currentViews = ViewHandler.GetAllViews(); while (currentViews.MoveNext()) { var currentView = currentViews.Current; currentView.Select(); currentView.VisibilitySettings.WeldsVisible = _baseWeld; currentView.VisibilitySettings.WeldsVisibleInComponents = _baseWeld; currentView.Modify(); } }
private void buttonCutFitting_Click(object sender, EventArgs e) { _boolean = !_boolean; var currentViews = ViewHandler.GetAllViews(); while (currentViews.MoveNext()) { var currentView = currentViews.Current; currentView.Select(); currentView.VisibilitySettings.CutsVisible = _boolean; currentView.VisibilitySettings.CutsVisibleInComponents = _boolean; currentView.VisibilitySettings.FittingsVisible = _boolean; currentView.VisibilitySettings.FittingsVisibleInComponents = _boolean; currentView.Modify(); } }
private void buttonBoltGroup_Click(object sender, EventArgs e) { _boltGroup = !_boltGroup; var currentViews = ViewHandler.GetAllViews(); while (currentViews.MoveNext()) { var currentView = currentViews.Current; currentView.Select(); currentView.VisibilitySettings.BoltsVisible = _boltGroup; currentView.VisibilitySettings.BoltsVisibleInComponents = _boltGroup; currentView.VisibilitySettings.BoltHolesVisible = _boltGroup; currentView.VisibilitySettings.BoltHolesVisibleInComponents = _boltGroup; currentView.Modify(); } }
private void OnOff(bool value) { _controlLine = value; _controlPoint = value; _baseWeld = value; _baseComponent = value; _part = value; _boltGroup = value; _boolean = value; var currentViews = ViewHandler.GetAllViews(); while (currentViews.MoveNext()) { var currentView = currentViews.Current; currentView.Select(); currentView.VisibilitySettings.ConstructionLinesVisible = value; currentView.VisibilitySettings.WeldsVisibleInComponents = value; currentView.VisibilitySettings.PointsVisible = value; currentView.VisibilitySettings.PointsVisibleInComponents = value; currentView.VisibilitySettings.WeldsVisibleInComponents = value; currentView.VisibilitySettings.WeldsVisible = value; currentView.VisibilitySettings.WeldsVisibleInComponents = value; currentView.VisibilitySettings.ComponentsVisible = value; currentView.VisibilitySettings.ComponentsVisibleInComponents = value; currentView.VisibilitySettings.PartsVisible = value; currentView.VisibilitySettings.PartsVisibleInComponents = value; currentView.VisibilitySettings.BoltsVisible = value; currentView.VisibilitySettings.BoltsVisibleInComponents = value; currentView.VisibilitySettings.BoltHolesVisible = value; currentView.VisibilitySettings.BoltHolesVisibleInComponents = value; currentView.VisibilitySettings.CutsVisible = value; currentView.VisibilitySettings.CutsVisibleInComponents = value; currentView.VisibilitySettings.FittingsVisible = value; currentView.VisibilitySettings.FittingsVisibleInComponents = value; currentView.Modify(); } }
public static void Main(string[] args) { var model = new Model(); var graphicsDrawer = new GraphicsDrawer(); var picker = new Picker(); var red = new Color(1, 0, 0); var white = new Color(1, 1, 1); var blue = new Color(0, 0, 1); var green = new Color(0, 1, 0); var black = new Color(0, 0, 0); try { var savedPlane = model.GetWorkPlaneHandler().GetCurrentTransformationPlane(); model.GetWorkPlaneHandler().SetCurrentTransformationPlane(new TransformationPlane()); var part1 = picker.PickObject(Picker.PickObjectEnum.PICK_ONE_PART, "Pick Part") as Part; var solid = part1.GetSolid(); var maximumPoint = solid.MaximumPoint; var minimumPoint = solid.MinimumPoint; graphicsDrawer.DrawText(maximumPoint, maximumPoint.ToString(), white); graphicsDrawer.DrawText(minimumPoint, maximumPoint.ToString(), white); var part2 = picker.PickObject(Picker.PickObjectEnum.PICK_ONE_PART, "Pick Part") as Part; var part2CoordinateSystem = part2.GetCoordinateSystem(); var origin = part2CoordinateSystem.Origin; var xDirection = origin + part2CoordinateSystem.AxisX; var yDirection = origin + part2CoordinateSystem.AxisY; var xAxis = new LineSegment(origin, xDirection); var yAxis = new LineSegment(origin, yDirection); graphicsDrawer.DrawLineSegment(xAxis, blue); graphicsDrawer.DrawLineSegment(yAxis, red); graphicsDrawer.DrawText(origin, "ORIGIN", white); graphicsDrawer.DrawText(xDirection, "XAXIS", blue); graphicsDrawer.DrawText(yDirection, "YAXIS", red); var intersectionPoints = solid.GetAllIntersectionPoints(part2CoordinateSystem.Origin, part2CoordinateSystem.AxisX, part2CoordinateSystem.AxisY); while (intersectionPoints.MoveNext()) { var point = intersectionPoints.Current as Point; graphicsDrawer.DrawText(point, point.ToString(), green); } var plane = new Plane() { Origin = origin, AxisX = part2CoordinateSystem.AxisX, AxisY = part2CoordinateSystem.AxisY, }; var cut = new CutPlane() { Father = part1, Identifier = new Identifier(new Guid()), Plane = plane, }; cut.Insert(); model.CommitChanges(); var part2Centerline = part2.GetCenterLine(false); var intersect = solid.Intersect(new LineSegment(part2Centerline[0] as Point, part2Centerline[1] as Point)); var point1 = intersect[0] as Point; var point2 = intersect[1] as Point; graphicsDrawer.DrawText(point1, "POINT1", red); graphicsDrawer.DrawText(point2, "POINT2", blue); model.GetWorkPlaneHandler().SetCurrentTransformationPlane(savedPlane); var currentViews = ViewHandler.GetAllViews(); while (currentViews.MoveNext()) { var currentView = currentViews.Current; currentView.Select(); currentView.VisibilitySettings.WeldsVisible = false; currentView.VisibilitySettings.WeldsVisibleInComponents = false; currentView.VisibilitySettings.ComponentsVisible = false; currentView.VisibilitySettings.FittingsVisible = false; currentView.VisibilitySettings.FittingsVisibleInComponents = false; currentView.Modify(); } var faces = picker.PickFace("Pick Face"); var vertices = faces.OfType <InputItem>().ToList()[1].GetData() as ArrayList; foreach (Point vertex in vertices) { graphicsDrawer.DrawText(vertex, vertex.ToString(), black); } plane = new Plane { Origin = vertices[0] as Point, AxisX = new Vector((vertices[1] as Point) - (vertices[0] as Point)), AxisY = new Vector((vertices[2] as Point) - (vertices[0] as Point)), }; cut = new CutPlane { Father = part1, Identifier = new Identifier(new Guid()), Plane = plane, }; cut.Insert(); model.CommitChanges(); } catch (Exception ex) { // ignored } }
public static void Main(string[] args) { ModelViewEnumerator viewEnum = ViewHandler.GetTemporaryViews(); while (viewEnum.MoveNext()) { var currentView = viewEnum.Current; ViewHandler.HideView(currentView); } var picker = new Picker(); var connection = picker.PickObject(Picker.PickObjectEnum.PICK_ONE_OBJECT) as Connection; if (connection == null) { return; } var origin = connection.GetCoordinateSystem().Origin; var minPoint = new Point { X = origin.X - 200, Y = origin.Y - 200, Z = origin.Z - 300 }; var maxPoint = new Point { X = origin.X + 200, Y = origin.Y + 200, Z = origin.Z + 300 }; var name = $"Connection: {connection.Name} ({connection.Identifier.ID})"; var view = new View { Name = name, ViewCoordinateSystem = { AxisX = new Vector(1, 0, 0), AxisY = new Vector(0, 1, 0), Origin = origin }, DisplayCoordinateSystem = new CoordinateSystem() { AxisX = new Vector(1, -.7, 0), AxisY = new Vector(0, 1, 2), Origin = origin }, WorkArea = { MinPoint = minPoint, MaxPoint = maxPoint }, ViewDepthUp = 500, ViewDepthDown = 500, }; view.Insert(); var views = ViewHandler.GetAllViews(); while (views.MoveNext()) { var currentView = views.Current; if (currentView.Name == name) { ViewHandler.ShowView(currentView); } } }
private void buttonOff_Click(object sender, System.EventArgs e) { var picker = new Picker(); var modelObject = picker.PickObject(Picker.PickObjectEnum.PICK_ONE_OBJECT); var currentViews = ViewHandler.GetAllViews(); while (currentViews.MoveNext()) { var currentView = currentViews.Current; currentView.Select(); var type = modelObject.GetType().Name.ToUpper(); var baseType = modelObject.GetType().BaseType?.Name.ToUpper(); switch (type) { case "CONTROLLINE": _controlLine = false; currentView.VisibilitySettings.ConstructionLinesVisible = false; currentView.VisibilitySettings.WeldsVisibleInComponents = false; break; case "CONTROLPOINT": _controlPoint = false; currentView.VisibilitySettings.PointsVisible = false; currentView.VisibilitySettings.PointsVisibleInComponents = false; currentView.VisibilitySettings.WeldsVisibleInComponents = false; break; } switch (baseType) { case "BASEWELD": _baseWeld = false; currentView.VisibilitySettings.WeldsVisible = false; currentView.VisibilitySettings.WeldsVisibleInComponents = false; break; case "BASECOMPONENT": _baseComponent = false; currentView.VisibilitySettings.ComponentsVisible = false; currentView.VisibilitySettings.ComponentsVisibleInComponents = false; break; case "PART": _part = false; currentView.VisibilitySettings.PartsVisible = false; currentView.VisibilitySettings.PartsVisibleInComponents = false; break; case "BOLTGROUP": _boltGroup = false; currentView.VisibilitySettings.BoltsVisible = false; currentView.VisibilitySettings.BoltsVisibleInComponents = false; currentView.VisibilitySettings.BoltHolesVisible = false; currentView.VisibilitySettings.BoltHolesVisibleInComponents = false; break; case "BOOLEAN": _boolean = false; currentView.VisibilitySettings.CutsVisible = false; currentView.VisibilitySettings.CutsVisibleInComponents = false; currentView.VisibilitySettings.FittingsVisible = false; currentView.VisibilitySettings.FittingsVisibleInComponents = false; break; } currentView.Modify(); } }