CELL을 입력하기 위해서는 아래의 루틴을 따르면 됩니다.
그럼 아래 제가 사용한 코드를 보도록 하겠습니다...
- CELL이 들어 있는 Cell Library 파일을 Attach 시킵니다.(이미 Attach되어 있으면 다시 Attach 시킬 필요가 없습니다.)
- Cell Library에서 삽입할 Cell을 Cell 이름을 통해서 구해와 삽입합니다.
그럼 아래 제가 사용한 코드를 보도록 하겠습니다...
/* 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; }
댓글
댓글 쓰기