- UID
- 520
- 积分
- 0
- 精华
- 贡献
-
- 威望
-
- 活跃度
-
- D豆
-
- 在线时间
- 小时
- 注册时间
- 2002-1-14
- 最后登录
- 1970-1-1
|
楼主 |
发表于 2002-8-13 10:03:05
|
显示全部楼层
- [FONT=courier new]
- //szStyle---文本样式名
- //TEXTSTYLEPARAM---文本样式的各参数结构体
- //TextStyelId---文字样式id
- int OpenTextstylekk(char *szStyle,TEXTSTYLEPARAM pTsp,AcDbObjectId &TextStyleId)
- {
- int iRz;
- AcDbSymbolTable * pTextStyleTable;
- AcDbTextStyleTableRecord* pTextStyleTableRecord;
- CCustomDatabase pDb;//
- char *tempChar;
- iRz=acdbHostApplicationServices()->workingDatabase()->getTextStyleTable ( pTextStyleTable, AcDb::kForWrite );
- if(iRz!=Acad::eOk)
- {
- return 0;
- }
- if(szStyle[0]=='$')
- {
- iRz=pTextStyleTable->getAt(szStyle+1,(AcDbSymbolTableRecord*&) pTextStyleTableRecord, AcDb::kForWrite) ;
- }
- else
- {
- iRz=pTextStyleTable->getAt(szStyle,(AcDbSymbolTableRecord*&) pTextStyleTableRecord, AcDb::kForWrite) ;
- }
- if(iRz!=Acad::eOk)//ûÓÐÏàÓ¦µÄ¿é±í¼Ç¼£¬
- {
- if(szStyle[0]=='$')//¶¨ÖÆÖÐÐÄÓУ¬Ö±½ÓÌáÈ¡
- {
- if(!pDb.GetTextstyleCustomParam(szStyle+1,&pTsp))
- {
- return 0;
- }
- }
- else//ûÓУ¬Ôòн¨
- {
- //³õʼ»¯Ñù±¾²ÎÊý
- fast_geo_InitTextStyleParam(szStyle,pTsp);
- }
- pTextStyleTableRecord=new AcDbTextStyleTableRecord();
- pTextStyleTableRecord->setName(pTsp.szTextstyleName);
- iRz=pTextStyleTable->add(TextStyleId,pTextStyleTableRecord) ;
- if(iRz!=Acad::eOk)
- {
- return 0;
- }
- //¶ÔÑù±¾¼Ç¼½øÐÐÉèÖÃ
- char *pChar;
- pChar=strstr(pTsp.szFontFile,".shx");
- if(pChar!=NULL)//°üº¬ÁË.shx£¬Ðè¼ÓÔØÐÍÎļþ
- {
- char *tempChar;
- char szFilePath[260];
- strcpy(szFilePath,"");
- GetFontsPathkk(szFilePath);
- tempChar=strchr(pTsp.szFontFile,'|');
- if(tempChar!=NULL)//°üº¬´ó×ÖÌå
- {
- CString str;
- char fileName[255],bigFontFileName[255],pathCopy[255];
- str=pTsp.szFontFile;
- int i;
- i=str.Find("|");
- str.SetAt(i,'\0');//Çå¿ÕºóÃæµÄ×Ö·û
- strcpy(fileName,str);
- strcpy(bigFontFileName,pTsp.szFontFile+i+1);
- strcpy(pathCopy,szFilePath);
- strcat(szFilePath,"\");
- strcat(szFilePath,fileName);
- strcat(pathCopy,"\");
- strcat(pathCopy,bigFontFileName);
- if(pTextStyleTableRecord->setFileName(szFilePath)!=Acad::eOk)
- return 0;
- if(pTextStyleTableRecord->setBigFontFileName(pathCopy)!=Acad::eOk)
- return 0;
- }
- else
- {
- pTextStyleTableRecord->setFileName(szFilePath);
- }
- }
- else
- {
- pTextStyleTableRecord->setFont(pTsp.szFontFile,pTsp.bBold,pTsp.bItalic,0,0);//×ÖÌåÎļþÃû
- }
- pTextStyleTableRecord->setIsVertical(pTsp.bVertical);//´¹Ö±·ñ
- pTextStyleTableRecord->setObliquingAngle(pTsp.dObliquingAngle);//Çãб½Ç¶È
- pTextStyleTableRecord->setXScale(pTsp.dXScale);//¿í¶È±ÈÀý
- pTextStyleTableRecord->setTextSize(pTsp.dHeight);//¸ß¶È
- //ÉèΪµ±Ç°Îı¾Ñù±¾
- acedCommand(RTSTR,"-style",RTSTR,"standard",RTSTR,"",RTREAL,0.0,RTREAL,1.0,RTSTR,"45",RTSTR,"N",RTSTR,"N",RTSTR,"N",0);
- // acedCommand(RTSTR,"-style",RTSTR,"ST",RTSTR,"",RTSTR,"0",RTSTR,"1",RTSTR,"45",RTSTR,"N",RTSTR,"N",RTSTR,"N",0);
- // acedCommand(RTSTR,"-style",RTSTR,pTsp.szTextstyleName,RTSTR,"",RTSTR,"pTsp.dHeight",
- // RTSTR,"pTsp.dXScale",RTSTR,"pTsp.dObliquingAngle",
- // RTSTR,"N",RTSTR,"N",RTSTR,"N",0);
- // pTextStyleTableRecord->setFlagBits((Adesk::UInt8)((pTsp.bXMirror() << 1) |
- // (pTsp.bYMirror() << 2)));
- }
- else//´ÓÎı¾Ñùʽ±í¼Ç¼ÖÐÌáÈ¡²ÎÊý
- {
- if(szStyle[0]=='$')
- {
- strcpy(pTsp.szTextstyleName,szStyle+1);//Îı¾ÑùʽÃû
- }
- else
- {
- strcpy(pTsp.szTextstyleName,szStyle);//Îı¾ÑùʽÃû
- }
- int charset,pitch;
- pTsp.bBold=0;//ÊÇ·ñΪ´ÖÌå
- pTsp.bItalic=0;//ÊÇ·ñΪбÌå
- iRz=pTextStyleTableRecord->font(tempChar,pTsp.bBold,pTsp.bItalic,charset,pitch);//×ÖÌåÎļþÃû
- if (iRz != Acad::eOk)
- {
- if (tempChar)
- delete tempChar;
- return 0;
- }
- if (strlen(tempChar) == 0)
- {
- // SHX font. Use the .ttf version of it.
- char *pShxFileName = NULL;
- if ((Acad::eOk != (iRz = pTextStyleTableRecord->fileName(pShxFileName))) ||
- !pShxFileName)
- {
- iRz = pTextStyleTableRecord->bigFontFileName(pShxFileName);
- }
- if (Acad::eOk != iRz)
- {
- return 0;
- }
-
- // Get the typeface name from font file name.
- for (int i = 0; i < strlen(pShxFileName); ++i)
- {
- if (pShxFileName[i] == '.')
- break;
- tempChar = new char[i + 1];
- strncpy(tempChar, pShxFileName, i);
- tempChar[i] = '\0';
- }
- }
- strcpy(pTsp.szFontFile,tempChar);
- pTsp.dHeight=pTextStyleTableRecord->textSize();//ÎÄ×ָ߶È
- pTsp.dXScale=pTextStyleTableRecord->xScale();//¿í¶È±ÈÀý
- pTsp.dObliquingAngle=pTextStyleTableRecord->obliquingAngle();//Çãб½Ç¶È
-
- Adesk::UInt8 pFlagBits = pTextStyleTableRecord->flagBits();
- if (pFlagBits & 0x2)
- {
- pTsp.bXMirror = Adesk::kTrue;
- }
- else
- {
- pTsp.bXMirror = Adesk::kFalse;
- }
- if (pFlagBits & 0x4)
- {
- pTsp.bYMirror = Adesk::kTrue;
- }
- else
- {
- pTsp.bYMirror = Adesk::kFalse;
- }
- pTsp.bVertical=pTextStyleTableRecord->isVertical();
- TextStyleId=pTextStyleTableRecord->objectId();//
- }
- // TextStyleId=pTextStyleTableRecord->objectId();//
- /* iRz=pTextStyleTable->getAt(pTsp.szTextstyleName,TextStyleId, Adesk::kFalse) ;
- if(iRz!=Acad::eOk)
- {
- pTextStyleTable->close();
- return 0;
- } */
- pTextStyleTableRecord->close();
- pTextStyleTable->close();
- return 1;
- }[/FONT]
复制代码 |
|