home *** CD-ROM | disk | FTP | other *** search
/ Chip 1997 January / Chip_1997-01_cd.bin / ms95 / disk22 / dir08 / f013770.re_ / f013770.re
Text File  |  1996-04-02  |  3KB  |  83 lines

  1. /*----------------------------------------------------------------------+
  2. |                                    |
  3. |  Copyright (1993-1995) Bentley Systems, Inc., All rights reserved.    |
  4. |                                    |
  5. |  "MicroStation" is a registered trademark and "MDL" and "MicroCSL"    |
  6. |  are trademarks of Bentley Systems, Inc.                    |
  7. |                                    |
  8. |  Limited permission is hereby granted to reproduce and modify this    |
  9. |  copyrighted material provided that the resulting code is used only     |
  10. |  in conjunction with Bentley Systems products under the terms of the    |
  11. |  license agreement provided therein, and that this notice is retained    |
  12. |  in its entirety in any such reproduction or modification.        |
  13. |                                    |
  14. +----------------------------------------------------------------------*/
  15. /*----------------------------------------------------------------------+
  16. |                                    |
  17. |    $Logfile:   J:/mdl/examples/clibmgr/utils.mcv  $
  18. |   $Workfile:   utils.mc  $
  19. |   $Revision:   1.2  $
  20. |       $Date:   13 Jul 1995 12:52:50  $
  21. |                                    |
  22. +----------------------------------------------------------------------*/
  23. /*----------------------------------------------------------------------+
  24. |                                    |
  25. |   Function -                                |
  26. |                                    |
  27. |        This MC is an example of how to read a cell out of cell library |
  28. |       that is not attached to the Microstation session            |
  29. |                                    |
  30. +----------------------------------------------------------------------*/
  31. #include    <mdl.h>
  32. #include    <stdio.h>
  33. #include    <tcb.h>
  34.  
  35. #include    <mscnv.fdf>
  36. #include    <mselmdsc.fdf>
  37. #include    <msfile.fdf>
  38.  
  39.  
  40. Private int clibMgr_getCell 
  41. (
  42. MSElementDescr    **cellEdPP,
  43. char        *cellName
  44. )    
  45.     char        patternSpec[MAXFILELENGTH], patternName[MAXFILELENGTH];
  46.     ULong        rad50Name, filePos = 0L;
  47.     FILE        *fp;
  48.     MSElementDescr  *edP;
  49.  
  50.  
  51.     if (mdlFile_find (patternSpec, patternName, "MS_CELL", NULL) ||
  52.     (fp = fopen (patternSpec, "rb")) == NULL)
  53.     return UnableToOpenCellLib;
  54.  
  55.     rad50Name = 0L;
  56.     mdlCnv_fromAsciiToR50 (strlen (cellName), cellName, &rad50Name);
  57.     while ((filePos = mdlWorkDgn_read (&edP, filePos, fp, -1, FALSE)))
  58.     {
  59.     if (edP->el.ehdr.type == CELL_LIB_ELM &&
  60.         edP->el.cell_lib_hdr.name == rad50Name)
  61.         {
  62.         if (tcb->ndices==3)
  63.         {
  64.         mdlElmdscr_convertTo3D (cellEdPP, edP, 
  65.                     FIXEDDEPTH, 0, NULL, 0);
  66.         mdlElmdscr_freeAll (&edP);
  67.         }
  68.         else
  69.         {
  70.         *cellEdPP = edP;
  71.         }
  72.         fclose (fp);
  73.         return SUCCESS;
  74.         }
  75.     else
  76.         {
  77.         mdlElmdscr_freeAll (&edP);
  78.         }
  79.     }
  80.     fclose (fp);
  81.     return CantFindCell;
  82.     }
  83.