几何尺寸与公差论坛------致力于产品几何量公差标准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-12, 10:40 PM   #1
yang686526
高级会员
 
注册日期: 06-11
帖子: 14579
精华: 1
现金: 224494 标准币
资产: 234494 标准币
yang686526 向着好的方向发展
默认 【转帖】ransform face coordinates to assembly9global0 coordinates

transform face coordinates to assembly(global) coordinates
hello,
i have an assembly with some parts.
i select a face and try to get the face normal and a point on the face in assembly coordinates.
dim swselmgr as iselectionmgr = nothing
dim mathutil as imathutility = nothing
dim myface as iface2
dim facecmp as icomponent2
dim facefeat as ifeature = nothing
dim vecarr as object = nothing
dim transface as imathtransform = nothing
dim mathfacenormalvec as imathvector = nothing
dim dfacenormalvec as double()
dim mathpntonface as imathpoint = nothing
dim dpntonface as double()
swselmgr = myownclass.getrootmodeldoc().selectionmanager
mathutil = myownclass.swapplicationobj.getmathutility()
facefeat = myface.getfeature()
facefeat.select2(false, -1)
facecmp = swselmgr.getselectedobjectscomponent3(1, -1)
dfacenormalvec = myface.normal
transface = facecmp.transform2
mathfacenormalvec = mathutil.createvector(dfacenormalvec)
mathfacenormalvec = mathfacenormalvec.multiplytransform(transface)
vecarr = mathfacenormalvec.arraydata
' get any point on face
dpntonface = myface.getclosestpointon(0.0, 0.0, 0.0)
mathpntonface = mathutil.createpoint(dpntonface)
mathpntonface = mathpntonface.multiplytransform(transface)
dpntonface = mathpntonface.arraydata
the point that i recieve lies on a parallel plane which contains the origin of my part and not on the selected plane.
i think my error is, that i have not transformed the face coordinates
to part coordinates. i don´t know how to get the transformation matrix for the face. any idea ?
thanks in advance,
matthias senff
matthias,
do you want the assembly coordinates of your selection?
if so just use:
selectionmgr::getselectionpoint2
have a look at the examples there too if you need more assistance.
from the description of the function you get this:
"this method gets the selected point's coordinates, in model space, from the currently selected object." that is what you want if i understood correclty...
cheers,
--stav.
in this world i am nobody...
and nobody is perfect !!!
---------
solidworks office 2008 sp4.0
dell precision pws390
nvidia quadro fx 3450/4000 sdi
thanks stav,
this helps me with my actual problem, but sooner or later i'll have to examine the relation of the faces, lines and points in my parts and i will not always have a selection point. one idea is to use the getcoordinatesystemtransformbyname(namein) from imodeldocextension, but i don't know if this works with the face and also how to get the correct name for the parameter.
hi matthias,
i wrote some code in the past that takes the x,y,z coordinates of a reference point on a part in an assembly, and it translates them to x,y,z with respect to the assembly. below find some of the code. as a pre-requisite i had that the user has to select the reference points (so that things are clear for you)
hope it helps,
--stav.
code:
dim pfeat1 as sldworks.feature
dim pfeat2 as sldworks.feature
dim ent as sldworks.entity
dim parcomp1 as sldworks.component2
dim parcomp2 as sldworks.component2
dim mtrans1 as sldworks.mathtransform
dim mtrans2 as sldworks.mathtransform
dim refpoint1 as sldworks.refpoint
dim refpoint2 as sldworks.refpoint
dim mpoint1 as sldworks.mathpoint
dim mpoint2 as sldworks.mathpoint
dim newmpoint1 sldworks.as mathpoint
dim newmpoint2 sldworks.as mathpoint
dim arraydata1 as variant
dim arraydata2 as variant
pfeat1 = selmgr.getselectedobject6(1, 0)
ent = pfeat1
parcomp1 = ent.getcomponent
mtrans1 = parcomp1.transform2
refpoint1 = pfeat1.getspecificfeature2()
mpoint1 = refpoint1.getrefpoint
newmpoint1 = mpoint1.multiplytransform(mtrans1)
arraydata1 = newmpoint1.arraydata
x1 = arraydata1(0)
y1 = arraydata1(1)
z1 = arraydata1(2)
pfeat2 = selmgr.getselectedobject6(2, 0)
ent = pfeat2
parcomp2 = ent.getcomponent
mtrans2 = parcomp2.transform2
refpoint2 = pfeat2.getspecificfeature2()
mpoint2 = refpoint2.getrefpoint
newmpoint2 = mpoint2.multiplytransform(mtrans2)
arraydata2 = newmpoint2.arraydata
x2 = arraydata2(0)
y2 = arraydata2(1)
z2 = arraydata2(2)
in this world i am nobody...
and nobody is perfect !!!
---------
solidworks office 2008 sp4.0
dell precision pws390
nvidia quadro fx 3450/4000 sdi
you may want to take a look at the getinitialdist function of the distance mate macro at
answer thanks for the answers.
matthias
quick
yang686526离线中   回复时引用此帖
GDT自动化论坛(仅游客可见)
回复


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

高级搜索
显示模式

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

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

相似的主题
主题 主题发起者 论坛 回复 最后发表
【转帖】face name of extruded body yang686526 SolidWorks二次开发 0 2009-04-12 08:53 PM


所有的时间均为北京时间。 现在的时间是 02:50 AM.


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