![]() |
【转帖】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 |
所有的时间均为北京时间。 现在的时间是 12:17 PM. |