几何尺寸与公差论坛

 找回密码
 注册
查看: 770|回复: 0

【转帖】problem with put-transform2

[复制链接]
发表于 2009-4-13 13:36:21 | 显示全部楼层 |阅读模式
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
您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|Archiver|小黑屋|几何尺寸与公差论坛

GMT+8, 2024-12-23 05:03 , Processed in 0.037150 second(s), 20 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表