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

children of component pattern
for a component pattern (localpattern1) in an assembly i want to get a list of the child instances of the pattern. i have been using feature.getchildren which actually works fine.
my problems arise if localpattern1 or some if the component instances from localpattern1 is used in another pattern (localpattern2). if i now use getchildren on localpattern1 the result also includes some but not all component instances from the second pattern!
the api help for feature.getchildren states that it only returns "direct children" - not children of children. however that doesn't seem to be the case... (could it be a bug...?)
can anyone throw some light at me - or give me ideas on how to only get the "direct children" of a component pattern?
jorn bjarning
cswp
cad & plm consultant
sw2008 sp5 / sw2009 sp2
hi jorn
i'm writing a program that makes a list of all the parts in an assembly. it is listing folders and parts. when i go through the feature tree the patterned parts show up before the pattern feature and when i try to use the feature.getchildren i just get an empty variant. yours is the only post i could find on this subject and it sounds like you're farther than i am. did you ever get the problems solved?
hi dan,
old case - i don't remember all the details and i am not sure for what project/task i wanted to use getchildren but i think i have located the right one.
i am pretty sure i had to give up getchildren because of the problems mentioned in my first post. instead i have used swfeature.getfirstsubfeature and swsubfeature.getnextsubfeature - see the following example (fraction of a procedure). please ignore what is irrelevant for you. my need was to identify and select components with specific names in a component pattern.
'-------------
'select the component pattern
call selectobject(patternfeaturename, "comppattern", 0, 0, 0, false, 0, nothing, 0)
'get the pattern feature
set swfeature = part.selectionmanager.getselectedobject6(1, -1)
set swsubfeature = swfeature.getfirstsubfeature
'if swsubfeature it nothing then exit sub (it is nothing when the pattern amount is 1 = no children)
if swsubfeature is nothing then
exit sub
end if
'clear selection list
part.clearselection2 true
'get number of characters in component name
componentnamelength = len(componentname)
'loop as long as swsubfeature is not nothing
do while (not (swsubfeature is nothing))
subfeaturename = swsubfeature.name
'debug.print subfeaturename
'if componentname is empty or the name of the current subfeature is equal to the specified componentname
'then select the subfeature.
if componentname = "" or left(subfeaturename, componentnamelength) = componentname then
call selectobject(subfeaturename & "@" & assemblyname, "component", 0, 0, 0, true, 0, nothing, 0)
end if
'get the next subfeature
set swsubfeature = swsubfeature.getnextsubfeature
loop
jorn bjarning
cswp
cad & plm consultant
sw2008 sp5 / sw2009 sp2
thanks jorn
i finally got what i wanted by traversing the feature tree and adding the pattern names to a collection. i then created a collection for each pattern in the first collection. i then traversed the feature tree a second time and when i found a reference that belonged to a pattern i would check the parent name and add that reference to the collection for that pattern. finally when i found the patterns at the end of the tree i would print out the proper collection. a rather long and to complicated for a simple task. your information will simplify my process.
thanks again
dan miel
sw 2008
dan,
happy i could help.
cheers!
jorn bjarning
cswp
cad & plm consultant
sw2008 sp5 / sw2009 sp2
hi jorn,
could you post all your code? it seems to resolved one of my issue but i'm not really got in vb so i don't really know how to get it works.
thanks,
steph
originally posted by: stephane demers
hi jorn,
could you post all your code? it seems to resolved one of my issue but i'm not really got in vb so i don't really know how to get it works.
stephane,
it's a small part of a large project which i cannot post here. what exactly are you struggeling with?
cheers,
jorn bjarning
cswp
cad & plm consultant
sw2008 sp5 / sw2009 sp2
that's ok i resolved my issue. but i got a new problem... i'm in a drawing of a part (1 level only) how can i get the custom properties for this part ??? do you know ?
steph
originally posted by: stephane demers
that's ok i resolved my issue. but i got a new problem... i'm in a drawing of a part (1 level only) how can i get the custom properties for this part ??? do you know ?
stephane,
i see you have raised the same question in another thread (
jorn bjarning
cswp
cad & plm consultant
sw2008 sp5 / sw2009 sp2
edited: 05/06/2008 at 10:21 am by jorn bjarning
quick
yang686526离线中   回复时引用此帖
GDT自动化论坛(仅游客可见)
回复


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

高级搜索
显示模式

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

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

相似的主题
主题 主题发起者 论坛 回复 最后发表
【转帖】changing component line fon yang686526 SolidWorks二次开发 0 2009-04-13 09:40 AM
【转帖】renaming component in an assembly yang686526 SolidWorks二次开发 0 2009-04-12 10:13 PM
【转帖】examinig part component mates yang686526 SolidWorks二次开发 0 2009-04-12 08:51 PM
【转帖】renaming component in an assembly yang686526 SolidWorks二次开发 0 2009-04-12 07:27 PM
【转帖】macro to delete parts from assembliessub-assemblies yang686526 SolidWorks二次开发 0 2009-04-12 06:55 PM


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


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