几何尺寸与公差论坛------致力于产品几何量公差标准GD&T (GDT:ASME)|New GPS(ISO)研究/CAD设计/CAM加工/CMM测量  


返回   几何尺寸与公差论坛------致力于产品几何量公差标准GD&T (GDT:ASME)|New GPS(ISO)研究/CAD设计/CAM加工/CMM测量 » 仿射空间:CAX软件开发(三)二次开发与程序设计 » CAD二次开发 » AutoCAD二次开发 » DirectDWG
用户名
密码
注册 帮助 会员 日历 银行 搜索 今日新帖 标记论坛为已读


 
 
主题工具 搜索本主题 显示模式
旧 2009-05-07, 12:05 PM   #1
yang686526
高级会员
 
注册日期: 06-11
帖子: 14579
精华: 1
现金: 224494 标准币
资产: 234494 标准币
yang686526 向着好的方向发展
默认 【转帖】query regarding oddbtext alignment and position

query regarding oddbtext alignment and position

query regarding oddbtext alignment and position
hi all,
i have a query regarding setting the alignment option for oddbtext entity.
i have done this by the following piece of code..
and i have not used any fonts.
pblock = m_pdb->getmodelspaceid().safeopenobject(oddb::kforwrite) ;
ptext = oddbtext::createobject();
ptext->setposition(odgepoint3d(ptx, pty, 0));
ptext->recordgraphicsmodified(false);
ptext->setheight(10);
ptext->setwidthfactor(3);
ptext->settextstyle(oddbsymutil::gettextstyleid("standar d", theapp.m_pdb));
ptext->settextstring("hello world");
ptext->setrotation(0);
ptext->sethorizontalmode(oddb::ktextright);
ptext->setverticalmode(oddb::ktextvertmid);
pblock->appendoddbentity(ptext);
i hope i'm not using any fonts. but the position of the text seems to be invalid.
am i doing the right way. i'm not using any fonts, so do i need to use the .shx file..?
if so, i don't have autocad installed. so how can i create a .shx file..?
is it a must that if i'm using a oddbtext entity, then i must use a .shx file. for proper alignment..?
tia
------------------
regards,
rajesh parameswaran

rajuinnet
# 27th october 2004, 01:52 am

registered user join date: mar 2003
location: france
posts: 135
if the horizontalmode is not ktextleft you have to set the alignment point.
try this:
code]
ptext->setalignmentpoint(odgepoint3d(ptx, pty, 0));
[/code]

broux@trace.fr
# 27th october 2004, 01:57 am

registered user join date: jul 2004
location: india
posts: 82

quote:
originally posted by froggy
if the horizontalmode is not ktextleft you have to set the alignment point.
try this:
code]
ptext->setalignmentpoint(odgepoint3d(ptx, pty, 0));
[/code]
hi froggy,
thank you for your response.
can i know more detail about this. i need to implement all the possible combnations. top left, top center, top right, bottom left, bottom center, bottom right, middle left, middle center, and middle right.
tia
------------------
regards,
rajesh parameswaran

rajuinnet
# 27th october 2004, 08:34 am

moderator join date: mar 2002
posts: 2,994
if text alignment is left-baseline use setposition(). in other cases use setalignmentpoint(). dd will calculate other point (position or alignment). to perform the calculation dd needs access to .shx file.
if required .shx file is not available you can set both position and alignment point yourself and call recordgraphicsmodified(false) to prevent recalculation. but recordgraphicmodified() will take effect only if it's called after all properties/coordinates are set because any oddbtext modification turns the graphicsmodified flag on.
sergey slezkin

sslezkin
# 28th october 2004, 01:15 am

registered user join date: jul 2004
location: india
posts: 82

