📄 strtext.mc
字号:
/*----------------------------------------------------------------------------+
| Copyright (C) 1991 Mach N. Dinh-Vu, All Rights Reserved |
| Program : strtext.mc |
| Revision : 1.0.a |
| UpgradeToV8: MicroStationFan 2006/05 |
+-----------------------------------------------------------------------------+
| scan the entire DGN file and located all text string. |
| Stroke the text into linestrings and then export to another DGN |
| file. |
+----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------+
| Include Files |
+----------------------------------------------------------------------------*/
#include <mdl.h> /* system include files */
#include <global.h>
#include <msrmgr.h>
#include <userfnc.h>
#include <stdlib/string.h>
#include <mscell.fdf>
#include <mselemen.fdf>
#include <mselmdsc.fdf>
#include <msmisc.fdf>
#include <msoutput.fdf>
#include <msparse.fdf>
#include <msstate.fdf>
#include <mswrkdgn.fdf>
#include "strtext.h"
#define NEWELEMENT -1
#define TOLERANCE 1000
DgnModelRefP modelRefP;
ULong workPos = -1L;
int number_exported = 0;
/*----------------------------------------------------------------------------+
| name main |
+----------------------------------------------------------------------------*/
Private void main (void)
{
RscFileHandle rfHandle;
/* load our comnand table */
if (mdlParse_loadCommandTable (NULL) == NULL)
mdlOutput_error ("Unable to load command table.");
mdlResource_openFile (&rfHandle, NULL, FALSE);
mdlOutput_prompt ("Key-in STRTEXT [filename] to execute");
}
/*----------------------------------------------------------------------------+
| name stroke_elm |
+----------------------------------------------------------------------------*/
Private int stroke_elm ( MSElement *el, void *params, int operation,
ULong offset, MSElementDescr *edP)
{
DPoint3d *points;
MSElementDescr *elmDP;
MSElement elm;
UInt32 color, weight, level, ggNum;
Int32 style;
int numPnts;
if (mdlElement_getType(el) != TEXT_ELM)
return SUCCESS;
if (mdlElement_stroke (&points, &numPnts, el, TOLERANCE) == SUCCESS)
{
if (numPnts > MAX_VERTICES)
numPnts = MAX_VERTICES;
mdlOutput_rscPrintf (MSG_MESSAGE, NULL, 0, 2, ++number_exported);
/* get element display symbology of current element */
mdlElement_getSymbology (&color, &weight, &style, el);
/* get properties of current element */
mdlElement_getProperties (&level, &ggNum, NULL, NULL,
NULL, NULL, NULL, NULL, el);
mdlLineString_create (&elm, NULL, points, numPnts);
/* set element display symbology of line string */
mdlElement_setSymbology (&elm, &color, &weight, &style);
/* set properties of line string */
mdlElement_setProperties (&elm, &level, &ggNum, NULL, NULL,
NULL, NULL, NULL, NULL);
mdlElmdscr_new (&elmDP, NULL, &elm);
workPos = mdlWorkDgn_write (elmDP, workPos, modelRefP);
/* Display text written */
mdlElement_display (el, HILITE);
/* Free temporary descriptor */
mdlElmdscr_freeAll (&elmDP);
}
return SUCCESS;
}
/*----------------------------------------------------------------------------+
| name writeFile |
+----------------------------------------------------------------------------*/
Private void writeFile ( char *filename )
{
ULong position = 0L;
MSElementDescr *edP;
int format;
BoolInt isThreeD;
if (mdlWorkDgn_openFile (&modelRefP, &format, &isThreeD, filename, NULL, FALSE)
!= SUCCESS)
{
mdlOutput_rscPrintf (MSG_MESSAGE, NULL, 0, 3, filename);
mdlUtil_beep (1);
return;
}
mdlOutput_rscPrintf (MSG_PROMPT, NULL, 0, 1, filename);
while ((position = mdlElmdscr_read (&edP, position, 0, FALSE, NULL)) != 0L)
{
if ((edP->el.ehdr.type == TEXT_ELM ) ||
(edP->el.ehdr.type == TEXT_NODE_ELM ))
{
mdlElmdscr_operation (edP, stroke_elm, NULL, ELMD_ELEMENT);
}
mdlElmdscr_freeAll (&edP);
} /* end-while */
/* cleanup */
mdlOutput_prompt(" ");
mdlOutput_command(" ");
mdlWorkDgn_closeFile (modelRefP);
}
/*----------------------------------------------------------------------------+
| name keyinText |
+----------------------------------------------------------------------------*/
Private void keyinText (void)
{
char filename [128];
/* do nothing on <CR> only */
if (!*statedata.cmdstring)
return;
/* save DGN filename */
strncpy (filename, statedata.cmdstring, sizeof(filename));
writeFile (filename);
}
/*----------------------------------------------------------------------------+
| name setTextState |
+----------------------------------------------------------------------------*/
Private void setTextState (void)
{
mdlState_setFunction (STATE_KEYIN, keyinText);
mdlOutput_prompt ("Enter DGN filename");
}
/*----------------------------------------------------------------------------+
| name strfile |
+----------------------------------------------------------------------------*/
cmdName strfile ( char *pStrings )
cmdNumber CMD_STRTEXT
{
char filename [128];
mdlOutput_rscPrintf (MSG_COMMAND, NULL, 0, 0);
if (*pStrings)
{
strcpy (filename, pStrings);
writeFile (filename);
}
else
setTextState ();
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -