几何尺寸与公差论坛

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

【转帖】bulk change descriptions for files in the vaul

[复制链接]
发表于 2009-4-13 09:23:08 | 显示全部楼层 |阅读模式
bulk change descriptions for files in the vault
hi
i have a couple of hundred part files in the vault of which i would like to change the description. i have a spreadsheet containing file name in the first column and the new description in the 2.
i would like to run a macro that picks up the info from the spreadsheets and change the files in the vault accordingly. i have got some vba experience and can alter code to suit my purposes, but i have no experience with the sw/pdm works api.
sure this is a common problem/task but i couldn't find suitable code yet (and info from where and how to run it, eg excel, sw, pdmworks???
using sw2006
can anybody help?
thanks
sabine
i don't think it is possible to check externally saved files into a vault using workgroup, but it would be with enterprise.
if it happens to be possible with workgroup (only way is to try it), your structure would go...
access excel sheet using excel api, iterate down the rows. for each filename do the following:
with pdm connection established call pdmwconnection.getspecificdocument to see if the document is in the vault, if it is call pdmwdocument::save to save out the file.
using dm or sw api set the custom property description to the current columns description value and save the document.
check the document back into the vault using pdmwconnection.checkin.
loop for every row.
this is all presuming that the checkin method allows checking in external files which i am pretty sure it doesn't
checkin will allow you check a file into the vault and you can even have it not bump the revision number. this is how solidworks updates all the files in the vault when upgrading to a new release i assume. anyways, i do it all the time when writing triggers for customers.
i managed to change the description for vault files with the issue a, however i can't change the description for files the are on b or 01 etc.
might have something to do with the fact that i am not actually checking out any files, since i struggle with the code a bit.
what code do i use to actually check out the file, change the description and check in again?
thanks for you help again!
sabine
as luke mentioned you can use the set pdmwdocument = pdmwconnection.getspecificdocument ( name, revision ) to get the specific revision of the document.
if you have configuration specific description, then you will have to get the pdmwconfigurations object for the pdmwdocument object, which is a collection of all of teh configurations of the document, and then get the specific configuration object.
set pdmwconfigurations = pdmwdocument.configurations
set pdmwconfiguration = pdmwconfigurations.item (configuration name)
now you would get the collection of properties and then the description property
set pdmwproperties = pdmwconfiguration.properties
set pdmwproperty = pdmwproperties.item ("description")
now that you have the description property, you set it's value by
pdmwproperty.value = new value
if the description is not a configuration specific property, it is a lot easier. you get the collection of properties by
set pdmwproperties = pdmwdocument.properties
now use the rest of the code from above to get the description property and set it's value.
wayne matus
texas engineering systems
if you want to set description for all revisions, you could omit the revsion in the pdmwconnection.getspecificdocument (name)
and get a collection of revisions of the file.
set pdmwdocuments = pdmwdocument.revisions
and then loop through each of the documents in this collection.
wayne matus
texas engineering systems
hi wayne
thanks for you help.
you unintentionally picked up another problem: configurations
unfortunately, most of the parts seem to have configuration. of which i don't know the name.
it would help to check how many configuration an item has.
i thought i can pull out that value from
set pdmwconfigurations = pdmwdocument.configurations, but it stays emppty even if there is a configuration.
any ideas?
sabine
the solidworks api has a method to get number of configuration in model.
dim swmodel as sldworks.modeldoc2
count = swmodel.getconfigurationcount
you can also get all the configuration names
dim vconfigname as variant
vconfigname = swmodel.getconfigurationnames
for i = 0 to ubound(vconfigname)
' do something
next i
wayne matus
texas engineering systems
quick
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2024-12-24 02:25 , Processed in 0.038028 second(s), 19 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2023 Discuz! Team.

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