Getting the value of a parameter in a part

Top  Previous  Next

Here you go:

 

        public static double GetPartMmParam (PartComponentDefinition PartDef,

                                             ParamType_e eParamType,

                                             string sParamName)

        {

            if (PartDef == null)

            {

                AutoBatSupp.Log.WriteLn(CLog.Type_e.ekErr,"SetAsmParam null AsmDef  (" + sParamName + ")" + eParamType.ToString());

                return 0.0 ;

            }

            if (!PartCompDefHasParam(PartDef, eParamType, sParamName))

            {

                AutoBatSupp.Log.WriteLn(CLog.Type_e.ekErr,"Assembly does not have parameter <" + sParamName + ">, " + eParamType.ToString());

                return 0.0;

            }

 

            // This will become a User or Model Parameter 

            Parameter Param = null;

 

            if (eParamType == ParamType_e.ekModel)

            {

                ModelParameters ModelParams = PartDef.Parameters.ModelParameters;

                ModelParameter ThisParam = ModelParams[sParamName];

                Param = (Parameter)ThisParam;

            }

            else if (eParamType == ParamType_e.ekUser)

            {

                UserParameters ModelParams = PartDef.Parameters.UserParameters;

                UserParameter ThisParam = ModelParams[sParamName];

                Param = (Parameter)ThisParam;

            }

 

            return (double)Param.Value * 10.0;

        }

 

 

Text, images and diagrams © 2021 Owen F. Ransen. All rights reserved. (But copy the source code as much as you want!)