/* 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_PATH
ID_PATH =  program.directory + "/d2puf"  // default 

                    // date as value of attribut 
VAR_ID_GLOB_DATUM = string(date(),24,25," ")    

VAR_ID_GLOB_GROUP = {} // list of groups in order to get the actual created ones


VAR_ID_GLOB_PCP_X = 0  // Previuos_contour_point
VAR_ID_GLOB_PCP_Y = 0


error_code = 0 
ID_DEBUG = false

// ============================================================================
// forward declaration
// -------------------
function VAR_ID_LIST_DISSOLVE_GROUPS ( list, att ) forward
function ID_creatt_user_attrib (obj, att, val) forward

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

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

  ID_TXT_TransferPrims = "Linien,Kreisbgen,Kreise,Ellipsen,Punkte nach I-DEAS bertragen"
  ID_TXT_TransferPrUnv = "Linien,Kreisbgen,Kreise,Punkte nach I-DEAS bertragen"
  ID_TXT_TransferPlane = "Flchen nach I-DEAS bertragen"
  ID_TXT_TransferEnd   = "Datentransfer beendet."
  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%" +
                         "Die selektierten Primitive werden nicht bertragen%."
  ID_TXT_NO_ELLIPSE    = "%Die selektierte Flche enthlt Ellipsen und Ellipsenbgen%" +
                         "Diese Flche kann nicht ber das Universal File bertragen werden.%"

else

  ID_TXT_TransferPrims = "transfer lines,circular arcs,circles,ellipses,points to I-DEAS"
  ID_TXT_TransferPrUnv = "transfer lines,circular arcs,circles,points to I-DEAS"
  ID_TXT_TransferPlane = "transfer planes to I-DEAS"
  ID_TXT_TransferEnd   = "data transfer completed."
  ID_TXT_NoSelection   = "%No elements selected.%Nothing to transfer.%"
  ID_TXT_NO_ELLIPT_ARC = "%Elliptical arcs cannot be created in I-DEAS.%" +
                         "The highlighted primitives will not be transferred.%"
  ID_TXT_NO_ELLIPSE    = "%Highlighted plane contains ellipses or elliptical arcs.%" +
                         "This plane cannot be transferred via I-DEAS Universal File.%"
end


// ============================================================================
function VAR_ID_GLOB_GROUP_SET ()
   return(top.list_group)
end
// ============================================================================
function VAR_ID_GLOB_GROUP_ATT_ATTRIB ( att )
  lg = top.list_group - VAR_ID_GLOB_GROUP
  for i in lg do
      ID_creatt_user_attrib( i, att, VAR_ID_GLOB_DATUM )
  end
end
// ============================================================================
function VAR_ID_LIST_DISSOLVE_GROUPS ( list, att )
  // dissolve the groups inside the group 'list'
  // input list group     group of elements
  //       att  string    user attribute for groups
  // return (group)
  //    with elements of type
  //    "point", "line", "circle", "plane" or "contour"
 
  grp_list = list where .prim_type = "group"
  list = list - grp_list

  // append group primitives to list
  for igrp in grp_list do
     ID_creatt_user_attrib( igrp, att, VAR_ID_GLOB_DATUM )
     list_geo = VAR_ID_LIST_DISSOLVE_GROUPS ( igrp.list, att )
     list = list or list_geo
  end

  new_grp = list where 
             .prim_type = "point"   or .prim_type = "line" or
             .prim_type = "circle"  or .prim_type = "ellips" or
             .prim_type = "contour" or .prim_type = "plane"

  return (new_grp)
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


