public static string GetDocMassUnits(Document document)
        {
            UnitsOfMeasure unitsOfMeasure  = document.UnitsOfMeasure;
            string         stringFromValue = unitsOfMeasure.GetStringFromValue(0.0, unitsOfMeasure.MassUnits);

            return(stringFromValue.Split(new char[] { ' ' })[1]);
        }
Exemplo n.º 2
0
        public double[] FindOrigin(ComponentOccurrence oCompOccur)
        {
            UnitsOfMeasure oUOM = _invApp.ActiveDocument.UnitsOfMeasure;
            AssemblyComponentDefinition oCompDef = (AssemblyComponentDefinition)oCompOccur.Definition;
            object oWorkPointProxy;

            double[]  c   = new double[3];
            WorkPoint oWP = oCompDef.WorkPoints[1];

            oCompOccur.CreateGeometryProxy(oWP, out oWorkPointProxy);

            c[0] = ((WorkPointProxy)oWorkPointProxy).Point.X;
            c[1] = ((WorkPointProxy)oWorkPointProxy).Point.Y;
            c[2] = ((WorkPointProxy)oWorkPointProxy).Point.Z;

            for (int k = 0; k < 3; k++)
            {
                c[k] = oUOM.ConvertUnits(c[k], "cm", "m");
            }

            string AbsolutePosition, name;

            name = FormatName(oCompOccur.Name);

            return(c);
        }
