Using The Get... Commands

The commands described in this section are the ones you can access when using scripting language  Editor and right-clicking in the Editor window. 

When writing a script containing the path of a feature contained in the specification tree, it is highly recommended to use the Get Feature command to retrieve the internal name of this feature.
 

The 'Get Axis' Command   

This task explains how to create a chamfer by using the Get Axis command. This command enables you to interactively capture the generic name of an axis and to insert it into the script instead of keying it in.
  1. Access the Product Knowledge workbench, and open the Script Editor.

  2. Enter the following script and click Generate. A pad is created.

    myChamferDocument isa CATPart
    {
             myPart isa Part
             {
                        PartBody isa BodyFeature
                        {
                                 P isa Pad
                                 {
                                 }

                        }
             }
    }

  3. Under the P isa Pad block, add F isa Chamfer, right-click and select Get Axis, and select an edge in your geometrical surface. The script must be as follows: 

    myChamferDocument isa CATPart
    {
             myPart isa Part
             {
                        PartBody isa BodyFeature
                        {
                              P isa Pad
                              { 
                              }
                              F isa Chamfer("Edge:(Face:(Brp:(P;0:(Brp:(Sketch.1;2)));
                              None:());Face:(Brp:(P;0:(Brp:(Sketch.1;3)));None:());
                              None:(Limits1:();Limits2:()))"){}
                        }
              }

    }

  4. Click Generate. The chamfer is created.

The "Get Edge" Command  

This task explains how to create a chamfer by using the Get Edge command. This command enables you to interactively capture the generic name of an edge and to insert it into the script instead of keying it in. 
  1. Access the Product Knowledge Template workbench, and open the Script Editor.

  2. Enter the following script and click Generate. A pad is created.

    myChamferDocument isa CATPart
    {
             myPart isa Part
             {
                        PartBody isa BodyFeature
                        {
                                 P isa Pad
                                 {
                                 }

                        }
             }
    }
  3. Under the P isa Pad block, add F isa Chamfer, right-click and select Get Edge, and select an edge in your geometrical surface. The script must be as follows: 

    myChamferDocument isa CATPart
    {
             myPart isa Part
             {
                        PartBody isa BodyFeature
                        {
                            P isa Pad
                            { }
                            F isa Chamfer("Edge:(Face:(Brp:(P;0:(Brp:(Sketch.1;2)));
                            None:());Face:(Brp:(P;2);None:());None:(Limits1:();Limits2:()))"){}
                        }
             }
    }
  4. Click Generate. The chamfer is created.

The "Get Surface" Command   

This task explains how to create a sketch on an existing face by using The Get Surface command. This command enables you to interactively capture the generic name of a surface and to insert it into the script instead of keying it in. 
  1. Open the PktGetSurface.CATPart file.

  2. Access the Product Knowledge Template workbench, and open the Script Editor. Enter the following script:

    import "f:\cube.CATPart";
    myFaceDocument isa CATPart
    {
             myPart isa Part
             {
                     PartBody isa BodyFeature
                     {
                     P isa Pad{}
                     S isa Sketch.1()
  3. Position the cursor between the two parentheses of the last line of the above script, right-click and select Get Surface.

  4. Select the face whose name you want to capture. The full name is inserted at the cursor location. Enter the end of your script. In our example, the final script is as follows: 

    import "f:\PktGetSurface.CATPart";
    myFaceDocument isa CATPart
    {
             myPart isa Part
             {
                  PartBody isa BodyFeature
                  {
                  P isa Pad{}
                  S isa Sketch.1("Face:(Brp:(P;0:(Brp:(Sketch.1;2)));None:())")
                  {
                  }
                  }
             }
    }
  5.  

The "Get Feature" Command   

This task explains how to create a sketch on an existing face by using The Get Surface command. This command enables you to interactively capture the generic name of a surface and to insert it into the script instead of keying it in. 
  1. Open the PktGetFeature.CATPart file.

  2. Access the Product Knowledge Template workbench, and click the Create a Generative Script icon.

  3. In the editor, select File > Open, and select the PktGetFeature.CATGScript file.

  4. Position the cursor after FirstPoint = object:, right-click and select Get Feature.

  5. Select a point in the geometry and add a semi-colon (;) at the end of the line.

  6. Position the cursor after SecondPoint = object:, right-click and select Get Feature.

  7. Select another point in the geometry and add a semi-colon (;) at the end of the line. Your script must now look like the one below:

 

  1.   Click Generate. The line is created.

The "Insert File Path" Command  

This task explains how to use the Insert File Path command. This command is one of the methods you can use to specify a path in a script. 
  1. Access the Script Editor and enter any instruction requiring a file path specification (import in the example below).

  2. Position the cursor where the path is to be specified.

  3. Right-click and select Insert File Path.

     
  4. In the dialog box which is displayed, select the appropriate file. Click Open to go back to the script editor.

  5. The full path is inserted at the cursor place.  Check that the statement is ended by a semi-colon.