nanoCAD Platform Help

Object - centre holes GOST 14034-74

Example of object

Source graphic

Table

SVersion = 2; // The first line of the script determines the version of the interpreter
// Description. It will be displayed in the Properties pane
// You can also sort the objects in the field
// Tabular data and mcqs
ObjectDescription = "center hole";
 
// This is the function description of the object
function ActHeader {
  NPart = 2; // The number of requests to a dynamic selection of parameters
 
  // This section contains descriptions of the parameters open object
  // Visible to other objects
  Public (
    // Define the parameter size hole - the diameter
    d, "diameter",
   
    // Plane to install, depending on the shaft end
    WP1, "the beginning of the plane"
   
    rValType, "Shaft Type" // Type of shaft, which connect the hole
              // Set for overlap on
              // Kinds and with a cut without cutting
   
    Lhole, "The depth of the holes," // This is the total hole depth
    Lthread, "Thread length" parameter // length thread
    // Parameters specific performances
    DF, "shaft diameter to form F",
    DH, "The diameter of the shaft to form H"
  );
  // Private parameters used to plot
  // And calculate the limits of other parameters
  Protected (seted, freeLen, bBlind, rSuppressPointHeight);
 
  // This section lists the parameters of the open,
  // Which will be accessible from the outside for editing
  // This is only classified as specific actions under
  // Changing the parameters of external functions defined in
  // OnChangeParameters
  Changeable (d, WP1, DF, DH, rValType, Lhole, Lthread);
 
  // Show dialog box to insert dynamic selection parameters
  OnDlgBeforeSelectParam = 1;
  // Do not regenerate suppression circuit after insertion
  ContourOnLine = 0;
  // This is the part of the shaft member
  IsAValPart = 1;
  // And a built-in part of the shaft
  InsidePart = 1;
 
  // This element - opening (this variable is used to
  // Dimensioning in Inventor)
  IsAHole = 1;
};
 
// Initialize the object parameters
function OnInitialization {
  // Load the table into the cache
  // Parameters table of the current line in the script is always available
  // Therefore loaded only one parameter d
  LoadInCache (d);
  // Variable seted is the default value UnknownValue
  // As initialized with this value
  // So, if we put the following test, this unit
  // Operators will be executed only once:
  if (seted == UnknownValue) {
    seted = 1; // Set seted 1 to the condition is not fulfilled
       // Again
   
    // Set initial values
    rValType = 1; // The hole is placed on the shaft portion
    rZOrder = 4220; // Ranking - initial value of
   
    // Select from a table initial values
    SelectInCache ("kFirst", "Form", "~", "FH", "d", "~", 10);
    //T.e. according to the syntax of the operator - selected the first record
    // Table where Form parameter is "FH", and a parameter
    // Hole diameter d is approximately equal to 10
   
    // Set, pursuant to which the object will be initially
    // Displays
    strDesignName = "Form F";
   
    // Set the initial value of arbitrary parameters
    Lhole = 30; // The length of the hole
    Lthread = Lhole-d / 2; // This is the minimum possible length of the thread
   
    // The variable that determines whether the hole deaf.
    // Default - blind.
    bBlind = TRUE;
   
    // This variable determines the value of the parameter is relative to
    // Height of the end point of the cone of suppression. (See the drawing)
    rSuppressPointHeight = tg (30) * (d-1.082 * p) / 2;
  };
};
 
// Setting function handles
function SetGripPoint {
  NGrip = 3; // Total 3 pens
 
  pntGrip0 = pntOrigin; // The first - at the insertion point
 
  // The second handle - the handle length of the threaded portion
  pntGrip1 = pntOrigin + vecDirection * Lthread;
 
  // Third handle - handle is the total length of the hole
  pntGrip2 = pntOrigin + vecDirection * Lhole;
};
 
 
 