still hunting with alignment and position
quote:
originally posted by sergey slezkin
if text alignment is left-baseline use setposition(). in other cases use setalignmentpoint(). dd will calculate other point (position or alignment). to perform the calculation dd needs access to .shx file.
if required .shx file is not available you can set both position and alignment point yourself and call recordgraphicsmodified(false) to prevent recalculation. but recordgraphicmodified() will take effect only if it's called after all properties/coordinates are set because any oddbtext modification turns the graphicsmodified flag on.
hi sergey,
as you told i have modified my code. but for all the positions, its placing the text ane bottom corner of the drawing...
please help...
code below..
pblock = m_pdb->getmodelspaceid().safeopenobject(oddb::kforwrite) ;
ptext = oddbtext::createobject();
ptext->setheight(height);
ptext->setwidthfactor(3);
ptext->settextstyle(oddbsymutil::gettextstyleid(strstyle , m_pdb));
ptext->settextstring(strtext);
ptext->setrotation(0);
ptext->getboundingpoints(temparray);
nstyle = getjustificationindex(just);
switch (nstyle)
{
case 1: // top left
ptext->setalignmentpoint(temparray[0].x, temparray[0].y);
ptext->sethorizontalmode(oddb::ktextleft);
ptext->setverticalmode(oddb::ktexttop);
break;
case 2: // top center
ptext->setalignmentpoint((temparray[0].x + temparray[1].x)/2 , temparray[0].y);
ptext->sethorizontalmode(oddb::ktextcenter);
ptext->setverticalmode(oddb::ktexttop);
break;
case 3: // top right
ptext->setalignmentpoint(temparray[1].x, temparray[0].y);
ptext->sethorizontalmode(oddb::ktextright);
ptext->setverticalmode(oddb::ktexttop);
break;
case 4: // middle left
ptext->setalignmentpoint(temparray[0].x, (temparray[1].y + temparray[2].y)/2);
ptext->sethorizontalmode(oddb::ktextleft);
ptext->setverticalmode(oddb::ktextvertmid);
break;
case 5: // middle center
ptext->setalignmentpoint((temparray[0].x + temparray[1].x)/2 , (temparray[1].y + temparray[1].y)/2);
ptext->sethorizontalmode(oddb::ktextcenter);
ptext->setverticalmode(oddb::ktextvertmid);
break;
case 6: // middle right
ptext->setalignmentpoint(temparray[1].x, (temparray[1].y + temparray[1].y)/2);
ptext->sethorizontalmode(oddb::ktextright);
ptext->setverticalmode(oddb::ktextvertmid);
break;
case 7: //bottom left
ptext->setposition(temparray[2].x, temparray[2].y);
ptext->sethorizontalmode(oddb::ktextleft);
ptext->setverticalmode(oddb::ktextbottom);
break;
case 8: //bottom center
ptext->setalignmentpoint((temparray[0].x + temparray[1].x)/2 , temparray[2].y);
ptext->sethorizontalmode(oddb::ktextcenter);
ptext->setverticalmode(oddb::ktextbottom);
break;
case 9: //bottom right
ptext->setalignmentpoint(temparray[3].x, temparray[3].y);
ptext->sethorizontalmode(oddb::ktextright);
ptext->setverticalmode(oddb::ktextbottom);
break;
}
pblock->appendoddbentity(ptext);
ptext->recordgraphicsmodified(false);
tia
---------------------
regards,
rajesh parameswaran

rajuinnet
# 28th october 2004, 06:21 am

moderator join date: mar 2002
posts: 2,994
if you use recordgraphicsmodified(false) to prevent dd recalculation of second point you need to set both position and alignment points.
sergey slezkin

sslezkin
# 28th october 2004, 06:27 am

registered user join date: jul 2004
location: india
posts: 82

quote:
originally posted by sergey slezkin
if you use recordgraphicsmodified(false) to prevent dd recalculation of second point you need to set both position and alignment points.
hi sergey,
even if i don't use the recordgraphicsmodified(false) option, the same result is performed.
am i creating the right way ..?
--------------------
regards,
rajesh parameswaran

rajuinnet
# 28th october 2004, 06:48 am

moderator join date: mar 2002
posts: 2,994
you call getboundingpoints() to fill temparray.
at this moment text position was not set so it has (0,0,0) value. temparray is filled with values around (0,0,0)
when you use them to set position or alignment.
surely all texts are near (0,0,0)
btw getboundingpoints() needs .shx files to calculate string dimensions properly. if fonts are not available default font will be used and results will be incorrect.
sergey slezkin

sslezkin
# 28th october 2004, 06:56 am

registered user join date: jul 2004
location: india
posts: 82

quote:
originally posted by sergey slezkin
you call getboundingpoints() to fill temparray.
at this moment text position was not set so it has (0,0,0) value. temparray is filled with values around (0,0,0)
when you use them to set position or alignment.
surely all texts are near (0,0,0)
btw getboundingpoints() needs .shx files to calculate string dimensions properly. if fonts are not available default font will be used and results will be incorrect.
hi sergey,
if i am using the font standard, then is it necessary that it needs the .shx file for the getboundingpoints() function..?
ptext->settextstyle(oddbsymutil::gettextstyleid("standar d", m_pdb));
---------------------
regards,
rajesh parameswaran

rajuinnet
# 28th october 2004, 07:09 am

moderator join date: mar 2002
posts: 2,994
standard is not font it's text style. any text style can have any font (shx or ttf)
dd has a built-in font similar to simplex.shx which is used if no other fonts are available.
sergey slezkin

