Post

Cell 삽입하기

CELL을 입력하기 위해서는 아래의 루틴을 따르면 됩니다.

  1. CELL이 들어 있는 Cell Library 파일을 Attach 시킵니다.(이미 Attach되어 있으면 다시 Attach 시킬 필요가 없습니다.)
  2. Cell Library에서 삽입할 Cell을 Cell 이름을 통해서 구해와 삽입합니다.

간단하죠….

그럼 아래 제가 사용한 코드를 보도록 하죠…

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
/* ANSI C includes */#include stdlib.h>
#include stdio.h>
#include string.h>
#include assert.h>

/* MDL H includes */
#include mdl.h>
#include cmdlist.h>
#include dlogids.h>
#include dlogitem.h>
#include mdlerrs.h>

/* MDL FDF includes */
#include ditemlib.fdf>
#include dlogman.fdf>
#include mscexpr.fdf>
#include mscnv.fdf>
#include msdialog.fdf>
#include msoutput.fdf>
#include msrsrc.fdf>
#include msstate.fdf>
#include mssystem.fdf>
#include mdllib.fdf>
#include msmline.fdf>
#include tcb.h>

/*----------------------------------------------------------------------+
| |
| name loadCellLibraryIfNeeded |
| |
| author BSI 6/91 |
| |
+----------------------------------------------------------------------*/
Private void loadCellLibraryIfNeeded(char *libToLoad)
{
    char libName[MAXFILELENGTH];
    int res = 0;

        if(*libToLoad  strcmp(libToLoad,tcb->celfilenm))
    {
        res = mdlCell_attachLibrary(libName,libToLoad,NULL,TRUE);
        if(SUCCESS != res)
        {
            sprintf(libName , "res = %d , path = %s,%d" , res , libToLoad , strlen(libToLoad));
            mdlDialog_dmsgsPrint(libName);
        }
    }
}

/*----------------------------------------------------------------------+
| |
| name WriteCellElement |
| |
| author BSI 6/91 |
| |
+----------------------------------------------------------------------*/
Public int WriteCellElement(FDN_ELEMENT* element)
{
    int share = 0;
    long location = 0;
    MSElementDescr *cellDescrP=NULL;
    MSElementDescr *cellDP=NULL;
    Dpoint3d        scale;
    RotMatrix       rMatrix;
    Transform       tMatrix;
    int view = 0;

    assert(element  "element is NULL");
    if(element)
    {
        loadCellLibraryIfNeeded(element->cell_file_name);
        if(0L != (location = mdlCell_getFilePosInLibrary(element->cell_name)))
        {
            mdlCell_getElmDscr (cellDescrP, NULL, location, NULL, NULL,NULL, NULL, 0, share, element->cell_name);
            if (cellDescrP)
                {
                mdlElmdscr_duplicate (cellDP, cellDescrP);
                /* --- adjust for active angle and view rotation --- */
                mdlTMatrix_getIdentity (tMatrix);
                mdlRMatrix_fromView (rMatrix, view, FALSE);
                mdlRMatrix_invert (rMatrix, rMatrix);
                mdlTMatrix_rotateByRMatrix (tMatrix, tMatrix, rMatrix);
                mdlTMatrix_rotateByAngles (tMatrix, tMatrix, 0.0, 0.0,tcb->actangle*fc_piover180);
                mdlElmdscr_transform (cellDP, tMatrix);

                /* --- adjust for active scale --- */
                mdlTMatrix_getIdentity (tMatrix);
                mdlParams_getActive (scale, ACTIVEPARAM_SCALE);
                mdlTMatrix_scale (tMatrix, tMatrix, scale.x, scale.y, scale.z);
                mdlElmdscr_transform (cellDP, tMatrix);

                /* --- adjust for position --- */
                mdlTMatrix_getIdentity (tMatrix);
                mdlTMatrix_translate (tMatrix, tMatrix, element->position.x, element->position.y, element->position.z);
                mdlElmdscr_transform (cellDP, tMatrix);

                AppendElementInfo(element,cellDP);
                mdlElmdscr_add(cellDP);

                if(cellDP)
                {
                    mdlElmdscr_freeAll (cellDP);
                    cellDP = NULL;
                }

                return SUCCESS;
            }
        }
        else
        {
            mdlDialog_dmsgsPrint("Can't find cell in cell library");
        }
    }
    return ERROR;
}