// This function determines the reaction of the object on the movement of the handles
function OnMoveGripPoint {
// Here comes the variable NMovingGrip, equal to the index with a slide
// Handle the numbering of the array starts from zero.
 
  // When editing the first handle just move the item to
  // Where the cursor is with this pen. Ie move the insertion point
  // Where is the first pen
  if (NMovingGrip == 0) {
    pntOrigin = pntGrip0;
  };
 
  // This we stretch the length of the (second pen)
  // This defines the length of the threaded portion, depending on the current
  // Execution of holes
  if (NMovingGrip == 1) {
   
    // Determine the distance stretching as vector length,
    // Defines a point ruchki1 and ruchki0
    rDistance = vecLen (pntGrip1-pntGrip0);
   
    // For the execution (shaped hole) "P"
    if (Form == "P") {
     // The length of the thread should be limited to reduce the amount of
     // (L-d / 2). Obviously, the length parameter thread Lthread
     // Will be set to the relative position of the cursor
     // If it is greater than (L-d / 2).
     Lthread = max (rDistance, L-d / 2);
    };
   
    // For the execution of "F H"
    if (Form == "F H") {
     // The same goes for the execution of the thread length must be
     // Size is bounded below by (l + d / 2).
     Lthread = max (rDistance, l + d / 2);
    };
   
    // Finally, in this condition, we limit the length of the thread
    // On, since the length of the thread can not be more
    // The length of the hole. Therefore, we will pull out all the hole
    // According to the new diameter of the thread.
    if (Lthread > Lhole-d / 2) {
     //T.e. when you change the length greater than the length of the thread holes
     // Set the new length of the holes equal
     // Thread length plus half the diameter
     Lhole = Lthread + d / 2;
    };
  };
 
  // This section examines the movement of the third handle.
  // The result of editing it is increasing the length of the hole,
  // Without affecting the thread.
  if (NMovingGrip == 2) {
   
    // In this case, the current distance is defined as
    // Length of the vector formed by dots and ruchki0 ruchki2
    rDistance = vecLen (pntGrip2-pntGrip0);
   
    // For the execution of "P"
    if (Form == "P") {
     // The length of the hole is limited below the parameter L
     Lhole = max (rDistance, L);
    };
   
    // Dlyaispolneniya "F H"
    if (Form == "F H") {
     // Length of the restricted orifice parameters (l + d)
     Lhole = max (rDistance, l + d);
    };
   
    // If you change the length of the hole is less than the length of the thread
    // Move thread abroad
    if (Lhole > Lthread + d / 2) {
     // That is, if the length of the opening is smaller than Lthread + d / 2,
     // Recalculate the new thread length which is less than
     // Current length of the holes in the d / 2
     Lthread = Lhole-d / 2;
    };
  };
 
};
 
