Esempio n. 1
0
 /// <summary>
 /// Suits Pipe  Converts Expression (e.g 21 mm, 21 )To Model World Units As Set By user,
 /// </summary>
 /// <param name="PartDocument">Inventor Part/Assembly Document Object As Referance</param>
 /// <param name="UnitsType">As Inventor UnitsTypeEnum</param>
 /// <param name="szDiaOD">Outside Diameter, Expression As String</param>
 /// <param name="szLength">The Inside Diameter, Expression As String</param>
 /// <param name="szThickness">Thickness Of The Object, Expression As String</param>
 /// <param name="DiaOD">Outside Diameter, Model World Value Out As double</param>
 /// <param name="Length">The Inside Diameter, Model World Value Out As double</param>
 /// <param name="Thickness">Thickness Of The Object, Model World Value Out As double</param>
 /// <returns>returns true if input validated, returns false if one Expression Fails Sets all out Vals to 0.</returns>
 public static bool ConvertPipeDiamensionsToModelWorldUnits(
     ref Inventor.PartDocument PartDocument,
     Inventor.UnitsTypeEnum UnitsType,
     string szDiaOD,
     string szThickness,
     string szLength,
     out double DiaOD,
     out double Thickness,
     out double Length)
 {
     DiaOD = 0; Length = 0; Thickness = 0;
     Inventor.UnitsOfMeasure UnitsOfMeasure = PartDocument.UnitsOfMeasure;
     UnitsOfMeasure.LengthUnits = UnitsType;
     if (UnitsOfMeasure.IsExpressionValid(szDiaOD, Inventor.UnitsTypeEnum.kDefaultDisplayLengthUnits) &&
         UnitsOfMeasure.IsExpressionValid(szLength, Inventor.UnitsTypeEnum.kDefaultDisplayLengthUnits) &&
         UnitsOfMeasure.IsExpressionValid(szThickness, Inventor.UnitsTypeEnum.kDefaultDisplayLengthUnits))
     {
         DiaOD     = UnitsOfMeasure.GetValueFromExpression(szDiaOD, Inventor.UnitsTypeEnum.kDefaultDisplayLengthUnits);
         Length    = UnitsOfMeasure.GetValueFromExpression(szLength, Inventor.UnitsTypeEnum.kDefaultDisplayLengthUnits);
         Thickness = UnitsOfMeasure.GetValueFromExpression(szThickness, Inventor.UnitsTypeEnum.kDefaultDisplayLengthUnits);
         return(true);
     }
     else
     {
         return(false);
     }
 }
Esempio n. 2
0
        private void btnTest_Click(object sender, EventArgs e)
        {
            Inventor.PartDocument  PDoc  = (Inventor.PartDocument)InvApp.ActiveDocument;
            Inventor.UnitsTypeEnum units = Inventor.UnitsTypeEnum.kMillimeterLengthUnits;
            CFlange flange = new CFlange(ref InvApp, ref PDoc, ref units, "XY", "300", "150", "30", "200", "18", "8");

            flange.Extrude_FlangeBody();
        }
