几何尺寸与公差论坛------致力于产品几何量公差标准GD&T (GDT:ASME)|New GPS(ISO)研究/CAD设计/CAM加工/CMM测量  


返回   几何尺寸与公差论坛------致力于产品几何量公差标准GD&T (GDT:ASME)|New GPS(ISO)研究/CAD设计/CAM加工/CMM测量 » 仿射空间:CAX软件开发(三)二次开发与程序设计 » CAD二次开发 » SolidWorks二次开发
用户名
密码
注册 帮助 会员 日历 银行 搜索 今日新帖 标记论坛为已读


回复
 
主题工具 搜索本主题 显示模式
旧 2009-04-13, 01:36 PM   #1
yang686526
高级会员
 
注册日期: 06-11
帖子: 14579
精华: 1
现金: 224494 标准币
资产: 234494 标准币
yang686526 向着好的方向发展
默认 【转帖】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
yang686526离线中   回复时引用此帖
GDT自动化论坛(仅游客可见)
回复


主题工具 搜索本主题
搜索本主题:

高级搜索
显示模式

发帖规则
不可以发表新主题
不可以回复主题
不可以上传附件
不可以编辑您的帖子

vB 代码开启
[IMG]代码开启
HTML代码关闭



所有的时间均为北京时间。 现在的时间是 01:37 PM.


于2004年创办,几何尺寸与公差论坛"致力于产品几何量公差标准GD&T | GPS研究/CAD设计/CAM加工/CMM测量"。免责声明:论坛严禁发布色情反动言论及有关违反国家法律法规内容!情节严重者提供其IP,并配合相关部门进行严厉查处,若內容有涉及侵权,请立即联系我们QQ:44671734。注:此论坛须管理员验证方可发帖。
沪ICP备06057009号-2
更多