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

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
yang686526离线中   回复时引用此帖
GDT自动化论坛(仅游客可见)
 


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

高级搜索
显示模式

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

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



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


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