几何尺寸与公差论坛

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

【转帖】assembly mate

[复制链接]
发表于 2009-4-12 20:15:09 | 显示全部楼层 |阅读模式
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
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2024-12-23 05:50 , Processed in 0.035267 second(s), 19 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2023 Discuz! Team.

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