![]() |
【转帖】alignment and position in oddbte
alignment and position in oddbtext
alignment and position in oddbtext which is the difference and the relation between alignment point (method alignmentpoint()) and position point (method position()) in the oddbtext class? position is always (left,baseline) point of the text. alignment point depends on vertical and horizontal alignment. for example if text alignment is (right,top) than alignment point is right top corner of the text. while creating text entity if alignment is left, baselige you need to specify position point. if alignment is (top,center) you specify top center as alignment point. position will be calculated by dd based on heiht, font, text string. if alignment is fit or aligned you have to specify both points. sergey slezkin quote: originally posted by sergey slezkin position is always (left,baseline) point of the text. alignment point depends on vertical and horizontal alignment. for example if text alignment is (right,top) than alignment point is right top corner of the text. while creating text entity if alignment is left, baselige you need to specify position point. if alignment is (top,center) you specify top center as alignment point. position will be calculated by dd based on heiht, font, text string. if alignment is fit or aligned you have to specify both points. i am having a similar problem with alignment and positioning. i have a top,center justified piece of text for which i am specifying the alignment point only and not the position. however, the position that dd is calculating does not seem to be correct. a simple test is to use dd to read an autocad file with one piece of justified text, capturing the text string, height, font, justification etc. and then writing a new database using those values. the result is not the same when both files are viewed inside autocad. the alignment of the text is the same for both files, but the position of the text in the second file is not the same. i understand that the adjustalignment() function is called automatically on oddbtext object closure, however, it seems that this very thing is causing the position to be calculated incorrectly. i can send more info if required, but this should be reasonably easy to reproduce. thanks in advance, ryan i should note that i am using version 1.11 build 1 of dwg direct. to calculate position correctly dd needs access to the font. if the font is not available default one is used and position may differ from the right one because of different font metrics. sergey slezkin quote: originally posted by sergey slezkin to calculate position correctly dd needs access to the font. if the font is not available default one is used and position may differ from the right one because of different font metrics. the font being used is specified as 'standard' and the filename is 'txt.shx' for both the source and destination. i would expect the same position out if the fonts are the same. i am using vs .net 2003 and the vc2003mt statically linked libraries. regards, ryan if txt.shx present on computer and is available to autocad it does not mean that dd is able to find it. dd calls oddbhostapp::findfile() to get the full path to .shx file. this function is expected to be overridden in oddbhostapp inheritor to take care about fonts location. sergey slezkin quote: originally posted by sergey slezkin if txt.shx present on computer and is available to autocad it does not mean that dd is able to find it. dd calls oddbhostapp::findfile() to get the full path to .shx file. this function is expected to be overridden in oddbhostapp inheritor to take care about fonts location. ok, i have overwritten the findfile() method and set the acad environment variable to teh autocad fonts directory and things are working now. it would be nice if there was some way a user could have that work done for them without having to be told to set an environment variable at all. for example,a reliable registry key for locating the autocad installation directory. then we could derive the fonts directory and get the correct file path. any suggestions on how to get the autocad install directory? regards, ryan odamfcapp sample contains codamfcappapp::findfile() attempting to locate acad folders based on registry information. but this is not general solution - your application using dd will work correctly only on computers with installed autocad. we intentionaly put this code not into dd but into the sample to avoid the situation when application works on developer's computer and does not work on his customer's one. sergey slezkin thanks for all your help. regards, ryan is it possible to avoid automatic call the adjustalignment() function? i set right values for the position and alignmentpoint but dd overwrites the position point. quote: originally posted by oleg k is it possible to avoid automatic call the adjustalignment() function? i set right values for the position and alignmentpoint but dd overwrites the position point. yes, it's possible. after all properties/coordinates are set to the text entity call ptext->recordgraphicsmodified(false); this will prevent position recalculation. sergey slezkin thank you, now autocad shows texts correctly. as far as i understand, if autocad will not find the same font then a text position may be a little wrong. is there the way do not use the 'position' point at all, in order autocad use only the 'alignmentpoint' and calculate the 'position' point automatically when load a drawing. autocad always use position to draw the text loaded from dwg. it recalculates the position based on alignment point only if text is modified. autocad always recalculates text position loading dxf file. if text has fit or align justification both position and alignment points are used. this can help to make a text which is displayed "correctly" with different fonts. sergey slezkin |
所有的时间均为北京时间。 现在的时间是 01:46 PM. |