objectarx二次開發,文字實體AcDbText獲取插入點不準確的問題

AcDbText::position Function

AcGePoint3d position() const;

	This function returns the insertion point of the text in WCS coordinates.
	If vertical mode is AcDb::kTextBase and horizontal mode is either AcDb::kTextLeft, AcDb::kTextAlign, or AcDb::kTextFit, then the position point is the insertion point for the text object and, for AcDb::kTextLeft, the alignment point (DXF group code 11) is automatically calculated based on the other parameters in the text object.
	For all other vertical and horizontal mode combinations, the alignment point is used as the insertion point of the text and the position point is automatically calculated based on the other parameters in the text object.
	The position value is the WCS equivalent of DXF group code 10.
大概意思就是:verticalMode() == AcDb::kTextBase時,如果 horizontalMode()== AcDb::kTextLeft 或 horizontalMode()== AcDb::kTextAlign 或 horizontalMode()== AcDb::kTextFit,那麼position() 函數就是文字的插入點,否則alignmentPoint ()就是插入點

AcDbText::alignmentPoint Function

AcGePoint3d alignmentPoint() const;

	This function returns the alignment point of the text.
	If vertical mode is AcDb::kTextBase and horizontal mode is either AcDb::kTextLeft, AcDb::kTextAlign, or AcDb::kTextFit, then the position point (DXF group code 10) is the insertion point for the text object and, for AcDb::kTextLeft, the alignment point is automatically calculated based on the other parameters in the text object.
	For all other vertical and horizontal mode combinations, the alignment point is used as the insertion point of the text and the position point is automatically calculated based on the other parameters in the text object.
	The alignment point value is the WCS equivalent of DXF group code 11.

獲取文字插入點函數如下

	AcDbText * pEntityPtr;
	AcGePoint3d insertPosition;
	if (pEntityPtr->verticalMode() == AcDb::kTextBase)
	{
		TextHorzMode hzModel = pEntityPtr->horizontalMode();
		if (hzModel == AcDb::kTextLeft ||hzModel == AcDb::kTextAlign || hzModel == AcDb::kTextFit)
		{
			insertPosition = pEntityPtr->position();
		}else{
			insertPosition = pEntityPtr->alignmentPoint();
		}
	}else{
			insertPosition = pEntityPtr->alignmentPoint();
	}

如有問題,歡迎拍磚留言指正

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章