// Function of the final calculation of parameters
function OnMakeParameters {
  // Name, surname and patronymic of the object
  strTheName = "CenterHole"; // Centering Hole
  strTheType = "ArborParts"; // Refers to detail shafts
  strTheSubType = "Simple"; // Type of opening - easy
 
  // Set the position of the plane WP1. It's just a plane
  // The base point at the insertion point and a normal vector,
  // Coincides with the vector direction of insertion
  WP1 = Plane (pntOrigin, vecDirection);
 
  // Realize the overlap for different occasions:
  // If the variable rValType, specifying the type section of the shaft, at the
  // Set that the hole is equal to 1 (this is a simple
  // Portion of the shaft), the order of the overlap is equal to 4220
  // (This number is given on the basis of the values ??of the order of
  // Portions of the shaft, so that the hole overlaps the shaft to its
  // Loop suppression
  if (rValType == 1) rZOrder = 4220;
  // For internal shaft portions and other portions where rValType not equal to 1
  else rZOrder = 2150;
  // The sequence will be different
 
 
  // This parameter constraints are found, depending on the version
  // For the execution of "P", more precisely, for the current record in the table,
  // Form that meets the hole "P".
  if (Form == "P") {
    // Limits the length of the holes parameter L
    Lhole = max (Lhole, L);
    // Limits the length of the thread parameter (Ld / 2)
    Lthread = max (Lthread, L-d / 2);
   
    // Define strDesignName in "Form P"
    //t.e. choose what the two-dimensional design, which corresponds to
    // The current parameters of the table
    strDesignName = "Form P";
  };
 
  // The same goes for the form "F H"
  if (Form == "F H") {
 
    // Limit the parameters of the holes and the length of the thread length
    Lhole = max (Lhole, l + d);
    Lthread = max (Lthread, l + d / 2);
   
    // This reassurance, if it does the user chose
    // Execution "P" in the two-dimensional forms, since the table
    // Exhibited parameter value in Form "FH".
    // In general, if you select the wrong version, the set
    // First correct.
    if (strDesignName == "Form P") {
     strDesignName = "Form F";
    };
  };
 
  // Limiting the length of the thread from the top, depending on the
  // Total length of the hole
  Lthread = min (Lthread, Lhole-d / 2);
 
  // The holes form P always deaf
  if (Form == "P") {bBlind = TRUE;};
 
  // This is to ensure that the correct path is drawn suppression
  // The schedule has a contour suppression, the position of one of the points
  // Which is specified by rSuppressPointHeight
  // So as to whether the user has selected the display
  // Blind or through-hole, set the parameter
  // RSuppressPointHeight desired value
  if (bBlind == TRUE) {// For blind hole
    rSuppressPointHeight = tg (30) * (d-1.082 * p) / 2;
  } Else {// For the through-hole (ie, not from the cone drill)
    rSuppressPointHeight = 0;
  };
 
  // This line simply sets specifications
  // Depending on the version adds the necessary letter
  // To the designated holes.
  if (strDesignName == "Form F") {strLetterForm = "F";};
  if (strDesignName == "FormaH") {strLetterForm = "H";};
  if (strDesignName == "FormaP") {strLetterForm = "P";};
 
  // Parameter strPartName - a string specification holes.
  // In addition, he also displayed hinte.
  strPartName = "Ed. Center." + strLetterForm + "M" + d + "GOST14034-74";
  // Format string automatically, ie
  // When adding a string value with
  // Numerical value is automatically converted to a string
};
 
// This function determines the type of dialogue the insertion hole
function OnDialog {
  // Load the parameters of the cache work table
  LoadInCache (d);
  // Call the dialogue with the key
  UniDialog (
    // This defines the fields of the table hole
    // The shape and diameter. Output as a table defining the parameters
    DBFLD, Form, d,
    // The diameter of the shaft to form F and Form H
    // Output only as reference parameters
    DBINF, DF, DH,
    // Parameters asked randomly (subject to restrictions, of course)
    // Display on the Properties tab
    VFLD,
     Lthread, "thread depth"
     Lhole, "The depth of the hole"
    // Tag blind or through hole
    // Display on the properties tab in the form of a tick
    BFLD,
     bBlind, "Deaf"
    // Choices performances. Displays all performance
    VIDS, strDesignName, "All",
    // Displays all recognized types
    TVIDS, lViewType, "All",
    // Displays preview
    VIEW, "Vids"
  );
};
 
// This function is performed before the dynamic selection of the parameters
function OnInitSelect {
  // This function comes variable rPart - sequence number
  // Prompt you to choose the dynamic parameters. counting begins at 0
  if (rPart == 0) {
    // For the first case indicate the diameter of the thread
    // Output a corresponding hint
    strPromt = "Enter the depth of the thread";
  };
  if (rPart == 1) {
    // For the second case indicates the depth of the hole (it zhe
    // Total length).
    strPromt = "Enter the hole depth";
  };
};
 
