/* SDRC source file description block ---------------
 *                       
 * ideas_msg.txt
 * 9-AUG-1994 / SDRC Germany - Poing / R. Werner
 *
 * ***************************************************
 * *****          COPYRIGHT  (C) 1993            *****
 * *****    BY SDRC Software und Service GmbH    *****
 * *****            ALL RIGHTS RESERVED          *****
 * ***************************************************
 *                            
 * Application: Variant Engineering
 *                            
 * Task: Interface to I-DEAS
 *                            
 * Function: globals, constants, messages
 *                            
 * Subsystem Description:
 *
 *   This AQL include file contains standard constants,
 *   messages, and output configuration parameters for
 *   the interface Variant Engineering <--> I-DEAS Master Series.
 *       
 * History
 *
 *   9-AUG-1994 / R. Werner / Variant Engineering
 *      Rev level to 3.8                                                
 *   15-SEP-1994 / R. Werner / use working directory
 *      for temporare files
 *
 * ---------------------------------------------------
 */

// ============================================================================
// Globals
// -------
var ID_DSPLINE
var ID_HATCH_TOL
var ID_PATH
    ID_PATH = program.directory + "/d2puf"  // default
var ID_REF_OBJECT

// forward declaration of functions
// --------------------------------
function Get_ID_DSPLINE() forward
function Get_ID_HATCH_TOL() forward
function ID_get_uniform_aql ( ) forward
function ID_simple_name (fname) forward
function ID_creatt_user_attrib (obj, att, val) forward

// files used
// ----------
ID_TXT_IdeasMain      = "/d2puf_exe"
ID_TXT_Error          = "error"
ID_TXT_IdeasComfile   = "communication file"


// ============================================================================
// Messages
// --------
if program.language = "deutsch" then

   // Umlaute:  = Ae,   = ae
   //           = Oe,   = oe
   //           = Ue,   = ue
   //           = `scharf s`


   ID_TXT_NO_IDEAS_COM          = "Es besteht keine X-Kommunikation mit I-DEAS Drafting Setup.%"
   ID_TXT_TRANSFER_FILE         = "Transfer - Dateiname :"
   ID_TXT_NO_TRANSFER_FILE      = "Es existiert keine Transfer - Datei: "
   ID_TXT_ReferToDelPrims       = "Alle selektierten Elemente haben Referenzen%" 
                                + "auf gelschte Elemente. Bitte korrigieren%"
   ID_TXT_ModelName             = "Modellname:"
   ID_TXT_UpdateStart           = "Bitte warten ...  Suchen nach vorhandenem Modell"
   ID_TXT_UpdateEnd             = "UPDATE der I-DEAS Zeichnung abgeschlossen"
   ID_TXT_UpdateView            = "Bearbeiten der Ansicht "
   ID_TXT_UpdateSelectKey       = "Bitte zu vernderende treibende Masse (grn) selektieren"
   ID_TXT_NoComfile             = "Fehler: Es exisitiert keine Kommunikationsdatei: "
                                + ID_TXT_IdeasComfile + "%"
   ID_TXT_NoKeyDimensLayer      = "Keine Ebene fr treibende Masse vorhanden%"
   ID_TXT_NoKeyDimensExist      = "Keine treibenden Masse vorhanden%"
   ID_TXT_NoKeyDimensExists     = "Keine treibenden Masse selektiert%"
   ID_TXT_FaultTransferAql      = "Fehler beim Umwandeln der Transfer Datei in AQL-Prozedur.%"

   ID_TXT_NoConfig = "Kopplung I-DEAS - ObjectD%"
                   + "Konfigurationsdatei ideas.config nicht vorhanden.%"
                   + "Bitte Installation berprfen!%"
   ID_TXT_NoAql =  "Kopplung I-DEAS - ObjectD%"
                   + "ideas.aql nicht gefunden.%"
                   + "Bitte Installation berprfen!%"
   ID_TXT_CheckInstallMissFile =   "Kopplung I-DEAS - ObjectD%"
                                 + "Bitte Installation berprfen!%"
                                 + "Nicht gefunden: "
 
   ID_TXT_NoSelection   = "%Keine Elemente ausgewhlt.%Es werden keine Daten bertragen.%"
   ID_TXT_NO_ELLIPT_ARC = "%Derzeit besteht keine Mglichkeit einen Ellipsenbogen in I-DEAS zu erzeugen%"
   ID_TXT_TransferEnd   = "Datentransfer beendet."
   ID_TXT_ReevalSolid   = "Reevaluierung des Solids"
   ID_TXT_Errorfile     = "Aufgetretene Fehler siehe : "
   ID_TXT_CutNameLayer28Char = "%Name fr Ebene wurde auf 28 Zeichen gekrzt : %"
   ID_TXT_CutNameModel28Char = "%Name fr Modellname wurde auf 28 Zeichen gekrzt : %"
   ID_TXT_Fault10 = "Fehler beim Editieren von "
   ID_TXT_Fault11 = "   Element liegt auf Ebene "
   ID_TXT_Fault12 = "   Beim nochmaligen Uebergang wird Originalzustand wieder hergestellt."
   ID_TXT_Fault20 = "Fehler: Kein eindeutiger Ebenenname. Ebene "
   ID_TXT_Fault21 = "    existiert "
   ID_TXT_Fault22 = " mal. Die erste gefundene Ebene wurde aktualisiert."
   ID_TXT_Fault30 = "Warnung: Groesse des Zeichnungsrahmens wurde angenaehert "
   ID_TXT_Fault31 = "  horizontal: "
   ID_TXT_Fault32 = " anstelle von "
   ID_TXT_Fault33 = "  vertikal:   "
