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

addcomponent4 - random behaviour?
hi,
i am currently creating a sub routine that inserts parts into the current open assembly (pvassembly as modeldoc2 object), below is the code. there are a few other parts that need to be implement that haven't yet so disregard them (i.e. the mateto and mateside). the problem i am having is that for the parts i am working with this works great except for one part. the part is inserted in some assemblies but not in others, the error message i get is:
"attempted to read or write protected memory. this is often an indication that other memory is corrupt."
i'm at a lost and can't figure it out, any suggestions? all other parts are implemented is a similar fashion and the part file is not corrupt.
public sub addcomponenttoassembly(byref componentname as string, byref config as string, byref mateto as string, byref mateside as string)
dim errors as long
dim model as modeldoc2
dim fileerror as long
dim filewarning as long
dim swcomp as sldworks.component2
on error goto hanndler
model = iswapp.opendoc6(componentname, swdocumenttypes_e.swdocpart, swopendocoptions_e.swopendocoptions_silent, config, fileerror, filewarning)
iswapp.documentvisible(false, swdocumenttypes_e.swdocpart)
iswapp.activatedoc2(assemblytitle, true, errors)
swcomp = pvassembly.addcomponent4(componentname, "default", 0, 0, 0)
iswapp.closedoc(componentname)
'if mateto = "" then
'else
'end if
exit sub
hanndler:
msgbox(err.description)
msgbox(pvassembly.getpathname)
msgbox(componentname)
end sub
this could be with you opening the part silently you are not seeing certain errors that are preventing the component as reporting as open correctly. i actually experience a similar issue with certain files where opendoc6 opens the doc successfully, but the ierrors reports the file was not found! even though its open in front of me and the model it sent back was perfectly fine.
try taking silent off and seeing if any errors get shown for the part.
thanks for getting back to me,
i played with the opendocoption and as you suggested and i switched to loadmodel which still didn't, i thought maybe the visiblity was important so i commented out the .documentvisible property for the assembly (in another sub that creates pvassembly) and voila it works!
does anyone know how to silent load assembly creation or modification?
thanks,
ed
swapp.visible = false will be your only other option.
yang686526离线中   回复时引用此帖
GDT自动化论坛(仅游客可见)
 


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

高级搜索
显示模式

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

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

相似的主题
主题 主题发起者 论坛 回复 最后发表
三十分钟掌握stl yogy vc编程 0 2007-05-18 03:33 PM


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


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