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

selecting faces for mates
i need to replace lots of parts in lots of assemblies. i have in mind to name some faces of the parts and use those faces for editing the mates. that way when i get ready to replace some bolts i'll name the threaded part "thread" and use that for concentric mates. i'm having trouble when i try to select the face with the selectbyidid2 using"thread@bolt-3@assm ,face" it doesn't get selected. another way i tried to select the face, was to traverse the faces until i found the name, then set face to that face but that doesn't add the face to the selection for mating and i'm having trouble finding the correct selection code. i think it would be the same code needed when a face is selected and set using "set face = sm.getselectedobject5(1) ".
problem two is that i have a program that goes through an assembly and finds invalid mates then gets the existing component to that mate but i haven't figured out how to get the face that the mate goes to.
i will sure appreciate any help with this.
thanks
dan miel
2008 sp4
edited: 10/23/2008 at 12:12 am by dan miel
hi dan
attached you can find the code to select a named face
you can find this code in the api help under
"select component face by name example (vb)"
public function selectcomponentfacebyname(byval comp as sldworks.component2, byval facename as string) as sldworks.face2
dim body as object
dim face as sldworks.face2
dim curfacename as string
dim retval as boolean
const swselcomponents = 20
set body = comp.getbody() ' get the component body
set face = body.getfirstface
comp.deselect
' traverse thru all body faces
do while not face is nothing
curfacename = assdoc.getentityname(face)
if (curfacename = facename) then
face.select (0) ' select the face
set body = nothing
set selectcomponentfacebyname = face
exit do
end if
set face = face.getnextface
loop
end function
for your second problem maybe the code in the api help under
"get mates and mate entities example (vb)"
helps
regards
heinz
you may also find it beneficial to understand how the selectbyid2 strings should be constructed. i wrote a guide
luke
i see that you copied the information from your book to your webpage. i have looked at that page several times and i retried changing the id from "thread@bolt-3@assm1 ,face" to "thread@extrude1@bolt-3@assm1 ,face" but the selectbyid still doesn't pick it up. i reference your book quite often, it is helpful.
heinz
i used that example to find the face but after i find the two faces i'll need to select them both to edit the mate. if i make a macro to add or edit mates, there are two faces selected just before the mate is added. i'm having trouble finding a selection method to select both face1 and face2.
thanks for your input.
dan
hi dan
i made that this way
set f1 = selectcomponentfacebyname(comp1, "k_mantel")
set f2 = selectcomponentfacebyname(schln, "schln_mantel")
f1.select (0)
f2.select (1)
assdoc.addmate3 swmateconcentric, swmatealignaligned, false, 0, 0, 0, 0, 0, 0, 0, 0, false, longstatus
hope this helps
p.s.
sorry about my english :-(
heinz
i created a program this weekend that gets the faces and edits the mate using the code you put here, thank you. one of the things that was confusing me was that there needs to be a third selection for the editmate line: m1.select(3), where the m1 is the mate to be edited.
luke
in your book you say to use select4 for selecting faces. is the select4 a better code than just select? i did notice that select4 returns the data object also, so is that the reason for select4?
thanks
dan miel
quick
yang686526离线中   回复时引用此帖
GDT自动化论坛(仅游客可见)
回复


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

高级搜索
显示模式

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

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

相似的主题
主题 主题发起者 论坛 回复 最后发表
【转帖】select all faces within a bo yang686526 SolidWorks二次开发 0 2009-04-13 02:10 PM
【转帖】maco to select all faces yang686526 SolidWorks二次开发 0 2009-04-13 12:34 PM
【转帖】how to get the name of the reference plane yang686526 SolidWorks二次开发 0 2009-04-13 11:58 AM


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


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