Exemplo n.º 3
0
        public double GetValueFromExpression(string expression)
        {
            double value = 0.0;

            //get the active document
            Document activeDocument = m_inventorApplication.ActiveDocument;

            //get the unit of measure object
            UnitsOfMeasure unitsOfMeasure = activeDocument.UnitsOfMeasure;

            //get the current length units of the user
            UnitsTypeEnum lengthUnitsType = unitsOfMeasure.LengthUnits;

            //convert the expression to the current length units of user
            try
            {
                object vVal;
                vVal  = unitsOfMeasure.GetValueFromExpression(expression, lengthUnitsType);
                value = System.Convert.ToDouble(vVal);
            }
            catch (System.Exception e)
            {
                string strErrorMsg = e.Message;

                value = 0.0;
                return(value);
            }
            return(value);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Gets the value of a numeric parameter.
        /// <code></code>VB sample:<code>Msgbox(GetParameterValue(oDoc, "ParameterName"))</code>
        /// </summary>
        /// <param name="document">Inventor.Document</param>
        /// <param name="parameterName">Name of the parameter as a string.</param>
        /// <returns></returns>
        public static string GetParameterValue(this Document document, string parameterName)
        {
            Parameter parameter = document.GetParameter(parameterName);

            UnitsOfMeasure uom = document.UnitsOfMeasure;

            if (!ParameterExists(parameter))
            {
                return(String.Empty);
            }

            var value = parameter.Value;
            var unit  = parameter.get_Units();

            UnitsTypeEnum unitEnum;

            unitEnum = uom.GetTypeFromString(unit);

            switch (unitEnum)
            {
            case UnitsTypeEnum.kBooleanUnits:
                return((string)parameter.Value);

            case UnitsTypeEnum.kTextUnits:
                return((string)parameter.Value);

            default:
                return(uom.GetStringFromValue((double)value, unitEnum));
            }
        }
        public virtual void ConvertAndValidateLineData(LoadDetailData load, bool manuallyCreated, string urnPrefix, BaseServiceResponse response)
        {
            if (load.LineItems?.Count > 0)
            {
                for (int i = 0; i < load.LineItems.Count; i++)
                {
                    var itemUrnPrefix = $"{urnPrefix}:{nameof(load.LineItems)}:{i}";
                    var lineItem      = load.LineItems[i];
                    //if (string.IsNullOrWhiteSpace(lineItem.ProductDescription))
                    //    response.AddError($"{itemUrnPrefix}:{nameof(lineItem.ProductDescription)}", _messages.ProductDescriptionRequired);
                    if (lineItem.Quantity <= 0)
                    {
                        response.AddError($"{itemUrnPrefix}:{nameof(lineItem.Quantity)}", _messages.LineItemQuantityInvalid);
                    }
                    if (lineItem.Weight <= 0)
                    {
                        response.AddError($"{itemUrnPrefix}:{nameof(lineItem.Weight)}", _messages.LineItemWeightInvalid);
                    }
                    if (lineItem.Volume <= 0)
                    {
                        response.AddError($"{itemUrnPrefix}:{nameof(lineItem.Volume)}", _messages.LineItemVolumeInvalid);
                    }

                    if (string.IsNullOrWhiteSpace(lineItem.UnitOfMeasure))
                    {
                        response.AddError($"{itemUrnPrefix}:{nameof(lineItem.UnitOfMeasure)}", _messages.UnitOfMeasureRequired);
                    }
                    else
                    {
                        //match unit of measure on name or code
                        lineItem.UnitOfMeasureId = UnitsOfMeasure?.FirstOrDefault(_ =>
                                                                                  string.Compare(_.Name, lineItem.UnitOfMeasure, true) == 0 ||
                                                                                  string.Compare(_.Code, lineItem.UnitOfMeasure, true) == 0)?.UnitOfMeasureId;
                        if (lineItem.UnitOfMeasureId == null)
                        {
                            response.AddError($"{itemUrnPrefix}:{nameof(lineItem.UnitOfMeasure)}", _messages.UnitOfMeasureInvalid);
                        }
                    }

                    if (lineItem.PickupStopNumber <= 0)
                    {
                        response.AddError($"{itemUrnPrefix}:{nameof(lineItem.PickupStopNumber)}", _messages.LineItemPickupStopNumberRequired);
                    }
                    else if (!(load.LoadStops?.Any(_ => _.StopTypeId == (int)StopTypeEnum.Pickup && _.StopNbr == lineItem.PickupStopNumber) ?? false))
                    {
                        response.AddError($"{itemUrnPrefix}:{nameof(lineItem.PickupStopNumber)}", _messages.LineItemPickupStopNumberInvalid);
                    }

                    if (lineItem.DeliveryStopNumber <= 0)
                    {
                        response.AddError($"{itemUrnPrefix}:{nameof(lineItem.DeliveryStopNumber)}", _messages.LineItemDeliveryStopNumberRequired);
                    }
                    else if (!(load.LoadStops?.Any(_ => _.StopTypeId == (int)StopTypeEnum.Delivery && _.StopNbr == lineItem.DeliveryStopNumber) ?? false))
                    {
                        response.AddError($"{itemUrnPrefix}:{nameof(lineItem.DeliveryStopNumber)}", _messages.LineItemDeliveryStopNumberInvalid);
                    }
                }
            }
        }
Exemplo n.º 6
0
 public void Rectangle(double x, double y, double width, double height, UnitsOfMeasure unit)
 {
     Rectangle(
         new Vector1D(x, unit),
         new Vector1D(y, unit),
         new Vector1D(width, unit),
         new Vector1D(height, unit));
 }
Exemplo n.º 7
0
 public void CurveTo(double x2, double y2, double x3, double y3, UnitsOfMeasure unit)
 {
     CurveTo(
         new Vector1D(x2, unit),
         new Vector1D(y2, unit),
         new Vector1D(x3, unit),
         new Vector1D(y3, unit));
 }
Exemplo n.º 8
0
 public void Arc(double x1, double y1, double x2, double y2, UnitsOfMeasure unit, float startAngle, float extentAngle)
 {
     Arc(
         new Vector1D(x1, unit),
         new Vector1D(y1, unit),
         new Vector1D(x2, unit),
         new Vector1D(y2, unit), startAngle, extentAngle);
 }
Exemplo n.º 9
0
        public ActionResult DeleteConfirmed(int id)
        {
            UnitsOfMeasure unitsOfMeasure = db.UnitsOfMeasures.Find(id);

            db.UnitsOfMeasures.Remove(unitsOfMeasure);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Exemplo n.º 10
0
 public void CurveTo(double x2, double y2, double x3, double y3, UnitsOfMeasure unit)
 {
     CurveTo(
        new Vector1D(x2, unit),
        new Vector1D(y2, unit),
        new Vector1D(x3, unit),
        new Vector1D(y3, unit));
 }
Exemplo n.º 11
0
 public void CurveFromTo(double x1, double y1, double x3, double y3, UnitsOfMeasure unit)
 {
     CurveFromTo(
         new Vector1D(x1, unit),
         new Vector1D(y1, unit),
         new Vector1D(x3, unit),
         new Vector1D(y3, unit));
 }
Exemplo n.º 12
0
 public void CurveFromTo(double x1, double y1, double x3, double y3, UnitsOfMeasure unit)
 {
     CurveFromTo(
        new Vector1D(x1, unit),
        new Vector1D(y1, unit),
        new Vector1D(x3, unit),
        new Vector1D(y3, unit));
 }
Exemplo n.º 13
0
 public void Arc(double x1, double y1, double x2, double y2, UnitsOfMeasure unit, float startAngle, float extentAngle)
 {
     Arc(
        new Vector1D(x1, unit),
        new Vector1D(y1, unit),
        new Vector1D(x2, unit),
        new Vector1D(y2, unit), startAngle, extentAngle);
 }
Exemplo n.º 14
0
        public void WriteURDF(string xmlfilename)
        {
            UnitsOfMeasure              oUOM        = _invApp.ActiveDocument.UnitsOfMeasure;
            AssemblyDocument            oAsmDoc     = (AssemblyDocument)_invApp.ActiveDocument;
            AssemblyComponentDefinition oAsmCompDef = oAsmDoc.ComponentDefinition;
            ComponentOccurrence         Parent;
            string ParentName, AbsolutePosition, name, mirname, mirParentName;

            double[] ParentCOM, Offset;

            Robot hubo = new Robot("HuboPlus");

            foreach (ComponentOccurrence oCompOccur in oAsmCompDef.Occurrences)
            {
                // Generate links from available subassemblies in main assembly.
                hubo.Links.Add(new Link(oCompOccur.Name));
                int c = hubo.Links.Count - 1;
                for (int i = 0; i < hubo.Links.Count; i++)
                {
                    if (String.Equals(hubo.Links[i].Name, ReturnParentName(oCompOccur)))
                    {
                        hubo.Links[c].Parent = hubo.Links[i];
                    }
                }

                if (hubo.Links[c].Parent != null)
                {
                    hubo.Joints.Add(new Joint(FormatJointName(hubo.Links[c].Name), JointType.Revolute, hubo.Links[c].Parent, hubo.Links[c]));
                    int j = hubo.Joints.Count - 1;
                    switch (hubo.Joints[j].Name[hubo.Joints[j].Name.Length - 1])
                    {
                    case 'R':
                        hubo.Joints[j].Axis = new double[] { 1, 0, 0 };
                        break;

                    case 'P':
                        hubo.Joints[j].Axis = new double[] { 0, 1, 0 };
                        break;

                    case 'Y':
                        hubo.Joints[j].Axis = new double[] { 0, 0, 1 };
                        break;

                    default:
                        break;
                    }
                }

                // Get mass properties for each link.
                double[] iXYZ = new double[6];
                oCompOccur.MassProperties.XYZMomentsOfInertia(out iXYZ[0], out iXYZ[3], out iXYZ[5], out iXYZ[1], out iXYZ[4], out iXYZ[2]); // Ixx, Iyy, Izz, Ixy, Iyz, Ixz -> Ixx, Ixy, Ixz, Iyy, Iyz, Izz
                hubo.Links[c].Inertial     = new Inertial(oCompOccur.MassProperties.Mass, iXYZ);
                hubo.Links[c].Inertial.XYZ = FindCenterOfMassOffset(oCompOccur);

                // Set shape properties for each link.
                hubo.Links[c].Visual = new Visual(new Mesh("package://" + hubo.Name + "/" + hubo.Links[c].Name + ".stl"));
            }
        }
        public static double GetDocDensity(Document document, double ApiDensity)
        {
            UnitsOfMeasure unitsOfMeasure = document.UnitsOfMeasure;

            double num  = unitsOfMeasure.ConvertUnits(1.0, "g", unitsOfMeasure.MassUnits);
            double num2 = unitsOfMeasure.ConvertUnits(1.0, "cm^3", GetDocVolumeUnits(document));

            return(ApiDensity * num / num2);
        }
        public static string GetDbVolumeUnits(Document document, bool appendSymbol = true)
        {
            UnitsOfMeasure unitsOfMeasure = document.UnitsOfMeasure;

            string stringFromValue = unitsOfMeasure.GetStringFromValue(0.0, UnitsTypeEnum.kDatabaseLengthUnits);

            string volUnit = stringFromValue.Split(new char[] { ' ' })[1];

            return(appendSymbol ? volUnit + "^3" : volUnit + " " + volUnit + " " + volUnit);
        }
Exemplo n.º 17
0
        public Inventor.Vector UpdateUnits(Inventor.Vector inp)
        {
            UnitsOfMeasure oUOM = _invApp.ActiveDocument.UnitsOfMeasure;

            inp.X = oUOM.ConvertUnits(inp.X, "cm", "m");
            inp.Y = oUOM.ConvertUnits(inp.Y, "cm", "m");
            inp.Z = oUOM.ConvertUnits(inp.Z, "cm", "m");

            return(inp);
        }
Exemplo n.º 18
0
        /////////////////////////////////////////////////////////////
        // Use: Returns Thread Pitch as string using default units.
        //
        /////////////////////////////////////////////////////////////
        public static string GetThreadPitchStr(ThreadInfo threadInfo,
                                               Document doc)
        {
            double pitch = ThreadWorker.GetThreadPitch(threadInfo);

            UnitsOfMeasure uom = doc.UnitsOfMeasure;

            return(uom.GetStringFromValue(pitch,
                                          UnitsTypeEnum.kDefaultDisplayLengthUnits));
        }
Exemplo n.º 19
0
 public ActionResult Edit([Bind(Include = "Id,Name")] UnitsOfMeasure unitsOfMeasure)
 {
     if (ModelState.IsValid)
     {
         db.Entry(unitsOfMeasure).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(unitsOfMeasure));
 }
Exemplo n.º 20
0
        public static String AsText(this UnitsOfMeasure UnitOfMeasure)
        {
            switch (UnitOfMeasure)
            {
            case UnitsOfMeasure.Celsius:
                return("Celsius");

            case UnitsOfMeasure.Fahrenheit:
                return("Fahrenheit");

            case UnitsOfMeasure.kWh:
                return("kWh");

            case UnitsOfMeasure.varh:
                return("varh");

            case UnitsOfMeasure.kvarh:
                return("kvarh");

            case UnitsOfMeasure.Watts:
                return("W");

            case UnitsOfMeasure.kW:
                return("kW");

            case UnitsOfMeasure.VoltAmpere:
                return("VA");

            case UnitsOfMeasure.kVA:
                return("kVA");

            case UnitsOfMeasure.var:
                return("var");

            case UnitsOfMeasure.kvar:
                return("kvar");

            case UnitsOfMeasure.Amperes:
                return("A");

            case UnitsOfMeasure.Voltage:
                return("V");

            case UnitsOfMeasure.Kelvin:
                return("K");

            case UnitsOfMeasure.Percent:
                return("Percent");


            default:
                return("Wh");
            }
        }
Exemplo n.º 21
0
        private void ShowDia(double dia)
        {
            //get the active document
            Document activeDocument = m_inventorApplication.ActiveDocument;
            //get the unit of measure object
            UnitsOfMeasure unitsOfMeasure = activeDocument.UnitsOfMeasure;

            string unitExpre = unitsOfMeasure.GetStringFromType(unitsOfMeasure.LengthUnits);

            m_connectCmdDlg.diaTextBox.Text = (unitsOfMeasure.ConvertUnits(dia, "cm", unitExpre)).ToString();
        }
Exemplo n.º 22
0
        //使能面板上的位置显示控件,并显示位置
        private void ShowLocation(double Xposition, double Yposition)
        {
            m_connectCmdDlg.numerUPX.Enabled = true;
            m_connectCmdDlg.numerUPY.Enabled = true;

            UnitsOfMeasure unitsOfMeasure = m_inventorApplication.ActiveDocument.UnitsOfMeasure;
            string         unitExpre      = unitsOfMeasure.GetStringFromType(unitsOfMeasure.LengthUnits);

            m_connectCmdDlg.numerUPX.Text = (unitsOfMeasure.ConvertUnits(Xposition, "cm", unitExpre)).ToString();
            m_connectCmdDlg.numerUPY.Text = (unitsOfMeasure.ConvertUnits(Yposition, "cm", unitExpre)).ToString();
        }
Exemplo n.º 23
0
        public ActionResult Create([Bind(Include = "Id,Name")] UnitsOfMeasure unitsOfMeasure)
        {
            if (ModelState.IsValid)
            {
                db.UnitsOfMeasures.Add(unitsOfMeasure);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(unitsOfMeasure));
        }
Exemplo n.º 24
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (_invApp.Documents.Count == 0)
            {
                // Create an instance of the open file dialog box.
                OpenFileDialog openFileDialog1 = new OpenFileDialog();
                openFileDialog1.Filter      = "Inventor assembly (.iam)|*.iam|All Files (*.*)|*.*";
                openFileDialog1.FilterIndex = 1;
                openFileDialog1.Multiselect = false;

                // Call the ShowDialog method to show the dialog box.
                DialogResult dialogResult = openFileDialog1.ShowDialog();

                // Process input if the user clicked OK.
                if (dialogResult == DialogResult.OK)
                {
                    _invApp.Documents.Open(openFileDialog1.FileName);
                }
                else
                {
                    _invApp.Documents.Open("D:\\Workspace\\AutoTurf4_CAD\\Version 4 - Komplet maskine.iam");
                }
            }

            oUOM        = _invApp.ActiveDocument.UnitsOfMeasure;
            oAsmDoc     = (AssemblyDocument)_invApp.ActiveDocument;
            oAsmCompDef = oAsmDoc.ComponentDefinition;

            //Change to master version for massproperties and joints
            repman     = oAsmCompDef.RepresentationsManager;
            lod_master = repman.LevelOfDetailRepresentations["Master"];
            lod_simple = repman.LevelOfDetailRepresentations["Collision"];

            lod_master.Activate();
            robot = new Robot(oAsmDoc.DisplayName, oAsmCompDef);

            textBox1.Text = oAsmDoc.DisplayName;

            dataGridView1.AutoGenerateColumns         = false;
            dataGridView2.AutoGenerateColumns         = false;
            dataGridView1.DataSource                  = robot.Links;
            dataGridView1.Columns[0].DataPropertyName = "Name";
            dataGridView1.Columns[1].DataPropertyName = "Inertial";
            dataGridView2.DataSource                  = robot.Joints;
            dataGridView2.Columns[0].DataPropertyName = "Name";
            dataGridView2.Columns[1].DataPropertyName = "JointType";
            dataGridView2.Columns[2].DataPropertyName = "Origin";
            dataGridView2.Columns[3].DataPropertyName = "Axis";
            dataGridView2.Columns[4].DataPropertyName = "Parent";
            dataGridView2.Columns[5].DataPropertyName = "Child";
        }
Exemplo n.º 25
0
        private void button3_Click(object sender, RoutedEventArgs e)
        {
            if (_invApp.Documents.Count == 0)
            {
                // Create an instance of the open file dialog box.
                OpenFileDialog openFileDialog1 = new OpenFileDialog();
                openFileDialog1.Filter      = "Inventor assembly (.iam)|*.iam|All Files (*.*)|*.*";
                openFileDialog1.FilterIndex = 1;
                openFileDialog1.Multiselect = false;

                // Call the ShowDialog method to show the dialog box.


                // Process input if the user clicked OK.
                if (openFileDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    _invApp.Documents.Open(openFileDialog1.FileName);
                }
                else
                {
                    _invApp.Documents.Open(Properties.Settings.Default.autoload_file);
                }
            }

            oUOM        = _invApp.ActiveDocument.UnitsOfMeasure;
            oAsmDoc     = (AssemblyDocument)_invApp.ActiveDocument;
            oAsmCompDef = oAsmDoc.ComponentDefinition;

            //Change to master version for massproperties and joints
            repman     = oAsmCompDef.RepresentationsManager;
            lod_master = repman.LevelOfDetailRepresentations["Master"];

            lod_master.Activate();
            robot = new Robot(oAsmDoc.DisplayName, oAsmCompDef);

            if (addbaselinkcheckbox.IsChecked == true)
            {
                addbaselink(ref robot, oAsmCompDef);
            }

            textBox.Text = oAsmDoc.DisplayName.TrimEnd(".iam".ToCharArray());

            dataGridLinks.DataContext  = robot.Links;
            dataGridJoints.DataContext = robot.Joints;

            dataGridLinks.ItemsSource  = robot.Links;
            dataGridJoints.ItemsSource = robot.Joints;
            dataGridLinks.Items.Refresh();
            dataGridJoints.Items.Refresh();
        }
Exemplo n.º 26
0
        private Inventor.ExtrudeFeature CreateFlangeExtrustion(ref Inventor.PartDocument PartDocument, string FlangeDiaOD, string FlangeDiaID, string FlangeThickness)
        {
            Inventor.UnitsOfMeasure      UnitsOfMeasure;
            Inventor.PlanarSketch        Sketch;
            Inventor.TransientGeometry   TransientGeometry;
            Inventor.SketchCircle        SketchCircle;
            Inventor.WorkPoint           WorkPoint;
            Inventor.WorkPlane           BaseWorkPlane;
            Inventor.RadiusDimConstraint RadiusDimConstraint = null;
            Inventor.SketchEntity        SketchEntity;
            Inventor.ObjectCollection    SketchObjectCollection;
            Inventor.Profile             Profile;
            Inventor.ExtrudeDefinition   ExtrudeDefinition;
            Inventor.ExtrudeFeature      ExtrudeFeature = null;

            SketchObjectCollection = InvApp.TransientObjects.CreateObjectCollection();

            UnitsOfMeasure = PartDocument.UnitsOfMeasure;
            double DiaOD = 0, DiaID = 0, Thickness = 0;

            DiaOD     = UnitsOfMeasure.GetValueFromExpression(FlangeDiaOD, Inventor.UnitsTypeEnum.kMillimeterLengthUnits);
            DiaID     = UnitsOfMeasure.GetValueFromExpression(FlangeDiaID, Inventor.UnitsTypeEnum.kMillimeterLengthUnits);
            Thickness = UnitsOfMeasure.GetValueFromExpression(FlangeThickness, Inventor.UnitsTypeEnum.kMillimeterLengthUnits);

            TransientGeometry = InvApp.TransientGeometry;
            WorkPoint         = PartDocument.ComponentDefinition.WorkPoints[1];
            BaseWorkPlane     = GetPartDocumentWorkPlane(ref PartDocument, "XY");

            Sketch              = PartDocument.ComponentDefinition.Sketches.Add(BaseWorkPlane, false);
            SketchEntity        = Sketch.AddByProjectingEntity(WorkPoint);
            SketchCircle        = Sketch.SketchCircles.AddByCenterRadius(TransientGeometry.CreatePoint2d(0, 0), DiaOD / 2);
            RadiusDimConstraint = Sketch.DimensionConstraints.AddRadius((Inventor.SketchEntity)SketchCircle, TransientGeometry.CreatePoint2d(0, 0), false);
            Sketch.GeometricConstraints.AddCoincident(SketchEntity, (Inventor.SketchEntity)SketchCircle.CenterSketchPoint);

            RadiusDimConstraint = null;
            SketchCircle        = null;
            SketchCircle        = Sketch.SketchCircles.AddByCenterRadius(TransientGeometry.CreatePoint2d(0, 0), DiaID / 2);
            RadiusDimConstraint = Sketch.DimensionConstraints.AddRadius((Inventor.SketchEntity)SketchCircle, TransientGeometry.CreatePoint2d(0, 0), false);
            Sketch.GeometricConstraints.AddCoincident(SketchEntity, (Inventor.SketchEntity)SketchCircle.CenterSketchPoint);
            SketchObjectCollection.Add(SketchCircle);

            Profile           = Sketch.Profiles.AddForSolid(true, SketchObjectCollection);
            ExtrudeDefinition = PartDocument.ComponentDefinition.Features.ExtrudeFeatures.CreateExtrudeDefinition(Profile, Inventor.PartFeatureOperationEnum.kNewBodyOperation);
            ExtrudeDefinition.SetDistanceExtent(Thickness, Inventor.PartFeatureExtentDirectionEnum.kPositiveExtentDirection);

            ExtrudeFeature      = PartDocument.ComponentDefinition.Features.ExtrudeFeatures.Add(ExtrudeDefinition);
            ExtrudeFeature.Name = "FlangeBase";

            return(ExtrudeFeature);
        }
Exemplo n.º 27
0
        // GET: Units/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            UnitsOfMeasure unitsOfMeasure = db.UnitsOfMeasures.Find(id);

            if (unitsOfMeasure == null)
            {
                return(HttpNotFound());
            }
            return(View(unitsOfMeasure));
        }
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        // Use: Return string from API value
        //
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        public static string GetStringFromAPILength(double value)
        {
            try
            {
                UnitsOfMeasure uom = InvApplication.ActiveDocument.UnitsOfMeasure;

                string strValue = uom.GetStringFromValue(value, UnitsTypeEnum.kDefaultDisplayLengthUnits);

                return(strValue);
            }
            catch
            {
                return("*Error*");
            }
        }