else

   ID_TXT_NO_IDEAS_COM         = "No X-Communication with I-DEAS Drafting Setup.%"
   ID_TXT_NO_TRANSFER_FILE     = "Transfer file does not exist: "
   ID_TXT_TRANSFER_FILE        = "transfer filename :"
   ID_TXT_ReferToDelPrims      = "All selected elements have references%" 
                               + "to deleted elements. Please correct%"
   ID_TXT_ModelName            = "model name:"
   ID_TXT_UpdateStart          = "Please wait ...  Search for I-DEAS Drawing"
   ID_TXT_UpdateEnd            = "End of UPDATE of I-DEAS Drawing"
   ID_TXT_UpdateView           = "Now processing View "
   ID_TXT_UpdateSelectKey      = "Please select key dimensions (green) to modify"
   ID_TXT_NoComfile            = "Error: No communication file \""
                               + ID_TXT_IdeasComfile + "\" exists%"
   ID_TXT_NoKeyDimensLayer     = "No layer for key dimensions%"
   ID_TXT_NoKeyDimensExist     = "No key dimensions%"
   ID_TXT_NoKeyDimensExists    = "No key dimensions selected%"
   ID_TXT_FaultTransferAql     = "Fault during creating AQL prozedure from transfer file%"

   ID_TXT_NoConfig = "Integration of I-DEAS - ObjectD%"
                   + "Doesn't exist ideas.config.%"
                   + "Please check your installation%"
   ID_TXT_NoAql =  "Integration of I-DEAS - ObjectD%"
                   + "Doesn't exist ideas.aql.%"
                   + "Please check your installation%"
   ID_TXT_CheckInstallMissFile =   "Interface of I-DEAS - ObjectD%"
                                   + "Please check your installation%"
                                   + "Doesn't exist:%"
 
   ID_TXT_NoSelection   = "%No elements selected.%Nothing to transfer.%"
   ID_TXT_NO_ELLIPT_ARC =" %Elliptical arcs cannot be created in I-DEAS.%"
   ID_TXT_TransferEnd   = "data transfer completed."
   ID_TXT_ReevalSolid   = "Reevaluating of solid"
   ID_TXT_Errorfile     = "For errors look at : "
   ID_TXT_CutNameLayer28Char = "%Name for layer is reduced to 28 characters : %"
   ID_TXT_CutNameModel28Char = "%Name for model name is reduced to 28 characters : %"
   ID_TXT_Fault10 = "Fault when editing "
   ID_TXT_Fault11 = "   element is on layer "
   ID_TXT_Fault12 = "   You will get the original status with the next transfer."
   ID_TXT_Fault20 = "Error: Non uniform layer name. Layer "
   ID_TXT_Fault21 = "    exists "
   ID_TXT_Fault22 = " times. First layer was updated."
   ID_TXT_Fault30 = "Warning: size of title block approximated "
   ID_TXT_Fault31 = "  horizontal: "
   ID_TXT_Fault32 = " used instead of "
   ID_TXT_Fault33 = "  vertical:   "
 end

