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

assembly mate
please advise what has to be changed in the attached code so that this macro would mate any part with the default planes.
i think the following would have to be changed:
dim swapp as object to change to dim swapp as sldworks.sldworks
dim part as object to change to dim doc as modeldoc2
dim feature as object to change to dim swfeature as sldworks.feature and
following declaration to be added: dim swassem as sldworks.assemblydoc
here is the macro as recorded
dim swapp as object
dim part as object
dim selmgr as object
dim boolstatus as boolean
dim longstatus as long, longwarnings as long
dim feature as object
sub main()
set swapp = application.sldworks
set part = swapp.activedoc
set selmgr = part.selectionmanager
boolstatus = part.extension.selectbyid2("", "face", -0.05018753307439, 0.07470333306185, 0.001915977147348, false, 0, nothing, 0)
part.fixcomponent
part.clearselection2 true
boolstatus = part.extension.selectbyid2("front plane", "plane", 0, 0, 0, true, 1, nothing, 0)
boolstatus = part.extension.selectbyid2("front@230x30 ctp-1@assem1", "plane", 0, 0, 0, true, 1, nothing, 0)
set feature = part.addmate2(0, 0, false, 0.001915977147419, 0, 0, 0.001, 0.001, 0.001, 0, 0.5235987755983, 0.5235987755983, longstatus, 0, 0, 0, 0, 0, 1, false, false, false, false)
part.clearselection2 true
boolstatus = part.extension.selectbyid2("top plane", "plane", 0, 0, 0, true, 1, nothing, 0)
boolstatus = part.extension.selectbyid2("top@230x30 ctp-1@assem1", "plane", 0, 0, 0, true, 1, nothing, 0)
set feature = part.addmate2(0, 0, false, 0.01983725804587, 0, 0, 0.001, 0.001, 0.001, 0, 0.5235987755983, 0.5235987755983, longstatus, 0, 0, 0, 0, 0, 1, false, false, false, false)
part.clearselection2 true
boolstatus = part.extension.selectbyid2("right plane", "plane", 0, 0, 0, true, 1, nothing, 0)
boolstatus = part.extension.selectbyid2("right@230x30 ctp-1@assem1", "plane", 0, 0, 0, true, 1, nothing, 0)
set feature = part.addmate2(0, 0, false, 7.449832208977e-04, 0, 0, 0.001, 0.001, 0.001, 0, 0.5235987755983, 0.5235987755983, longstatus, 0, 0, 0, 0, 0, 1, false, false, false, false)
part.clearselection2 true
part.shownamedview2 "*isometric", 7
end sub
feroz mahomed
windows xp professional sp2
sworks 2009 sp2
nvidia quadro fx1500
feroz - i'm not sure i completely understand the goal, but hopefully this will help. you don't need to change the way things are declared to get it to work, but it is a good idea.
mike,
i should have mentioned that i don't have any programming knowledge.the parts that would be used for assemblies would always have a different name.i was hoping for someone to edit the recorded code.
my goal is to assemble 4 parts.the first part would be mated to the 3 default planes. the 2nd part would be mated to the top and right planes of the 1st part and also the inner face of one part would be coincident with the outer face of the other.the 3rd part would be mated in a similar way to the 2nd part.
feroz mahomed
windows xp professional sp2
sworks 2009 sp2
nvidia quadro fx1500
if your macro works and it is just the assembly and part filenames that change just alter the strings like so:
dim swapp as sldworks.sldworks
dim part as modeldoc2
dim selmgr as selectionmgr
dim boolstatus as boolean
dim assname as string
sub main()
assname = "assm1" ' set assembly name manually or get the assembly name from the document
set swapp = application.sldworks
set part = swapp.activedoc
set selmgr = part.selectionmanager
boolstatus = part.extension.selectbyid2("", "face", -0.05018753307439, 0.07470333306185, 0.001915977147348, false, 0, nothing, 0)
part.fixcomponent
part.clearselection2 true
boolstatus = part.extension.selectbyid2("front plane", "plane", 0, 0, 0, true, 1, nothing, 0)
boolstatus = part.extension.selectbyid2("front@230x30 ctp-1@" + assname, "plane", 0, 0, 0, true, 1, nothing, 0)
set feature = part.addmate2(0, 0, false, 0.001915977147419, 0, 0, 0.001, 0.001, 0.001, 0, 0.5235987755983, 0.5235987755983, longstatus, 0, 0, 0, 0, 0, 1, false, false, false, false)
part.clearselection2 true
boolstatus = part.extension.selectbyid2("top plane", "plane", 0, 0, 0, true, 1, nothing, 0)
luke,
the original code does not work. it stops at this linehighlighted in yellow)
set feature = part.addmate2(0, 0, false, 0.07938451177896, 0, 0, 0.001, 0.001, 0.001, 0, 0.5235987755983, 0.5235987755983, longstatus, 0, 0, 0, 0, 0, 1, false, false, false, false)
the macro also stops at the same line if the code is changed as per your instructions.
feroz mahomed
windows xp professional sp2
sworks 2009 sp2
nvidia quadro fx1500
that is because you have way too many parameters, alter it to the following and update the call to addmate3:
set feature = part.addmate3(0, 0, false, 0.07938451177896, 0, 0, 0.001, 0.001, 0, 0, 0, false, longstatus)
luke,
i have replaced all instances of set feature = part.addmate2.how do i update the call?
feroz mahomed
windows xp professional sp2
sworks 2009 sp2
nvidia quadro fx1500
quick
yang686526离线中   回复时引用此帖
GDT自动化论坛(仅游客可见)
 


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

高级搜索
显示模式

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

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

相似的主题
主题 主题发起者 论坛 回复 最后发表
【转帖】inserting and mating parts in an assembly yang686526 SolidWorks二次开发 0 2009-04-12 06:43 PM


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


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