几何尺寸与公差论坛

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

【转帖】inserting sw bom table

[复制链接]
发表于 2009-4-13 12:20:00 | 显示全部楼层 |阅读模式
inserting sw bom table
i have been struggling with a macro to insert a sw bom table on drawings. the table shall be of the type 'toplevelonly'.
when inserting the bom table on an assembly drawing where the assembly has multiple configurations, the bom for all configurations are shown - i only want the bom table to contain the content of 1 configuration. i.e. the configuration shown in the view to which the boq table is attached.
i know i need to use bomfeature.setconfigurations in order to determine which configurations to show but i can't seem to get the settings right. all configurations are consistently shown in the table.
can anyone explain how to do this (using sw2006)?
any help is appreciated.
jorn
jorn bjarning
cswp
cad & plm consultant
sw2008 sp5 / sw2009 sp2
ni jorn,
i have the same problem in 2008, have you find the key for your problem yet?
thanks
have you done something like this:
sub insert_bom_ass()
set swapp = application.sldworks
set swmodel = swapp.activedoc
set swselmgr = swmodel.selectionmanager
set swfeatmgr = swmodel.featuremanager
set swapp = createobject("sldworks.application")
set swmodel = swapp.activedoc
set swdraw = swmodel
dim smodelname as string
set swsheet = swdraw.getcurrentsheet
set swview = swdraw.getfirstview
set swview = swview.getnextview
configuration = swview.referencedconfiguration
anchortype = swconst.swbomconfigurationanchortype_e.swbomconfigurationanchor_topright
smodelname = swview.getreferencedmodelname
sopentype = ucase(right(smodelname, 6))
if sopentype = "sldprt" then
sopentype = swdocpart
else
sopentype = swdocassembly
end if
if sopentype <> swdocpart then
tabletemplate = "l:\solidworks\bom\machinex2008.sldbomtbt"
bomtype = 2
else
tabletemplate = "l:\solidworks\bom\machinexpi&Egrave;ce2008.sldbomtbt"
bomtype = 3
end if
' insert bom table
set swbomann = swview.insertbomtable2(true, 0, 0, anchortype, bomtype, configuration, tabletemplate)
' le bom type diff&Egrave;re pour un piece ou un assemblage
swmodel.clearselection2 true
if bomtype = 2 then
your problem is by default the array of visibles is true, not false, so instead of setting visible(0) to true, you need to set all others to false.
names = swbomfeat.getconfigurations(false, visible)
visible(1) = false
visible(2) = false
visible(3) = false
etc...
boolstatus = swbomfeat.setconfigurations(false, visible, names)
obviously just get the size of the names array and do a loop, this is just to show you simply to test it
thanks .... it worked!!!
i add those lines...
qtyconfig = swbomfeat.getconfigurationcount(false)
visible(0) = true
for i = 1 to qtyconfig - 1
visible(i) = false
next i
boolstatus = swbomfeat.setconfigurations(false, visible, names)
and change the variable configuration = ""
luke, have you any idea how can i set the header font of a bom arial 6 centered and the content of the bom to be arial 9 left???
when i run my prog for a part, fonts are like i set it in my bom template, but when it's for an ass'y, the font of the header is set for every lines....
pierre-andré mongeon
*-----------------------*
junior mech. eng.
sw2007 sp4.0
sw2008 sp3.1
kbeworks
api development
edited: 06/18/2008 at 02:26 pm by pierre-andré mongeon
pierre-andré,
i see you got the problem solved. i'll write it behind the ear. i actually (once again) dropped using sw bom tables. unlike excel boms the content of a sw bom does not automatically update the content if you change the model configuration in the view to which the table is attached. you will have to manually change the referenced configuration in the bom table properties.
for many this might not be a problem but it is for me. when working with configurator solutions (as i do) this is useless. the biggest problem is that you will newer suspect the bom to show the content of another configuration.
jorn bjarning
cswp
cad & plm consultant
sw2008 sp5 / sw2009 sp2
pierre-andré,
the bom header font is defined in the bom template, and it may (for some reason) be different in assemblies than parts. try to insert it manually and see if it differs from the programmatical approach and let me know.
luke,
what i've done from now is to try inserting a bom manually with the ass'y template. worked perfectly, the header font and the bom lines font are different.
doing it with vb doesn't come out the same way, both header and bom lines are the same. for now, it's not a big deal... i made the header to be like i want me bom lines and it worked fine. it's just weird that it's not similar to insert a bom manually then programmatically.
about the part of programming you suggested me for the configuration "top level only", it will always show the first configuration of the ass'y no??
and i don't want to add a rule to prevent the conceptor from creating a config name "for bom" and modify the default (which is the first configuration). we all know that if it has to happen, it will...
thanks
jorn,
i hope we wont have to drop the sw table since our new erp will read the sw bom. we will use the bidirectionnality of 2008 to modify the bom before sending it to the erp. since we are strong in the automatisation of our drawings, it will be a large gain over the manual approch of creating the bom. i know we could do a vb entering the bom description of every parts, but with the link to the erp database, i was not confortable enough in programming all that. we'll try (what we actually do) to avoid configurations instead. i never was a big fan of configurations asking newbies to follow complexe part conception rules, and since we do custom build it's not very usefull.
pierre-andré mongeon
*-----------------------*
junior mech. eng.
sw2007 sp4.0
sw2008 sp3.1
kbeworks
api development
pierre-andré,
i was only pointing out what i believe is an error or missing functionality. if it's not a problem for you then don't take notice of my comment.
have a nice weekend and good luck with your solution!
jorn
jorn bjarning
cswp
cad & plm consultant
sw2008 sp5 / sw2009 sp2
jorn,
you have decided to drop sw bom, is it only because of the problem with configurations or you have experienced other kind of problems?
do you think that my decision to choose sw bom is good considering my needs with the erp?
have a good weekend too.
thanks for your replies.
pierre-andré mongeon
*-----------------------*
junior mech. eng.
sw2007 sp4.0
sw2008 sp3.1
kbeworks
api development
originally posted by: pierre-andré mongeon
jorn,
you have decided to drop sw bom, is it only because of the problem with configurations or you have experienced other kind of problems?
do you think that my decision to choose sw bom is good considering my needs with the erp?
thanks for your replies.
pierre-andré,
since sw added the sw bom faciity i don't know how many years ago i have evaluated it in every new release of the software because it has nice features and because i expect that sw will eliminate excel bom at some point. however i always found problems and small annoyances with the sw bom which have made me stick to the old fashioned excel bom.
in the current release (2008) i am only aware of the problem mentioned already.
with the knowledge i have about your needs in relation to erp i am not able to give you a recommendation about using sw bom or excel bom. in order to do so i need more details. but if you have verified that sw can do what you want with sw bom i would go for that.
jorn bjarning
cswp
cad & plm consultant
sw2008 sp5 / sw2009 sp2
quick
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2024-12-23 14:07 , Processed in 0.037212 second(s), 20 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2023 Discuz! Team.

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