Exemplo n.º 29
0
        private static IEnumerable <Vector1D> GetValues(string node, string key, UnitsOfMeasure unit)
        {
            var value = GetValue(node, key);

            if (value == null)
            {
                yield break;
            }

            var format = System.Globalization.CultureInfo.InvariantCulture.NumberFormat;

            foreach (var v in value.Split(','))
            {
                double d = double.Parse(v, format);
                yield return(new Vector1D(d, unit));
            }
        }
Exemplo n.º 30
0
        private void TextBox2_TextChanged(object sender, EventArgs e)
        {
            mUOM = mApp.ActiveDocument.UnitsOfMeasure;

            if (TextBox2.Text.Length > 0) 
            {
                if (mUOM.IsExpressionValid(TextBox2.Text, UnitsTypeEnum.kDefaultDisplayLengthUnits)) 
                {
                    TextBox2.ForeColor = System.Drawing.Color.Black;
                    Button2.Enabled = true;
                }
                else
                {
                    TextBox2.ForeColor = System.Drawing.Color.Red;
                    Button2.Enabled = false;
                }
            }
        }
Exemplo n.º 31
0
        private void TextBox2_TextChanged(object sender, EventArgs e)
        {
            mUOM = mApp.ActiveDocument.UnitsOfMeasure;

            if (TextBox2.Text.Length > 0)
            {
                if (mUOM.IsExpressionValid(TextBox2.Text, UnitsTypeEnum.kDefaultDisplayLengthUnits))
                {
                    TextBox2.ForeColor = System.Drawing.Color.Black;
                    Button2.Enabled    = true;
                }
                else
                {
                    TextBox2.ForeColor = System.Drawing.Color.Red;
                    Button2.Enabled    = false;
                }
            }
        }
