Exemple #1
0
        //static Plane CreatePlane(Point origin, Direction normal)
        //{
        //    return Plane.Create(Frame.Create(origin, normal));
        //}

        static DesignBody CreatePPBar(Part part)
        {
            Window window = Window.ActiveWindow;

            Debug.Assert(part != null, "part 1= null");

            double barRadius = 0.002;
            double barLenght = 0.020;

            Point pointStart = Point.Create(0, 0.03, 0.07);
            Point pointEnd   = Point.Create(0.02, 0.04, 0.09);

            DesignCurve.Create(part, CurveSegment.Create(pointStart, pointEnd));

            //Plane plane = CreatePlane(pointStart, normal);
            //DesignCurve line = DesignCurve.Create();
            //Direction direction = Direction.Equals(CurveSegment);
            //Frame frame = Frame.Create(pointStart);
            //Plane plane = Plane.Create(frame);


            Body bar = Body.ExtrudeProfile(new CircleProfile(Plane.PlaneYZ, barRadius), barLenght);

            return(DesignBody.Create(part, "Cylinder", bar));
        }
Exemple #2
0
        public static DesignBody CreateBar(Part part)
        {
            Debug.Assert(part != null, "part != null");

            double barRadius = 0.002;
            double barLenght = 0.020;

            Point pointStart = Point.Create(0, 0, 0);
            Point pointEnd   = Point.Create(0, 0.04, 0.05);

            DesignCurve.Create(part, CurveSegment.Create(pointStart, pointEnd));

            Body cylinder1 = Body.ExtrudeProfile(new CircleProfile(Plane.PlaneZX, barRadius), barLenght);

            DesignBody.Create(part, "Cylinder1", cylinder1);


            Body cylinder2 = Body.ExtrudeProfile(new CircleProfile(Plane.PlaneXY, barRadius), barLenght);

            DesignBody.Create(part, "Cylinder2", cylinder2);


            Body cylinder3 = Body.ExtrudeProfile(new CircleProfile(Plane.PlaneYZ, barRadius), barLenght);

            return(DesignBody.Create(part, "Cylinder3", cylinder3));
        }
Exemple #3
0
        static void CreateLine(Part line)
        {
            Window window     = Window.ActiveWindow;
            Point  pointStart = Point.Create(0.10, 0.04, 0.07);
            Point  pointEnd   = Point.Create(0.02, 0.11, 0.09);

            DesignCurve.Create(line, CurveSegment.Create(pointStart, pointEnd));
            MessageBox.Show($"Line between {pointStart} and {pointEnd} will be created", "Info");
        }
        static void CreatePoints(Part part)
        {
            Window window = Window.ActiveWindow;

            List <PointTarget> points = ImportingFun.LoadSampleData();

            foreach (var PointTarget in points)
            {
                //MessageBox.Show($"Line between {points[0]} and will be created");
                Point.Create(PointTarget.xPoint, PointTarget.yPoint, PointTarget.zPoint);
            }
        }
Exemple #5
0
        static void CreateLines(Part multiLine)
        {
            Window window = Window.ActiveWindow;

            List <PointTarget> points = ImportingFun.LoadSampleData();

            foreach (var PointTarget in points)
            {
                //MessageBox.Show($"Line between {points[0]} and will be created");
                DesignCurve.Create(multiLine, CurveSegment.Create(Point.Create(PointTarget.xPoint, PointTarget.yPoint, PointTarget.zPoint), Point.Create(PointTarget.x2Point, PointTarget.y2Point, PointTarget.z2Point)));
            }
        }
Exemple #6
0
        static void MultiBeamCreator(Part part)
        {
            try
            {
                //Document doc = Document.GetDocument(Settings.Default.ProjectPath + "/" + Settings.Default.ProjectName + ".scdoc");
                Document doc = Window.ActiveWindow.Document;
                Part     p   = doc.MainPart;

                int id = 0;
                List <PointLocation> pointLocations = CsvDataRead.ReadData();  // Get all beams out of file

                foreach (var location in pointLocations)
                {
                    Point startPoint = Point.Create(Double.Parse("" + (location.xPoint / 1000), new CultureInfo("de-DE")), Double.Parse("" + (location.yPoint / 1000), new CultureInfo("de-DE")), Double.Parse("" + (location.zPoint / 1000), new CultureInfo("de-DE")));
                    Point endPoint   = Point.Create(Double.Parse("" + (location.x2Point / 1000), new CultureInfo("de-DE")), Double.Parse("" + (location.y2Point / 1000), new CultureInfo("de-DE")), Double.Parse("" + (location.z2Point / 1000), new CultureInfo("de-DE")));
                    if (location.diameter != 0)
                    {
                        try
                        {
                            double diameter = location.diameter;
                            double radi     = Double.Parse("" + (location.diameter / 2000), new CultureInfo("de-DE"));

                            var lineSegment = CurveSegment.Create(startPoint, endPoint);
                            var designLine  = DesignCurve.Create(p, lineSegment);

                            Vector heightVector = endPoint - startPoint;
                            Frame  frame        = Frame.Create(startPoint, heightVector.Direction);
                            Plane  plane        = Plane.Create(frame);
                            var    profi        = new CircleProfile(plane, radi);

                            //var doc = DocumentHelper.GetActiveDocument();
                            //Document doc = Document.GetDocument(Path.GetDirectoryName("Document1"));
                            //Document doc = window.ActiveContext.Context.Document;


                            Part beamProfile = Part.CreateBeamProfile(doc, "Beam" + id, profi);

                            Beam.Create(beamProfile, designLine);
                            id += 1;
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show(ex.ToString(), "Info");
                        }
                    }
                }
            }
            catch (Exception exe)
            {
                MessageBox.Show(exe.ToString(), "Info");
            }
        }
        public static DesignBody CylinderPtPt(Part part)
        {
            Point  point1   = Point.Create(0.00, 0.01, 0.00);
            Point  point2   = Point.Create(0.03, 0.05, 0.04);
            double diameter = 0.004;
            double radi     = diameter / 2;

            Vector heightVector = point2 - point1;
            Frame  frame        = Frame.Create(point1, heightVector.Direction);
            Plane  plane        = Plane.Create(frame);


            Body cylinder4 = Body.ExtrudeProfile(new CircleProfile(plane, radi), heightVector.Magnitude);

            return(DesignBody.Create(part, "Cylinder3", cylinder4));
        }
        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");
            }
        }
Exemple #9
0
        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");
            }
        }