- UID
- 5043
- 积分
- 1347
- 精华
- 贡献
-
- 威望
-
- 活跃度
-
- D豆
-
- 在线时间
- 小时
- 注册时间
- 2002-5-13
- 最后登录
- 1970-1-1
|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
×
- void changeTextInnerAlign()
- {
- //使用以下代码可以更换文本对齐方式,而不改变文字位置:
- ads_name name,ent;
- AcDbEntity *pObj;
- AcDbObjectId ObjId;
- long length=0;
-
- acutPrintf(_T("\n选择需要对齐的文本实体:"));
- if(acedSSGet(NULL,NULL,NULL,NULL,name)!=RTNORM) return;
- acedSSLength(name,&length);
-
- ArxDbgUiPrKeyWordDef prAlignType(_T("修改后的对齐方式[左对齐(L)/水平居中(M)/右对齐(R)]"),
- _T("L M R"), _T("L"));
- if (prAlignType.go() != ArxDbgUiPrBase::kOk)
- return ;
- CString Justify;
- if (prAlignType.isKeyWordPicked(_T("L")))
- Justify = "左对齐";
- else if (prAlignType.isKeyWordPicked(_T("M")))
- Justify = "水平居中";
- else if (prAlignType.isKeyWordPicked(_T("R")))
- Justify = "右对齐";
- else
- {
- ASSERT(0);
- return ;
- }
-
- int i; for( i=0;i<length;i++)
- {
- acedSSName(name,i,ent);
- acdbGetObjectId(ObjId,ent);
- acdbOpenObject(pObj,ObjId,AcDb::kForWrite,Adesk::kFalse);
-
- AcDbExtents extents1, extents2;
-
-
- if(pObj->isKindOf(AcDbText::desc()))//普通文本
- {
- AcDbText *pText=AcDbText::cast(pObj);
-
- pText->getGeomExtents(extents1);
- if(Justify==_T("左对齐")) pText->setHorizontalMode(AcDb::kTextLeft);
- else if(Justify==_T("右对齐")) pText->setHorizontalMode(AcDb::kTextRight);
- else if(Justify==_T("水平居中")) pText->setHorizontalMode(AcDb::kTextCenter);
- else pText->setHorizontalMode(AcDb::kTextLeft);
- pText->setVerticalMode(AcDb::kTextBase);
-
- }
- else if(pObj->isKindOf(AcDbMText::desc()))//多行文本
- {
- AcDbMText *pMText=AcDbMText::cast(pObj);
-
- pMText->getGeomExtents(extents1);
- if(Justify==_T("左对齐"))
- {
- if(pMText->attachment()==AcDbMText::kTopCenter ||
- pMText->attachment()==AcDbMText::kTopRight)
- pMText->setAttachment(AcDbMText::kTopLeft);
- else if(pMText->attachment()==AcDbMText::kMiddleCenter ||
- pMText->attachment()==AcDbMText::kMiddleRight)
- pMText->setAttachment(AcDbMText::kMiddleLeft);
- else if(pMText->attachment()==AcDbMText::kBottomCenter ||
- pMText->attachment()==AcDbMText::kBottomRight)
- pMText->setAttachment(AcDbMText::kBottomLeft);
- }
- else if(Justify==_T("水平居中"))
- {
- if(pMText->attachment()==AcDbMText::kTopLeft ||
- pMText->attachment()==AcDbMText::kTopRight)
- pMText->setAttachment(AcDbMText::kTopCenter);
- else if(pMText->attachment()==AcDbMText::kMiddleLeft ||
- pMText->attachment()==AcDbMText::kMiddleRight)
- pMText->setAttachment(AcDbMText::kMiddleCenter);
- else if(pMText->attachment()==AcDbMText::kBottomLeft ||
- pMText->attachment()==AcDbMText::kBottomRight)
- pMText->setAttachment(AcDbMText::kBottomCenter);
- }
- else if(Justify==_T("右对齐"))
- {
- if(pMText->attachment()==AcDbMText::kTopLeft ||
- pMText->attachment()==AcDbMText::kTopCenter)
- pMText->setAttachment(AcDbMText::kTopRight);
- else if(pMText->attachment()==AcDbMText::kMiddleLeft ||
- pMText->attachment()==AcDbMText::kMiddleCenter)
- pMText->setAttachment(AcDbMText::kMiddleRight);
- else if(pMText->attachment()==AcDbMText::kBottomLeft ||
- pMText->attachment()==AcDbMText::kBottomCenter)
- pMText->setAttachment(AcDbMText::kBottomRight);
- }
- }
- pObj->close();
-
- AcDbEntity *pEnt = NULL;
- acdbOpenObject(pEnt, ObjId, AcDb::kForWrite);
- if (pEnt == NULL)
- return;
- pEnt->getGeomExtents(extents2);
- AcGeVector3d vec = extents1.minPoint() - extents2.minPoint();
- pEnt->transformBy(AcGeMatrix3d::translation(vec));
- pEnt->close();
- }
- }
|
|