Exemplo n.º 32
0
        /// <inheritdoc/>
        public string ToDelimitedString()
        {
            CultureInfo culture = CultureInfo.CurrentCulture;

            return(string.Format(
                       culture,
                       StringHelper.StringFormatSequence(0, 11, Configuration.FieldSeparator),
                       Id,
                       SequenceNumberTestObservationMasterFile.HasValue ? SequenceNumberTestObservationMasterFile.Value.ToString(Consts.NumericFormat, culture) : null,
                       UnitsOfMeasure?.ToDelimitedString(),
                       RangeOfDecimalPrecision != null ? string.Join(Configuration.FieldRepeatSeparator, RangeOfDecimalPrecision.Select(x => x.ToString(Consts.NumericFormat, culture))) : null,
                       CorrespondingSiUnitsOfMeasure?.ToDelimitedString(),
                       SiConversionFactor?.ToDelimitedString(),
                       ReferenceNormalRangeForOrdinalAndContinuousObservations != null ? string.Join(Configuration.FieldRepeatSeparator, ReferenceNormalRangeForOrdinalAndContinuousObservations.Select(x => x.ToDelimitedString())) : null,
                       CriticalRangeForOrdinalAndContinuousObservations != null ? string.Join(Configuration.FieldRepeatSeparator, CriticalRangeForOrdinalAndContinuousObservations.Select(x => x.ToDelimitedString())) : null,
                       AbsoluteRangeForOrdinalAndContinuousObservations?.ToDelimitedString(),
                       DeltaCheckCriteria != null ? string.Join(Configuration.FieldRepeatSeparator, DeltaCheckCriteria.Select(x => x.ToDelimitedString())) : null,
                       MinimumMeaningfulIncrements.HasValue ? MinimumMeaningfulIncrements.Value.ToString(Consts.NumericFormat, culture) : null
                       ).TrimEnd(Configuration.FieldSeparator.ToCharArray()));
        }
