hexagon logo

Surface Normal Deviation of points in FCF

ok, so here's what i'm trying to do...

i have a profile,

i would like the the surface normal deviation of the points in a table like this


t1 t2 t3 t4
t5 t6 t7 t8

instead of the long table of xyz ijk

i need it from the fcf b/c of the best fitting that has been done

i had tried
ASSIGN/V2 = DOT(SCN1.HIT[1].XYZ-SCN1.HIT[1].TXYZ,SCN1.HIT[1].IJK)


but this doesn't match the fcf deviations as they have been best fit


any ideas?

thanks

-cappy
  • Thank you DJAMS for the original code


    You are most welcome Cappy - you really took the ball and ran with it!
  • Let's simplify this.

    HA! I will now think of you every time I use the DOT() function. (grrr...) Wink


  • here's what i did in c#

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using PCDLRN;
    
    namespace SurfaceNormals
    {
        class Program
        {
            /*
             * This progam generates a report that contains surface normal deviations for a profile dimension
             * in PC-DMIS.
             * 
             * Call this program from your PC-DMIS Part Program using an external command.
             * 
             * Pre-conditions:  PC-DMIS is open
             *                  PC-DMIS Part Program is Running
             *                  A variable exists in the current Part Program named "PROFILE_NAME"
             *                  A Variable exists in the current Part Program named "CUR_ALN"
             *                  A Variable exists in the current Part Program named "OUTHEADER"
             *                  A Variable exists in the current Part Program named "OUT_PATH"
             *                  A Variable exists in the current Part Program namde "PREC"
             *                  A Variable exists in the current Part Program named "NUMCOL"
             * 
             * Post Conditions: A file named <output path>_Surface normal Deviations.txt is created
             * 
             * 
             * Rev 0 - Cappy6124 
             * initial release
             * 
             */
    
            static void Main(string[] args)
            {
    
                IApplication pcdApp = new Application(); //Connect to PC-DMIS
                IPartProgram pcdProg = pcdApp.ActivePartProgram; //Connect to Active Part Program
                /*
                 * The variable "ProfileName" gets the value of the variable "PROFILE_NAME" from PC-DMIS
                 * This is the name of the profile to get the surface normal deviations from.
                 */
                Variable ProfileName = pcdProg.GetVariableValue("PROFILE_NAME");
                /*
                 * Alignment name is the name of the alignment that the SND are relative to.
                 * This value comes from the PC-DMIS variable "CUR_ALN"
                 */
                Variable AlignmentName = pcdProg.GetVariableValue("CUR_ALN");
                /*
                 *outHeader is the Header of the Surface Normal Deviations that will be output
                 *Example: "Surface Normal Deviations for CW Hub Spline from TE to LE"
                 *This value comes from PC-DMIS
                 */
                string outHeader = pcdProg.GetVariableValue("OUTHEADER").StringValue;
                /*
                 * outPath is the out put file name supplied by the PC-DMIS variable "OUT_PATH"
                 * "_Surface normal Deviations.TXT" is appended to this string.
                 */
                string outPath = pcdProg.GetVariableValue("OUT_PATH").StringValue+"_Surface Normal Deviations.txt";
    
                System.IO.FileStream outFS; //Check to see if output file exists
                if (System.IO.File.Exists(outPath))
                {
                    //if the output file does exist, append to it.
                    outFS = new System.IO.FileStream(outPath, System.IO.FileMode.Append, System.IO.FileAccess.Write);
                }
                else
                {
                    //if the output file does not exist, create it.
                    outFS = new System.IO.FileStream(outPath, System.IO.FileMode.OpenOrCreate, System.IO.FileAccess.Write);
                }
    
                System.IO.StreamWriter outSW = new System.IO.StreamWriter(outFS);//create a streamwriter
    
                Console.WriteLine(ProfileName.StringValue); //write the name of the profile for debugging
    
                //get the profile dimension command
                DimensionCmd dCmd = pcdProg.Commands.Item(ProfileName.StringValue).FCFCommand.ProfileDimension;
                
                //get the deviations from the profile command
                double[] d = dCmd.GetProfilePointInfos(ENUM_POINT_INFO_TYPES.DEVIATION_INFO, FDATA_COORDSYS.FDATA_PART, AlignmentName.StringValue);
    
                //create the output string
                string outString = "";
                /*
                 * prec is the PC-DMIS value of "PREC", this is the number of places after the decimal
                 */
                int prec = Convert.ToInt32(pcdProg.GetVariableValue("PREC").StringValue);
    
                //numcol is the number of columns to output
                int numCol = Convert.ToInt32(pcdProg.GetVariableValue("NUMCOL").StringValue);
                //format string is the format to output your values
                //it starts as " 0." -> if it is positive, put a space infront of the number
                string formatString = " 0.";
    
                //add the correct number of places to the format string
                //example if prec == 3 then format string == " 0.000"
                for (int i = 0; i < prec; i++)
                {
                    formatString = formatString + "0";
                }
    
                //add the condition for negative numbers (apply a "-" for a negative number to
                //the beginning of the number
                formatString=formatString+";-0.";
    
                //add the correct numbe of places for the negative condition
                for (int i = 0; i < prec; i++)
                {
                    formatString = formatString + "0";
                }
    
                //foreach deviation 
                for (int i = 0; i <= d.GetUpperBound(0); i++)
                {
                    //if the remainder of i/number of columns = 0 and i>0
                    if (i % numCol == 0 && i > 0)
                    {
                        //add a new line to the output string
                        outString = outString + Environment.NewLine;
                    }
                    //add the current deviation to the output string with some spaces for clarity
                    outString = outString + d[i].ToString(formatString) + "     ";
                }
                
                //write the header
                outSW.WriteLine(outHeader);
                //write the ouput string
                outSW.WriteLine(outString);
                //flush the stream
                outSW.Flush();
                //close the stream
                outFS.Close();
            }
        }
    }
    



    Use the variables listed at the top of the program in PC-DMIS to supply info to the program
    then immediately after those variables call the external program.

    it only takes about .5 seconds to execute


    ***edit****
    Thank you DJAMS for the original code


    Not sure how to execute this since it's in C#. Do I just save it with a .bas extension and call the script from within PCD like a VB script?