// This function defines the behavior of the object in the dynamic selection of the parameters
function OnSelectParam {
  // For the first cycle of selection parameters. In principle, the limitations
  // The same as for the handles.
  // These variables come rXcoord and rYcoord - relative
  // Abscissa and ordinate of the cursor
  if (rPart == 0) {
 
    // Parameter range is determined
    // Module relative abscissa
    rDistance = Abs (rXcoord);
   
    // Limitations on choice of parameters depending on the version
    if (Form == "P") {
     Lthread = max (rDistance, L-d / 2);
    };
    if (Form == "F H") {
     Lthread = max (rDistance, l + d / 2);
    };
    if (Lthread > Lhole-d / 2) {
     Lhole = Lthread + d / 2;
    };
  };
 
  // For the second request
  if (rPart == 1) {
 
    // Parameter distance
    rDistance = Abs (rXcoord);
   
    // Restrictions.
    if (Form == "P") {
     Lhole = max (rDistance, L);
    };
    if (Form == "F H") {
     Lhole = max (rDistance, l + d);
    };
    if (Lhole < Lthread + d / 2) {
 Lhole = Lthread + d / 2;
 };
 };
};

// This function is performed when the parameters in the dialog insert
function OnDialogChanged {
// Function adds interactivity in the form of dialogue.
// In this case we need to hide execution and daw "deaf"
 
// Operator ShowDesign hides or displays performance.
// Depending on the value of the first parameter (1 - Shows
// 0 - hides.
// Operator ShowBool ??hides and displays switches (tick)

// For a start, execution and show all daw
ShowDesign (1 "Form F");
ShowDesign (1, "Form H");
ShowDesign (1 "FormaP");
ShowBool ??(1, "deaf");

// If you choose such a line in the table where d3 is 0,
// It is necessary to hide the performance of "Form H". (As defined in the guest,
// That the performance is not used for such values
// Settings
if (d3 == 0) ShowDesign (0, "Form H");

// If the selected row corresponding to the shape of the hole "P", then
// To hide the other two performance (they can not be selected)
// And daw "blind" because the shape of P is always blind.
if (Form == "P") {
ShowDesign (0, "FormaH");
ShowDesign (0, "FormaF");
ShowBool ??(0, "deaf");
};

// But for the chosen form of "FH", you need only to hide
// Execution "Form F"
if (Form == "F H") {
ShowDesign (0, "Form P");
};
};

// Function OnChangeParameters performed under external influence
// Object. It is an attempt to establish a dependence or direct
// Change the parameters of the object properties panel
// This function determines the reaction of the object to such a change.
function OnChangeParameters {
// Here comes the object new, representing a
// The same object with the new value of open options.

// Random variable we can immediately assign new values
rValType = new.rValType;
Lhole = new.Lhole;
Lthread = new.Lthread;

// Here consistently given, how to choose a line from the table,
// The new value of the corresponding parameters.
// Check whether the changed parameter d
if (new.d! = d) {// ie. If the new value is not equal to the old
// Table is loaded into the cache
LoadInCache (d);
// And get out of it the first available record with a parameter
// D, approximately equal to the new value.
SelectInCache ("kFirst", "d", "~", new.d);
// Then we check not change any other parameters
} Else if (DH! = New.DH) {// change the diameter of the shaft H performance
// Load
LoadInCache (DH);
// Select the first record
SelectInCache ("kFirst", "DH", "~", new.DH);
} Else if (DF! = New.DF) {// change the diameter of the shaft version F
// Load
LoadInCache (DF);
// Select the first entry with an approximately equal value
SelectInCache ("kFirst", "DF", "~", new.DF);
};

// Default processing completed successfully.
//T.e. send the object to change the parameters that
// Set the necessary parameters.
// To do this, we assign the value of the variable Handled OBJ_HANDLED
Handled = OBJ_HANDLED;

// If after selecting from the table the shaft diameter is not established
// The new value, it may require the cyclical update
// Send a variable object variable
// Handled equal OBJ_WARNING
if (d! = new.d) {
Handled = OBJ_WARNING;
};

// In this block operators recalculated the new position of the object
// When you change its work plane

// Variable fix to test the ability to move.
// In general, in this case it could not be used
// Because the hole does not change when you change its geometry
// Planes.
// This block is generated script wizard, so it has
// This unified view

fix = 0;

// Check if the dependency has changed and whether the
// PloskostWP1
if (IsFixedParam (WP1)) {
// Increase the value of the variable fix, for the follow-up audit
fix = fix + 1;
// Save the old value of the vector insertion.
vecXOld = vecDirection;
// Assign new value to the vector inserts match
// To the new position of the plane WP1
vecDirection = Vector (new.WP1);
// And move the insertion point to a new position openings
// PloskostiWP1
pntOrigin = Point (new.WP1);

// Restore the coordinate system on the basis of
// Old and new values ??of the vectors
restoreBasis (vecXOld, vecPlane, vecDirection);
};
// If all of a sudden hole with fixed geometry
// Objects begin to stretch in different directions, then
// Return an error
if (fix > 1) {
    Handled = OBJ_ERROR;
  };
};
 