Exemplo n.º 33
0
        public double[] FindCenterOfMassOffset(ComponentOccurrence oDoc)
        {
            // Store temporary variables and names
            MassProperties oMassProps = oDoc.MassProperties;

            double[] c = new double[3];

            c[0] = oMassProps.CenterOfMass.X;
            c[1] = oMassProps.CenterOfMass.Y;
            c[2] = oMassProps.CenterOfMass.Z;

            UnitsOfMeasure oUOM = _invApp.ActiveDocument.UnitsOfMeasure;

            for (int k = 0; k < 3; k++)
            {
                c[k] = oUOM.ConvertUnits(c[k], "cm", "m");
            }

            return(c);
        }
Exemplo n.º 34
0
        private void AddFlangeiMateDefinitions(ref Inventor.PartDocument PartDocument, string Dia, string MateNamePrefix, string Offset)
        {
            Inventor.ExtrudeFeature ExtrudeFeature;
            Inventor.UnitsOfMeasure UnitsOfMeasure;
            Inventor.Edge           Edge = null;
            Inventor.EdgeLoops      EdgeLoops;
            double FlangeHoleDiaOD = 0;
            int    Counter         = 0;

            ExtrudeFeature  = PartDocument.ComponentDefinition.Features.ExtrudeFeatures[1];
            UnitsOfMeasure  = PartDocument.UnitsOfMeasure;
            FlangeHoleDiaOD = UnitsOfMeasure.GetValueFromExpression(Dia, Inventor.UnitsTypeEnum.kMillimeterLengthUnits);

            foreach (Inventor.Face Face in ExtrudeFeature.Faces)
            {
                if (Face.SurfaceType == Inventor.SurfaceTypeEnum.kCylinderSurface)
                {
                    Inventor.Cylinder Cylinder;
                    Cylinder = Face.Geometry;
                    if (Cylinder.Radius == FlangeHoleDiaOD / 2)
                    {
                        EdgeLoops = Face.EdgeLoops;
                        foreach (Inventor.EdgeLoop EdgeLoop in EdgeLoops)
                        {
                            if (EdgeLoop.IsOuterEdgeLoop)
                            {
                                foreach (Inventor.Edge mEdge in EdgeLoop.Edges)
                                {
                                    if (mEdge.CurveType == Inventor.CurveTypeEnum.kCircleCurve)
                                    {
                                        Edge = mEdge;
                                        PartDocument.ComponentDefinition.iMateDefinitions.AddInsertiMateDefinition(Edge, false, Offset, null, MateNamePrefix + ":" + Counter.ToString());
                                        Counter++;
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 35
0
 public Vector4D(double x, double y, double width, double height, UnitsOfMeasure unit)
 {
     this.offset = new PDF.Vector2D(x, y, unit);
     this.size = new PDF.Vector2D(width, height, unit);
 }
Exemplo n.º 36
0
 private static Vector2D GetTwo(string node, string key, UnitsOfMeasure unit)
 {
     var values = GetValues(node, key, unit).ToArray();
     return new Vector2D(values[0], values[1]);
 }
Exemplo n.º 37
0
        private static IEnumerable<Vector1D> GetValues(string node, string key, UnitsOfMeasure unit)
        {
            var value = GetValue(node, key);
            if (value == null)
                yield break;

            var format = System.Globalization.CultureInfo.InvariantCulture.NumberFormat;

            foreach (var v in value.Split(','))
            {
                double d = double.Parse(v, format);
                yield return new Vector1D(d, unit);
            }
        }
Exemplo n.º 38
0
 public void MoveTo(double x, double y, UnitsOfMeasure unit)
 {
     MoveTo(
        new Vector1D(x, unit),
        new Vector1D(y, unit));
 }
Exemplo n.º 39
0
 public void Rectangle(double x, double y, double width, double height, UnitsOfMeasure unit)
 {
     Rectangle(
        new Vector1D(x, unit),
        new Vector1D(y, unit),
        new Vector1D(width, unit),
        new Vector1D(height, unit));
 }
Exemplo n.º 40
0
            /// <summary>
            /// Constructs an <c>ImageData</c> object with given parameters.
            /// </summary>
            /// <param name="origFilename">The filename of the image.</param>
            /// <param name="reportFilename">The filename where the Excel report is stored.</param>
            /// <param name="dateTimeFired">The date and time the target was fired upon.</param>
            /// <param name="shooterLName">The shooter's last name.</param>
            /// <param name="shooterFName">The shooter's first name.</param>
            /// <param name="rangeLocation">The location of the range.</param>
            /// <param name="distanceUnits">The units that the distance to target is measured in.</param>
            /// <param name="distance">The distance to the target.</param>
            /// <param name="temperature">The temperature on the range.</param>
            /// <param name="weaponName">The name of the weapon.</param>
            /// <param name="serialNumber">The serial number of the weapon.</param>
            /// <param name="weaponNotes">Notes on the weapon.</param>
            /// <param name="caliber">The units of caliber of the ammunition used.</param>
            /// <param name="caliberValue">The caliber of the ammunition used.</param>
            /// <param name="lotNumber">The lot number of the ammunition.</param>
            /// <param name="projectileMassGrains">The projectile mass in units of grains.</param>
            /// <param name="ammunitionNotes">Notes on the ammunition.</param>
            /// <param name="scale">The scale information for the target.</param>
            /// <param name="shotsFired">The number of shots fired.</param>
            /// <param name="points">A list of points where bullet holes are located.</param>
            /// <param name="roi">The region of interest for the target.</param>
            public ImageData(String origFilename, String reportFilename, DateTime dateTimeFired,
					String shooterLName, String shooterFName, String rangeLocation,
					UnitsOfMeasure distanceUnits, int distance, Temperature temperature,
					String weaponName, String serialNumber, String weaponNotes, CaliberUnit caliber,
					double caliberValue, String lotNumber, int projectileMassGrains,
					String ammunitionNotes, Scale scale, int shotsFired, IList<Point> points, ROI roi)
            {
                this.targetID = -1;
                this.origFilename = origFilename;
                this.reportFilename = reportFilename;
                this.dateTimeFired = dateTimeFired;
                this.shooterLName = shooterLName;
                this.shooterFName = shooterFName;
                this.rangeLocation = rangeLocation;
                this.distanceUnits = distanceUnits;
                this.distance = distance;
                this.temperature = temperature;
                this.weaponName = weaponName;
                this.serialNumber = serialNumber;
                this.weaponNotes = weaponNotes;
                this.caliber = caliber;
                this.caliberValue = caliberValue;
                this.lotNumber = lotNumber;
                this.projectileMassGrains = projectileMassGrains;
                this.ammunitionNotes = ammunitionNotes;
                this.scale = scale;
                this.shotsFired = shotsFired;
                this.points = points;
                this.regionOfInterest = roi;
            }
Exemplo n.º 41
0
 private static Vector1D GetOne(string node, string key, UnitsOfMeasure unit)
 {
     return GetValues(node, key, unit).First();
 }