// special error_codes
err_ID_TXT_NoComfile = 1            // serious error: display also in programmed action
err_no_key_dimension_selected = 50  // no serious error

// ============================================================================
// Main
// ====

// Configuration
// -------------
ID_DATE_OUTPUT = false
ID_DEBUG = false

if ID_DEBUG then
   nl nl nl
   `Start use of ideas_msg.txt ` [date()] nl
end

error_code = 0 

// Reference object and his attributes
ID_REF_OBJECT = top.list_globals.first
             // attribute         value
ID_KEY_NAME = "ID_KEY_NAME"    // string ... key layer name
ID_KEY_COLOR = "ID_KEY_COLOR"  // int    ... number of color of key layer
ID_KEY_COLOR_GREEN = 24        // int    ... number of color green

// attributes to layer
ID_VISIBLE = "ID_VISIBLE"      // string ... status of layer (e.g. selectable)

ID_DSPLINE = Get_ID_DSPLINE()
ID_HATCH_TOL = Get_ID_HATCH_TOL()

if ID_DEBUG then
   `ID_PATH = ` [ID_PATH] nl
   `ID_DSPLINE = ` [ID_DSPLINE] nl
   `ID_HATCH_TOL = ` [ID_HATCH_TOL] nl
end


if ID_DEBUG then
   `End use of ideas_msg.txt ` [date()] nl
end


// ============================================================================
// Functions
// =========

// ----------------------------------------------------------------------

function Get_ID_DSPLINE()

  // function: Get config parameter ID_DSPLINE from global element
  //
  // input -
  // return ( ID_DSPLINE : integer)
  // Get ID_DSPLINE from Configuration File
  // --------------------------------------

  ID_DSPLINE = 0
  if valid(ID_REF_OBJECT.user_ID_DSPLINE) then
     ID_DSPLINE = ID_REF_OBJECT.user_ID_DSPLINE
     if ID_DSPLINE = "" then
        ID_DSPLINE = 0
     end
  end

  return (ID_DSPLINE)

end

// ----------------------------------------------------------------------

function Get_ID_HATCH_TOL()

  // function: Get hatching tolerance from global element
  //
  // input -
  // return ( ID_HATCH_TOL : double)
  // 
  // description: used to calculate arc from poligones
  //     default tolerance 0.1 mm
  //  when length of poligone segements > ID_HATCH_TOL then
  //  try to create arc instead of poligones

  ID_HATCH_TOL = 0.1
  if valid(ID_REF_OBJECT.user_ID_HATCH_TOL) then
     ID_HATCH_TOL = ID_REF_OBJECT.user_ID_HATCH_TOL
     if ID_HATCH_TOL = "" then
        ID_HATCH_TOL = 0.1
     end
  end

  return (ID_HATCH_TOL)

end

// ----------------------------------------------------------------------

function ID_get_uniform_aql ( )

  // function: uniform file name from "login" and process id
  // input -
  // return (aql_file_name)

  ID_TXT_IdeasTmpAql    = "tmp.proc.aql"
  aql_file = ID_TXT_IdeasTmpAql + who() + string(program.pid)

  return (aql_file)

end 

// ============================================================================

function ID_simple_name (fname)

// function: get filename without path and extension
// input:
//   fname   string   whole filename with path and extension
// return    string   filename without path and extension

  rstring = fname 
  pst = rpos(fname,"/")   // search for "/" from the end 
  if pst > 0 then
    las = len(fname)
    dir_part = substr(fname, 1, pst)
    file_part = substr(fname, pst+1, las)
    pst = rpos(file_part,".")  
    las = len(file_part)
    if pst > 0 then
      rstring = substr(file_part, 1, pst-1)
    else
      rstring = file_part
    end
  end
  return(rstring)
end

// ============================================================================

function ID_creatt_user_attrib (obj, att, val)

// function: create and or attach attribute 'att' with 'val'
//           to object 'obj'
// input
//     obj  struct           Bea object
//     att  string           user attribute
//     val  string,real,int  value of user attribute

  if valid(obj.["user_" + att]) then
     set_attrib(obj, att, val)  
  else
     create_attrib(obj, att, val) 
  end 
  return

end


// ============================================================================
