几何尺寸与公差论坛------致力于产品几何量公差标准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-12, 08:41 PM   #1
yang686526
高级会员
 
注册日期: 06-11
帖子: 14579
精华: 1
现金: 224494 标准币
资产: 234494 标准币
yang686526 向着好的方向发展
默认 【转帖】document manager - add set custom properties

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


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

高级搜索
显示模式

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

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

相似的主题
主题 主题发起者 论坛 回复 最后发表
【转帖】custom properties bom --- yang686526 SolidWorks二次开发 0 2009-04-12 08:36 PM
【转帖】setting custom properties yang686526 SolidWorks二次开发 0 2009-04-12 07:36 PM
【转帖】inserting and mating parts in an assembly yang686526 SolidWorks二次开发 0 2009-04-12 06:43 PM
【转帖】document manager - add set custom properties yang686526 SolidWorks二次开发 0 2009-04-12 06:00 PM


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


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