![]() |
【转帖】problem with put-transform2
problem with put_transform2
i'm writing a student research project at the university of paderborn about an automatic movement transfer to a cad program - in this case solidworks 2007 student edition - at the moment. according to this i tried to develop an interface to the solidworks-api, which shall run the rotations within the cad program. unfortunately the result does not represent the aimed movement. perhaps i made a mistake or i have a mistake in thinking, because the movement does not follow the aimed axis at all. the rotation in the following c++ code should be around the y-axis but it is performed around an axis located somewhere in the x-z-plain (see attachment). the centerpoint of the rotation is the center of the cylinder located at the top of the cuboid, which's position is (-1250, 0, 5250): imathutility* pmathutility = null; imathpoint* pmathpoint; imathvector* pmathvector; double dangle; double darraydatapoint[3]; double darraydatavector[3]; hresult hr = s_ok; darraydatapoint[0] = -1250.0; darraydatapoint[1] = 0.0; darraydatapoint[2] = 5250.0; darraydatavector[0] = 0.0; darraydatavector[1] = 1.0; darraydatavector[2] = 0.0; dangle = 30.0; hr = swapp->igetmathutility(&pmathutility); hr = pmathutility->icreatevector(darraydatavector, &pmathvector); hr = pmathutility->icreatepoint(darraydatapoint, &pmathpoint); hr = pmathutility->icreatetransformrotateaxis( pmathpoint, pmathvector, dangle, &pxform ); hr = psldworks->get_iactivedoc2(&(pmodeldoc)); if(hr == s_ok) { hr = pmodeldoc->get_iselectionmanager(&pselectionmanager); hr = pselectionmanager->igetselectedobjectscomponent2(1, &pcomponent); hr = pmodeldoc->queryinterface(iid_iassemblydoc, (lpvoid *)&(passemblydoc)); if(hr == s_ok) { hr = pcomponent->put_transform2(pxform); hr = pmodeldoc->rebuild(3); hr = passemblydoc->updatebox(); hr = pcomponent->select(false, &retval); passemblydoc->release(); } pcomponent->release(); pselectionmanager->release(); pmodeldoc->release(); } i hope you can help me with this somehow. best regards jörg eichhorn click for full image hi jorg my suggestion at this point is that you are assuming i think that the current transform of the component is unity. possibly you could get the current transform from the component with component2->get_transform2 ( &xform ). use the mathutility to multiply that transform by the desired transform and then set the new rotation back to the component. it is hard to tell without seeing the actual results in action. also try setting the current transform of the component to unity and see what happens. also check the current transform of your object before and after you update it. also units should be in meters so your scoop looks like it must be huge!! or your origin is ~5 km away i don't know if that helps but might do. regards tom mulder. compac nw8440 intel core 2 t7400 2.16ghz ati mobility firegl v5200 solidworks 2008 sp4.0 windows xp professional sp2 quick |
所有的时间均为北京时间。 现在的时间是 01:21 AM. |