sslezkin
# 28th october 2004, 07:14 am

registered user join date: jul 2004
location: india
posts: 82

quote:
originally posted by sergey slezkin
standard is not font it's text style. any text style can have any font (shx or ttf)
dd has a built-in font similar to simplex.shx which is used if no other fonts are available.
hi sergey,
so is there any default font(s) available, or is there any limited fonts available, which can be used, such that there may be no need of any external files (*.shx)..?
tia
----------------
regards,
rajesh parameswaran

rajuinnet
# 28th october 2004, 09:03 am

moderator join date: mar 2002
posts: 2,994
dd has single built-in font similar to simplex.shx.
on windows platforms ttf fonts installed in your system are also available.
sergey slezkin

sslezkin

none
? | ?
thread tools



display modes
linear mode


search this thread

rate this thread
excellent
good
average
bad
terrible

posting rules
you may post new threads
you may post replies
you may post attachments
you may edit your posts
is on
are on
code is off
html code is off
forum jump
user control panel private messages subscriptions who's online search forums forums home general topics news questions and remarks business issues industry commentary general software issues documentation issues future directions dwg libraries dwgdirect.net dwgdirect, c++ version dwgdirectx, activex version adtdirect/c3ddirect opendwg toolkit/viewkit dgn libraries dgndirect, c++ version (2.x+) dgndirect libraries (legacy 0.99xx)
all times are gmt -7. the time now is 12:46 amfff">.
- - -
copyright ?2000 - 2009, jelsoft enterprises ltd.
copyright 1998-2008 open design alliance inc.
if the horizontalmode is not ktextleft you have to set the alignment point.
try this:
code]
ptext->setalignmentpoint(odgepoint3d(ptx, pty, 0));
[/code]

quote:
originally posted by froggy
if the horizontalmode is not ktextleft you have to set the alignment point.
try this:
code]
ptext->setalignmentpoint(odgepoint3d(ptx, pty, 0));
[/code]
hi froggy,
thank you for your response.
can i know more detail about this. i need to implement all the possible combnations. top left, top center, top right, bottom left, bottom center, bottom right, middle left, middle center, and middle right.
tia
------------------
regards,
rajesh parameswaran
if text alignment is left-baseline use setposition(). in other cases use setalignmentpoint(). dd will calculate other point (position or alignment). to perform the calculation dd needs access to .shx file.
if required .shx file is not available you can set both position and alignment point yourself and call recordgraphicsmodified(false) to prevent recalculation. but recordgraphicmodified() will take effect only if it's called after all properties/coordinates are set because any oddbtext modification turns the graphicsmodified flag on.
sergey slezkin

still hunting with alignment and position
quote:
originally posted by sergey slezkin
if text alignment is left-baseline use setposition(). in other cases use setalignmentpoint(). dd will calculate other point (position or alignment). to perform the calculation dd needs access to .shx file.
if required .shx file is not available you can set both position and alignment point yourself and call recordgraphicsmodified(false) to prevent recalculation. but recordgraphicmodified() will take effect only if it's called after all properties/coordinates are set because any oddbtext modification turns the graphicsmodified flag on.
hi sergey,
as you told i have modified my code. but for all the positions, its placing the text ane bottom corner of the drawing...
please help...
code below..
pblock = m_pdb->getmodelspaceid().safeopenobject(oddb::kforwrite) ;
ptext = oddbtext::createobject();
ptext->setheight(height);
ptext->setwidthfactor(3);
ptext->settextstyle(oddbsymutil::gettextstyleid(strstyle , m_pdb));
ptext->settextstring(strtext);
ptext->setrotation(0);
ptext->getboundingpoints(temparray);
nstyle = getjustificationindex(just);
switch (nstyle)
{
case 1: // top left
ptext->setalignmentpoint(temparray[0].x, temparray[0].y);
ptext->sethorizontalmode(oddb::ktextleft);
ptext->setverticalmode(oddb::ktexttop);
break;
case 2: // top center
ptext->setalignmentpoint((temparray[0].x + temparray[1].x)/2 , temparray[0].y);
ptext->sethorizontalmode(oddb::ktextcenter);
ptext->setverticalmode(oddb::ktexttop);
break;
case 3: // top right
ptext->setalignmentpoint(temparray[1].x, temparray[0].y);
ptext->sethorizontalmode(oddb::ktextright);
ptext->setverticalmode(oddb::ktexttop);
break;
case 4: // middle left
ptext->setalignmentpoint(temparray[0].x, (temparray[1].y + temparray[2].y)/2);
ptext->sethorizontalmode(oddb::ktextleft);
ptext->setverticalmode(oddb::ktextvertmid);
break;
case 5: // middle center
ptext->setalignmentpoint((temparray[0].x + temparray[1].x)/2 , (temparray[1].y + temparray[1].y)/2);
ptext->sethorizontalmode(oddb::ktextcenter);
ptext->setverticalmode(oddb::ktextvertmid);
break;
case 6: // middle right
ptext->setalignmentpoint(temparray[1].x, (temparray[1].y + temparray[1].y)/2);
ptext->sethorizontalmode(oddb::ktextright);
ptext->setverticalmode(oddb::ktextvertmid);
break;
case 7: //bottom left
ptext->setposition(temparray[2].x, temparray[2].y);
ptext->sethorizontalmode(oddb::ktextleft);
ptext->setverticalmode(oddb::ktextbottom);
break;
case 8: //bottom center
ptext->setalignmentpoint((temparray[0].x + temparray[1].x)/2 , temparray[2].y);
ptext->sethorizontalmode(oddb::ktextcenter);
ptext->setverticalmode(oddb::ktextbottom);
break;
case 9: //bottom right
ptext->setalignmentpoint(temparray[3].x, temparray[3].y);
ptext->sethorizontalmode(oddb::ktextright);
ptext->setverticalmode(oddb::ktextbottom);
break;
}
pblock->appendoddbentity(ptext);
ptext->recordgraphicsmodified(false);
tia
---------------------
regards,
rajesh parameswaran
if you use recordgraphicsmodified(false) to prevent dd recalculation of second point you need to set both position and alignment points.
sergey slezkin

