![]() |
【转帖】strange Behaviour When Copying Te
strange behaviour when copying text
strange behaviour when copying text hello, i am experiencing a very strange behavior when copying specified text entity. here is my example code: void copyandreplaceentity(oddbentityptr &pent, odrxclass *newenttype) { odrxobjectptr pnewobj = newenttype->create(); // create new object oddbentityptr pnewent = pnewobj; pnewent->copyfrom(pent); // copy content of old entity to new one pent->upgradeopen(); pent->handoverto(pnewent); // replace old entity with new in database pent->downgradeopen(); pnewent->downgradeopen(); pent.release(); // release old entity pent = pnewent; } function copyandreplaceentity creates new entity, and copies the content of old entity into new one. i use this function, to create my external exoddbtext entity and copy the content from normal oddbtext entity: class exoddbtext : public oddbtext { public: oddb_declare_members(exoddbtext); exoddbtext(){} }; odrx_dxf_define_members(exoddbtext, oddbtext, dbobject_constr, oddb::kdhl_current, oddb::kmreleasecurrent, 0, text, autocad); while i traverse through the entities in the main block, i use the following code: if (pent->iskindof(oddbtext::desc())) { oddbtextptr ptext1 = pent; odgepoint3d p1 = ptext1->position(); copyandreplaceentity(pent, exoddbtext::desc()); oddbtextptr ptext2 = pent; odgepoint3d p2 = ptext2->position(); } point p1 is (x=167.45000000000002; y=198.25000000000000) but point p2 is (x=169.32500000000002; y=198.25000000000000) as you can see, x component of point is changed. i use similar approach for almost all entities. is method copyandreplaceentity wrong, or is this a bug in the dwgdirect library? i would really appreciate, if anyone from opendwg could clarify this issue. i am sending alo an example file with such text entity. regards, tomaz attached files probably the text entity has horizontal alignment other than left (center or right). then new text entity is closed position point is recalculated based on alignment, text string, font, size etc. if calculated position differs from original it means that font used for recalculating position is different from one used for creating original text entity. maybe the font was not found and default one was substituted. sergey slezkin |
所有的时间均为北京时间。 现在的时间是 05:16 PM. |