Conversion of 3D file to 2D

Status
Not open for further replies.

Vidyadhar

Usenet Archive
Joined
Dec 6, 2001
Messages
10
Reaction score
0
We have a requirement for converting 3D dgn files to 2d in batch mode in microstation SE. The current cnvdgn mdl application stops for "Press any key to continue" after every conversion. We do not want that since conversion is on server (unattended).

Also we want that conversion should function in the same manner as done by cnvdgn.

I have written mdl for this as follows.

However the converted dgn file gives end of file missing message.
Please help !!

#include <mdl.h> /* MDL Library funcs structures & constants */ #include <cmdlist.h> /* MicroStation command numbers */ #include <dlogids.h> /* Contains Dialog and item IDs */ #include <dlogitem.h> /* Dialog Box Manager structures & constants
*/
#include <rscdefs.h> /* resource mgr structure definitions & constants */ #include <stdarg.h> /* macros for accessing arguments of functions */ #include <stdlib.h> /* fdf's for commonly used library functions */ #include <string.h> /* String function prototypes */ #include <pltstrct.h> /* String function prototypes */ #include <tcb.h> #include <stdio.h> #include <scanner.h> #include <msdefs.h> #include <global.h> #include <mselems.h>

#include "cnvdgnncmd.h"

#include <dlogman.fdf>
#include <mdllib.fdf>
#include <mselemen.fdf>
#include <msmisc.fdf>
#include <msrsrc.fdf>
#include <mssystem.fdf>
#include <msstate.fdf>
#include <msoutput.fdf>
#include <mstmatrx.fdf>
#include <mselmdsc.fdf>
#include <mslocate.fdf>
#include <msscan.fdf>
#include <msmisc.fdf>
#include <mswrkdgn.fdf>
#include <msparse.fdf>
#include <msdialog.fdf>

ULong filePosition;
Private char fileName[MAXFILELENGTH];

Private void processElement;
Private void locateElement;

/*---------------------------------------------------------------------+ | | name processElement 07/99 | +----------------------------------------------------------------------*/

Private void processElement
(
void
)
{
int returnValue;
MSElementDescr *element3d, *element2d;
Transform tMatrix;
FILE *pFile;
int status = 0;
int status1;
int count = 0;
Scanlist scanList;
ULong nextElm;
ULong filePos = 0L;
ULong currAddr[2];
int scanWords;

mdlTMatrix_getIdentity ( &tMatrix );
pFile = fopen (fileName, "w");
if (pFile==NULL)
{
mdlOutput_printf (MSG_ERROR, "Can't create file to write %s", fileName); return; }

mdlScan_initScanlist (&scanList);
mdlScan_noRangeCheck (&scanList);

scanList.scantype = ELEMTYPE | NESTCELL | ONEELEM; scanList.extendedType = FILEPOS; scanList.typmask[0] = TMSK0_GROUP_DATA| TMSK0_DIG_SETDATA | TMSK0_LEV_SYM ; /* type 3 (lines) only */ scanList.typmask[4] = TMSK4_MICROSTATION_ELM;

mdlScan_initialize (0, &scanList);

while (1)
{

scanWords = sizeof(currAddr) / sizeof(short);
status1 = mdlScan_file (currAddr, &scanWords, sizeof(currAddr), &nextElm);

if (status1 != BUFF_FULL)
{
break;
}

mdlElmdscr_read ( &element3d, currAddr[0], 0, FALSE, NULL );

if ((mdlElmdscr_convertTo2D ( &element2d, element3d, 0, &tMatrix, 0 ))==SUCCESS) { printf("conversion successful\n"); }

/*show information of the 2d element*/

mdlElmdscr_validate(element2d,NULL);

filePos = mdlWorkDgn_write(element2d, filePos, pFile,0,0);

printf("Status is %d\n",filePos);

if(filePos == 0) {
printf("Unable to write element\n");
} else {
count = count +1;
printf("Element %d written\n",count);
}

mdlElmdscr_freeAll ( &element2d );

mdlElmdscr_freeAll (&element3d);

}
fclose (pFile);
}

/*----------------------------------------------------------------------+ | | Main | author BSI 07/99 | +----------------------------------------------------------------------*/ Public void main

(
int argc,
char *argv
)

{
int rscFileH; /* a resource file handle */
char *setP; /* a ptr to a "C expression symbol set" */ char suggestedName[MAXFILELENGTH]; int status=0; int open_status,isThreeD; int slot, status1,avail; double scale_of_ref; ULong UOR_ref; char baseDevP[MAXFILELENGTH], baseDirP[MAXFILELENGTH], baseNameP[MAXFILELENGTH], baseExtP[MAXFILELENGTH], newRefFileName[MAXFILELENGTH], nameP[MAXFILELENGTH], extP[MAXFILELENGTH], refpath[MAXFILELENGTH];

mdlSystem_enterDebug;

mdlFile_checkDesignFile(&isThreeD,argv[4]);

if (isThreeD==1) {
if ((open_status = mdlSystem_newDesignFile ( argv[4] )) == SUCCESS) { //#ifdef TEST printf("argc %d",argc); printf("argv %s",argv[4]); //#endif sprintf (suggestedName, "new2d1.dgn"); sprintf (fileName, argv[5]);

processElement;

mdlSystem_closeDesignFile;
}

}

/* set the suggested file name to open */

}
 
In case you have not noticed my earlier post, The DOS window can be suppresed by writing a C routine as follows :

static STARTUPINFO StartupInfo;
static PROCESS_INFORMATION ProcessInfo;
sprintf(cmd,"%sustation -wacnvdgn -iinname:inp3d.dgn
-ioutname:out2d.dgn -ipauseScreen:off", ustndir);

StartupInfo.cb = sizeof(STARTUPINFO);
StartupInfo.lpDesktop = NULL;
StartupInfo.lpTitle = NULL;
StartupInfo.dwX = 0;
StartupInfo.dwY = 0;
StartupInfo.dwXSize = 0;
StartupInfo.dwYSize = 0;
StartupInfo.dwFlags = STARTF_USESHOWWINDOW;
StartupInfo.wShowWindow = SW_HIDE;

ProcessInfo.hProcess = NULL;

if (!CreateProcess(
(LPCTSTR) NULL,
(LPTSTR) cmd,
(LPSECURITY_ATTRIBUTES) NULL,
(LPSECURITY_ATTRIBUTES) NULL,
(BOOL) FALSE,
(DWORD) CREATE_NO_WINDOW,
(LPVOID) NULL,
(LPVOID) NULL,
(LPSTARTUPINFO) &StartupInfo,
(LPPROCESS_INFORMATION) &ProcessInfo)) status = -1; else WaitForSingleObject((HANDLE)ProcessInfo.hThread, INFINITE);

if (status != -1 &&
GetExitCodeProcess((HANDLE)ProcessInfo.hProcess, &exit_code))
status = (int)exit_code;

CloseHandle(ProcessInfo.hProcess);
CloseHandle(ProcessInfo.hThread);

(Vidyadhar) wrote:
We have a requirement for converting 3D dgn files to 2d in batch mode in microstation SE. The current cnvdgn mdl application stops for "Press any key to continue" after every conversion. We do not want that since conversion is on server (unattended).

Also we want that conversion should function in the same manner as done by cnvdgn.

I have written mdl for this as follows.

However the converted dgn file gives end of file missing message.
...
 
Status
Not open for further replies.

Latest threads

Back
Top