Esempio n. 3
0
 /// <summary>
 /// Suits Flat Faced Flanges String Expression e.g 21 mm, 21, To Model World Units, Set By User.
 /// </summary>
 /// <param name="PartDocument">Inventor Part/Assembly Document Object As Referance</param>
 /// <param name="UnitsType">As Inventor UnitsTypeEnum</param>
 /// <param name="szDiaOD">Outside Diameter, Expression As String</param>
 /// <param name="szDiaID">Inside Diameter, Expression As String</param>
 /// <param name="szThickness">Thickness Of The Object, Expression As String</param>
 /// <param name="szPCD">Placed Center Diameter, Expression As String</param>
 /// <param name="szBoltHoleDia">Bolt Hole Diameter,  Expression As String</param>
 /// <param name="szDia">Bolt Hole Diameter, Expression As String</param>
 /// <param name="szNumber">Number Of Bolt Holes In PCD, Expression As String</param>
 /// <param name="DiaOD">Outside Diameter, Model World Value, Out As double</param>
 /// <param name="DiaID">The Inside Diameter, Model World Value, Out As double</param>
 /// <param name="Thickness">Thickness Of The Object, Model World Value, Out As double</param>
 /// <param name="PCD">Placed Center Diameter, Model World Value, Out As double</param>
 /// <param name="Dia">Bolt Hole Diameter, Model World Value, Out As double</param>
 /// <param name="Number">Number Of Bolt Holes In PCD, Model World Value, Out As double</param>
 /// <returns>returns true if input validated, returns false if one Expression Fails Sets all out Vals to 0.</returns>
 public static bool ConvertFlatFacedFlangeDimsToModelWorldUnits(
     ref Inventor.PartDocument PartDocument,
     ref Inventor.UnitsTypeEnum UnitsType,
     string szDiaOD,
     string szDiaID,
     string szThickness,
     string szPCD,
     string szBoltHoleDia,
     string szNumber,
     out double DiaOD,
     out double DiaID,
     out double Thickness,
     out double PCD,
     out double Dia,
     out double Number)
 {
     DiaOD = 0; DiaID = 0; Thickness = 0; PCD = 0; Dia = 0; Number = 0;
     Inventor.UnitsOfMeasure UnitsOfMeasure = PartDocument.UnitsOfMeasure;
     UnitsOfMeasure.LengthUnits = UnitsType;
     if (UnitsOfMeasure.IsExpressionValid(szDiaOD, Inventor.UnitsTypeEnum.kDefaultDisplayLengthUnits) &&
         UnitsOfMeasure.IsExpressionValid(szDiaID, Inventor.UnitsTypeEnum.kDefaultDisplayLengthUnits) &&
         UnitsOfMeasure.IsExpressionValid(szThickness, Inventor.UnitsTypeEnum.kDefaultDisplayLengthUnits) &&
         UnitsOfMeasure.IsExpressionValid(szPCD, Inventor.UnitsTypeEnum.kDefaultDisplayLengthUnits) &&
         UnitsOfMeasure.IsExpressionValid(szBoltHoleDia, Inventor.UnitsTypeEnum.kDefaultDisplayLengthUnits) &&
         UnitsOfMeasure.IsExpressionValid(szNumber, Inventor.UnitsTypeEnum.kDefaultDisplayLengthUnits))
     {
         DiaOD     = UnitsOfMeasure.GetValueFromExpression(szDiaOD, Inventor.UnitsTypeEnum.kMillimeterLengthUnits);
         DiaID     = UnitsOfMeasure.GetValueFromExpression(szDiaID, Inventor.UnitsTypeEnum.kMillimeterLengthUnits);
         Thickness = UnitsOfMeasure.GetValueFromExpression(szThickness, Inventor.UnitsTypeEnum.kMillimeterLengthUnits);
         PCD       = UnitsOfMeasure.GetValueFromExpression(szPCD, Inventor.UnitsTypeEnum.kMillimeterLengthUnits);
         Dia       = UnitsOfMeasure.GetValueFromExpression(szBoltHoleDia, Inventor.UnitsTypeEnum.kMillimeterLengthUnits);
         Number    = UnitsOfMeasure.GetValueFromExpression(szNumber, Inventor.UnitsTypeEnum.kUnitlessUnits);
         return(true);
     }
     else
     {
         return(false);
     }
 }
Esempio n. 4
0
 /// <summary>
 /// Helper Convert Basic Dims Width, Height, Length, Thickness, Number Unit Type
 /// </summary>
 /// <param name="PartDocument">Inventor Part/Assembly Document Object As Referance</param>
 /// <param name="szWidth">Width Diamension, Expression As String</param>
 /// <param name="szHeight">Height Diamension, Expression As String</param>
 /// <param name="szLength">Length Diamension, Expression As String</param>
 /// <param name="szThickness">Thickness Diamension, Expression As String</param>
 /// <param name="szQty">Number Of Diamension, Expression As String</param>
 /// <param name="Width">Width, Model World Value, Out As double</param>
 /// <param name="Height">Height Diamension, Model World Value, Out As double</param>
 /// <param name="Length">Length Diamension, Model World Value, Out As double</param>
 /// <param name="Thickness">Thickness Diamension, Model World Value, Out As double</param>
 /// <param name="Qty">Number Or Qty Of Diamension, Model World Value, Out As double</param>
 private static void ConvertBaseObjectDims(
     ref Inventor.PartDocument PartDocument,
     ref Inventor.UnitsTypeEnum UnitsType,
     string szWidth,
     string szHeight,
     string szLength,
     string szThickness,
     string szQty,
     out double Width,
     out double Height,
     out double Length,
     out double Thickness,
     out double Qty)
 {
     Width = 0; Height = 0; Length = 0; Thickness = 0; Qty = 0;
     Inventor.UnitsOfMeasure UnitsOfMeasure = PartDocument.UnitsOfMeasure;
     UnitsOfMeasure.LengthUnits = UnitsType;
     Width     = UnitsOfMeasure.GetValueFromExpression(szWidth, Inventor.UnitsTypeEnum.kDefaultDisplayLengthUnits);
     Height    = UnitsOfMeasure.GetValueFromExpression(szHeight, Inventor.UnitsTypeEnum.kDefaultDisplayLengthUnits);
     Length    = UnitsOfMeasure.GetValueFromExpression(szLength, Inventor.UnitsTypeEnum.kDefaultDisplayLengthUnits);
     Thickness = UnitsOfMeasure.GetValueFromExpression(szThickness, Inventor.UnitsTypeEnum.kDefaultDisplayLengthUnits);
     Qty       = UnitsOfMeasure.GetValueFromExpression(szQty, Inventor.UnitsTypeEnum.kUnitlessUnits);
 }