// This function is performed before each attempt to establish a relationship
function BeforeConnect {
  // Here we just reset according to the latest
  // The following function to establish new
  ResetLastConstraint ();
}
 
// This function sets dependency. More specifically,
// It determines exactly how to behave when an object
// Accession to another object
function OnConnect {
  // Check for the value of the variable rPart, defining
  // The sequence number of the request to join the parts.
  //T.e. if the relationship is set in two stages,
  // Or more, it is possible to install one piece
  // Depending on two or more parts.
  // But in this particular case, depending on established only
  // From one piece, so only one request and verification
  // RPart equal to 0
  if (rPart == 0) {
    // The function comes onConnect object obj - this is a detail,
    // To which we are trying to join. We can help qualifier
    // Access to the parameters of the parts to check whether
    // Automatically install dependencies or not.
   
    // Check whether the part to which are trying to join,
    // Shaft:
    if (obj.strTheType == "Arbor") {
     
     // Next - will set depending on the current execution
     // Holes. Ie different versions is implemented differently depending on the shaft.
     if (Form == "F H") {
      
       // Set for the opening of the shaft of the same type as that of the
       // Section of the shaft, which join (this is necessary for the implementation of
       // Overlap
       rValType = obj.rValType;
      
       // Find the nearest plane to the plane of the opening WP1:
       strNearestPlane = nearestPlaneName (WP1, obj.WP1, obj.WP2);
       // This takes into account only the plane WP1 and WP2 object
       //t.e. if these are not the nearest plane, strNearestPlane
       // Is uncertain.
      
       // Further - check the shaft type. for common areas (external):
       if (obj.rValType! = 1)
         // Set the geometric relationship
         // Type "insert" codirectional. By the object to which
         // Subscribe for planes WP1 details and found
         // The nearest plane. The distance between the planes - 0 mm.
         // Dependence unidirectional
         SetGeomConstraint (INSERT, CODIRECT, obj, WP1, strNearestPlane, 0, FALSE);
        
       // For the internal sections of shafts:
       else
         // Set the relationship with the same parameters,
         // But oppositely.
         SetGeomConstraint (INSERT, CONTRDIRECT, obj, WP1, strNearestPlane, 0, FALSE);
      
       // Set the parameter depending on the current execution
       // Holes.
      
       // To form the hole F must be equated
       // Parameter rDiameter (shaft diameter) to the diameter DF table hole
       if (strDesignName == "Form F") {
         // So if the test is performed, the
         // Set the parametric dependence on expression.
         // RDiameter equating to DF
         SetParamConstraint (DF, obj, EXPR, "obj.rDiameter");
       };
      
       // To form H is the same test, but establishes a relationship
       // Already diameter hole DH.
       if (strDesignName == "FormaH") {
         SetParamConstraint (DH, obj, EXPR, "obj.rDiameter");
       };
      
       NoVectorSelect = 1; // setting the variable NoVectorSelect 1
            // Disable the selection of the direction vector for details
            // Since been joined and established addiction
            // Then choose further it is not necessary.
           
       Handled = OBJ_HANDLED; // Set the variable Handled
         // Value OBJ_HANDLED, ie saying that according to
         // Set successfully.
     };
     
    };
  };
}