![]() |
【转帖】help on oddbdatabaseinser
help on od?db?database::?insert
help on oddbdatabase::insert hi, i am trying to insert a file into another with the following code: code: bool codahelper::insert(lpctstr filename, double scale, double rotation ) { oddbdatabaseptr pdb; try { pdb = m_svcs.readfile( filename, false, false, oda::ksharedenyno ); } catch(oderror& e) { m_strerror = e.description().c_str(); return false; } odgematrix3d xform; // scale xform = odgematrix3d::scaling(scale); // rotation xform.settorotation(rotation, odgevector3d(0,0,1)); // insertion point xform.settranslation(odgevector3d(0,0,0)); m_pdb->insert(xform, pdb); return true; } i have 2 problems: 1) the file is inserted but it's not scaled. what is the right way scale an insert? 2) when i insert a drawing with some dimensions, if i rotate this drawing (90 degrees for example), the dimansions of the inserted drawing change. it seems like they loose the origins. is it a bug? thanks for any help, vinicius last edited by vinicius pontes; 30th june 2004 at 09:37 amfff">. 1. settorotation initializes the matrix to represent the rotation. previous values of the matrix are lost. to construct a matrix containing both scale and rotation you need multiply 2 matrixes. 2. when a drawing is inserted with non-zero rotation this is not equevalent to setting rotation to a block reference. transformby is applyied to entities (dimensions). definition points are transformed but if dimension text for example should be horizontal according to dimension variables (style or overrides) it remains horizontal. for ordinate dimensions even measured value will be changed. during this operation dimension blocks (representing dimension appearence) are recomputed. this also may result in changed appearence. to decide is it dd bug or not your specific case should be analized. (you can check it applying rotate command to your dimension in autocad - some dimensions would change their appearence). sergey slezkin thanks for your answer! but, 1) i understood that settoratation and also settoscaling initializes the matriz. i saw it when i reorder the calls, like the code below, and only the scaling was applyed. i just don't know yet how to apply both. could you give me a sample? code: odgematrix3d xform; xform.settorotation(rotation, odgevector3d(0,0,1)); xform.settoscaling(scale); 2) i made some tests with autocad (r14) and also with dwgdirect. see the results in the file in attachment. in the tests i made, first of all i create a drawing (drawing.dwg) which i used to insert in other drawings. this drawing is just a box with 2 dimensions: one horizontal and another vertical. i inserted it into another drawing with 45 degrees of rotation using autocad and i also inserted it with 0 degrees and rotaded 45 degrees (using autocad rotate command). in both cases, nothing changed with my dimensions. in a third case, i inserted it with a rotation of 45 degrees using dwgdirect. in this case the dimensions changed appearence. vinicius attached files (20.9 kb, 5 views) 1. code: odgematrix3d mtrans( odgematrix3d::translation(origin) * odgematrix3d::rotation(angle, odgevector3d::kzaxis) * odgematrix3d::scaling(scale) ); 2. this is dd bug. it effects rotated dimensions. sergey slezkin thank you! |
所有的时间均为北京时间。 现在的时间是 12:44 PM. |