几何尺寸与公差论坛

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

【转帖】document manager - add set custom properties

[复制链接]
发表于 2009-4-12 20:41:34 | 显示全部楼层 |阅读模式
document manager - add / set custom properties
hello,
i am having a bit of trouble getting the document manager to add or set custom properties to a list of parts that i have. the list of parts is actually a datagridview. the document manager can extract and display the properties just fine from my datagridview list. when it comes to writing them, nothing happens. i do not have the documents open, nor is solidworks running. can you please take a look a snippet of my code and possibly tell me what is wrong? i have included "imports swdocumentmgr" at the very top of my code.
vb.net code
const swdmkey = "myswdmkeygoeshere"
dim swdocmgr as swdmapplication
dim swdoc as swdmdocument3
dim nretval as long
dim classfac as swdmclassfactory
dim x, rowx as integer
dim prefix as string
dim lasername as string
dim v as object
classfac = createobject("swdocumentmgr.swdmclassfactory")
swdocmgr = classfac.getapplication(swdmkey)
prefix = inputbox("please enter prefix")
for x = 1 to datagridview1.rowcount - 1
laserstatus.text = "updating: " & (datagridview1.item(3, rowx).value)
statusstrip1.refresh()
lasername = prefix & "_" & datagridview1.item(1, rowx).value
msgbox(datagridview1.item(1, rowx).value)
swdoc = swdocmgr.getdocument(datagridview1.item(3, rowx).value, swdmdocumenttype.swdmdocumentpart, true, nretval)
v = swdoc.getcustompropertynames
swdoc.addcustomproperty("laserno", swdmcustominfotype.swdmcustominfotext, lasername)
swdoc.setcustomproperty("laserno", lasername)
swdoc.closedoc()
rowx = rowx + 1
next x
thank you in advance for your help!
tony szuta
cswa, cswp, cswp-smtl
try adding swdoc.save somewhere in there. probably right before swdoc.closedoc.
i'll get you eh steve, if it's the last thing i dooooo!
josh,
i have added what you suggested to my code. no luck.
tony szuta
cswa, cswp, cswp-smtl
have you tried checking the return value of the line swdoc.addcustomproperty("laserno", swdmcustominfotype.swdmcustominfotext, lasername) to see if the software thinks it was successful or not?
i'll get you eh steve, if it's the last thing i dooooo!
negative. how would i go about doing that?
thanks for your help josh.
tony szuta
cswa, cswp, cswp-smtl
retval = swdmdocument.addcustomproperty ( fieldname, fieldtype, fieldvalue)
input:
(bstr) fieldname
name of custom property
input:
(swdmcustominfotype) fieldtype
type of custom property as defined by swdmcustominfotype
input:
(bstr) fieldvalue
value for custom property
output:
(variant_bool*) retval
true if custom property is added, false if not
i'll get you eh steve, if it's the last thing i dooooo!
well when checking the return value, i have been able to determine that it is not working. it is returning "false" on each part.
tony szuta
cswa, cswp, cswp-smtl
perhaps it's because you're opening the document read-only.
swdoc = swdocmgr.getdocument(datagridview1.item(3, rowx).value, swdmdocumenttype.swdmdocumentpart, true, nretval)
document = swdmapplication.getdocument ( fullpathname, doctype, allowreadonly, result)
input:
(bstr) fullpathname
full path and filename of the document to get
input:
(swdmdocumenttype) doctype
type of document as defined by swdmdocumenttype
input:
(variant_bool) allowreadonly
true to open the document as read-only, false as read-write
output:
(swdmdocumentopenerror*) result
error as defined by swdmdocumentopenerror
output:
(iswdmdocument**) document
pointer to the swdmdocument object
i'll get you eh steve, if it's the last thing i dooooo!
nope. i tried that before i posted here this morning.
tony szuta
cswa, cswp, cswp-smtl
answer cancel my last post josh. i changed the value as you had suggested and have also changed the variable type of nretval from long to boolean.
i am not sure what did it, but whatever it was -thanks for your help!
tony szuta
cswa, cswp, cswp-smtl
intel core2 quad (q6600 @ 2.40 ghz)
nvidia quadro fx 4600 sdi
solidworks 2008 sp 4.0 (x32 & x64)
solidworks 2009 sp 2.0 (x32 & x64)
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2024-12-23 10:39 , Processed in 0.037551 second(s), 19 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2023 Discuz! Team.

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