Esempio n. 5
0
        private static bool IsUnitExprssionValid(ref Inventor.UnitsOfMeasure UnitsOfMeasure, ref Inventor.UnitsTypeEnum UnitsType, string szExpression)
        {
            if (UnitsOfMeasure.IsExpressionValid(szExpression, UnitsType))
            {
                return(false);
            }

            return(true);
        }
Esempio n. 6
0
        //Single Call multi add
        private void SetUserParameters(ref Inventor.PartDocument PartDocument, NameValueCollection ParameterNameValues, Inventor.UnitsTypeEnum units)
        {
            Inventor.UserParameter m_UserParameter;

            Collection <string> ParameterNameCach = new Collection <string>();

            if (PartDocument.ComponentDefinition.Parameters.UserParameters.Count == 0)  //Add from Scratch userPars
            {
                foreach (string namedParameter in ParameterNameValues.Keys)
                {
                    m_UserParameter = PartDocument.ComponentDefinition.Parameters.UserParameters.AddByExpression(namedParameter, ParameterNameValues[namedParameter], units);
                    m_UserParameter.ExposedAsProperty = true;
                }
            }
            else
            {
                foreach (Inventor.UserParameter up in PartDocument.ComponentDefinition.Parameters.UserParameters)
                {
                    ParameterNameCach.Add(up.Name);
                }

                foreach (string namedParameter in ParameterNameValues.Keys)
                {
                    if (!ParameterNameCach.Contains(namedParameter))
                    {
                        m_UserParameter = PartDocument.ComponentDefinition.Parameters.UserParameters.AddByExpression(namedParameter, ParameterNameValues[namedParameter], units);
                        m_UserParameter.ExposedAsProperty = true;
                    }
                    else
                    {
                        Inventor.UserParameter _UserParameter;
                        _UserParameter            = PartDocument.ComponentDefinition.Parameters.UserParameters[namedParameter];
                        _UserParameter.Expression = ParameterNameValues.Get(namedParameter) + "mm";
                        _UserParameter.CustomPropertyFormat.ShowTrailingZeros = false;
                        _UserParameter.CustomPropertyFormat.ShowUnitsString   = false;
                        _UserParameter.CustomPropertyFormat.Precision         = Inventor.CustomPropertyPrecisionEnum.kOneDecimalPlacePrecision;
                        _UserParameter.ExposedAsProperty = true;
                    }
                }
            }
            Inventor.PropertySet m_Propertyset = PartDocument.PropertySets["{32853F0F-3444-11D1-9E93-0060B03C1CA6}"];
            Inventor.Property    m_Property    = m_Propertyset["Description"];
            m_Property.Expression = "=<Material> <Length>X<Width>X<Thickness>";
        }
Esempio n. 7
0
        //Single Call and add
        private void SetUserParameters(ref Inventor.PartDocument PartDocument, string UserParameterName, string ParameterValue, Inventor.UnitsTypeEnum units)
        {
            bool found = false;

            Inventor.UserParameter m_UserParameter;
            foreach (Inventor.UserParameter UserParameter in PartDocument.ComponentDefinition.Parameters.UserParameters)
            {
                if (UserParameter.Name == UserParameterName)
                {
                    found = true;
                    UserParameter.Expression        = ParameterValue + "mm";
                    UserParameter.ExposedAsProperty = true;
                    break;
                }
            }

            if (!found)
            {
                m_UserParameter = PartDocument.ComponentDefinition.Parameters.UserParameters.AddByExpression(UserParameterName, ParameterValue, units);
                m_UserParameter.ExposedAsProperty = true;
            }
        }
Esempio n. 8
0
 public CFlange(ref Inventor.Application InvApplication, ref Inventor.PartDocument invPartDocument, ref Inventor.UnitsTypeEnum UnitsType, string szworkplanename, string szDiaOD, string szDiaID, string szThickness, string szPCD, string szBoltHoleDia, string szNumberBoltHoles)
 {
     szWorkPlaneName = szworkplanename;
     InvApp          = InvApplication;
     PartDocument    = invPartDocument;
     CToModelValue.ConvertFlatFacedFlangeDimsToModelWorldUnits(ref PartDocument, ref UnitsType, szDiaOD, szDiaID, szThickness, szPCD, szBoltHoleDia, szNumberBoltHoles, out FlangeDiaOD, out FlangeDiaID, out FlangeThickness, out FlangePlacedCenterDiameter, out FlangeBoltHoleDia, out FlangeNumberBoltHoles);
 }