quote:
originally posted by sergey slezkin
if you use recordgraphicsmodified(false) to prevent dd recalculation of second point you need to set both position and alignment points.
hi sergey,
even if i don't use the recordgraphicsmodified(false) option, the same result is performed.
am i creating the right way ..?
--------------------
regards,
rajesh parameswaran
you call getboundingpoints() to fill temparray.
at this moment text position was not set so it has (0,0,0) value. temparray is filled with values around (0,0,0)
when you use them to set position or alignment.
surely all texts are near (0,0,0)
btw getboundingpoints() needs .shx files to calculate string dimensions properly. if fonts are not available default font will be used and results will be incorrect.
sergey slezkin

quote:
originally posted by sergey slezkin
you call getboundingpoints() to fill temparray.
at this moment text position was not set so it has (0,0,0) value. temparray is filled with values around (0,0,0)
when you use them to set position or alignment.
surely all texts are near (0,0,0)
btw getboundingpoints() needs .shx files to calculate string dimensions properly. if fonts are not available default font will be used and results will be incorrect.
hi sergey,
if i am using the font standard, then is it necessary that it needs the .shx file for the getboundingpoints() function..?
ptext->settextstyle(oddbsymutil::gettextstyleid("standar d", m_pdb));
---------------------
regards,
rajesh parameswaran
standard is not font it's text style. any text style can have any font (shx or ttf)
dd has a built-in font similar to simplex.shx which is used if no other fonts are available.
sergey slezkin

quote:
originally posted by sergey slezkin
standard is not font it's text style. any text style can have any font (shx or ttf)
dd has a built-in font similar to simplex.shx which is used if no other fonts are available.
hi sergey,
so is there any default font(s) available, or is there any limited fonts available, which can be used, such that there may be no need of any external files (*.shx)..?
tia
----------------
regards,
rajesh parameswaran
dd has single built-in font similar to simplex.shx.
on windows platforms ttf fonts installed in your system are also available.
sergey slezkin
yang686526离线中   回复时引用此帖
GDT自动化论坛(仅游客可见)
 


主题工具 搜索本主题
搜索本主题:

高级搜索
显示模式

发帖规则
不可以发表新主题
不可以回复主题
不可以上传附件
不可以编辑您的帖子

vB 代码开启
[IMG]代码开启
HTML代码关闭

相似的主题
主题 主题发起者 论坛 回复 最后发表
【转帖】alignment and position in oddbte yang686526 DirectDWG 0 2009-05-04 03:55 PM


所有的时间均为北京时间。 现在的时间是 02:36 PM.


于2004年创办,几何尺寸与公差论坛"致力于产品几何量公差标准GD&T | GPS研究/CAD设计/CAM加工/CMM测量"。免责声明:论坛严禁发布色情反动言论及有关违反国家法律法规内容!情节严重者提供其IP,并配合相关部门进行严厉查处,若內容有涉及侵权,请立即联系我们QQ:44671734。注:此论坛须管理员验证方可发帖。
沪ICP备06057009号-2
更多