![]() |
【转帖】add component in assembly 9vb.net0
add component in assembly (vb.net)
hi, i trying to use .addcomponent4 command to add the component in to an assemble. it's don't working. this is code that i created. const compname as string = "c:\documents and settings\administrator\desktop\shukree\thesis\test program\assembly\hinge.sldprt" dim swapp as sldworks.sldworks dim model as modeldoc2 dim swassy as assemblydoc dim swcomp as component2 model = swapp.activedoc swassy = model swcomp = swassy.addcomponent4(compname, "", 0, 0, 0) - can anyone help me? - i have one guestion. why menubar (command menu) don't show in assemblydoc & drawingdoc? it's show in partdoc only. thanks, shukree hey shukree, try to open the component before you add it to your assembly. use modeldoc2:: opendoc6 for that. as for the menubar if it is the custom menubar maybe the code was set to add it only for part documents. have a look in the swaddin.vb file (#region "ui methods") and you will see on what documents the menubar was to set to appear on. cheers, --stav. in this world i am nobody... and nobody is perfect ;) !!! --------- solidworks office 2008 sp4.0 dell precision pws390 nvidia quadro fx 3450/4000 sdi edited: 04/22/2008 at 08:17 am by stavros antoniou thanks, stavros what code in ui methods region that set for any doucument. this my ui methods #region "ui methods" public sub addcommandmgr() dim cmdgroup as icommandgroup dim ibmp as new bitmaphandler dim thisassembly as assembly thisassembly = system.reflection.assembly.getassembly(me.gettype()) cmdgroup = icmdmgr.createcommandgroup(1, "vb addin", "vb addin", "", -1) cmdgroup.largeiconlist = ibmp.createfilefromresourcebitmap("sketchcircle.toolbarlarge.bmp") cmdgroup.smalliconlist = ibmp.createfilefromresourcebitmap("sketchcircle.toolbarsmall.bmp") cmdgroup.largemainicon = ibmp.createfilefromresourcebitmap("sketchcircle.mainiconlarge.bmp") cmdgroup.smallmainicon = ibmp.createfilefromresourcebitmap("sketchcircle.mainiconsmall.bmp") 'cmdgroup.addcommanditem("createcube", -1, "create a cube", "create cube", 0, "createcube", "", 0) cmdgroup.addcommanditem("sketch the circle", -1, "display sample property manager", "show pmp", 2, "showpmp", "enablepmp", 2) cmdgroup.hastoolbar = true cmdgroup.hasmenu = true cmdgroup.activate() thisassembly = nothing ibmp.dispose() end sub public sub removecommandmgr() icmdmgr.removecommandgroup(1) end sub function addpmp() as boolean ppage = new userpmpage ppage.init(iswapp, me) end function function removepmp() as boolean ppage = nothing end function #end region thanks hey shukree, use this function call: commandgroup::showindocumenttype before you use the addcommanditen function. using that function you can specify on what document types you want your menu/toolbars to be visible in. --stav. in this world i am nobody... and nobody is perfect ;) !!! --------- solidworks office 2008 sp4.0 dell precision pws390 nvidia quadro fx 3450/4000 sdi thanks, stavros i try to use commandgroup::showindocumenttype like this: --------- public sub addcommandmgr() dim cmdgroup as icommandgroup dim ibmp as new bitmaphandler dim thisassembly as assembly thisassembly = system.reflection.assembly.getassembly(me.gettype()) cmdgroup = icmdmgr.createcommandgroup(1, "vb addin", "vb addin", "", -1) cmdgroup.largeiconlist = ibmp.createfilefromresourcebitmap("sketchcircle.toolbarlarge.bmp") cmdgroup.smalliconlist = ibmp.createfilefromresourcebitmap("sketchcircle.toolbarsmall.bmp") cmdgroup.largemainicon = ibmp.createfilefromresourcebitmap("sketchcircle.mainiconlarge.bmp") cmdgroup.smallmainicon = ibmp.createfilefromresourcebitmap("sketchcircle.mainiconsmall.bmp") cmdgroup.showindocumenttype = swconst.swdocumenttypes_e.swdocpart cmdgroup.showindocumenttype = swconst.swdocumenttypes_e.swdocassembly cmdgroup.showindocumenttype = swconst.swdocumenttypes_e.swdocdrawing 'cmdgroup.addcommanditem("createcube", -1, "create a cube", "create cube", 0, "createcube", "", 0) cmdgroup.addcommanditem("sketch the circle", -1, "display sample property manager", "show pmp", 2, "showpmp", "enablepmp", 2) cmdgroup.hastoolbar = true cmdgroup.hasmenu = true cmdgroup.activate() thisassembly = nothing ibmp.dispose() end sub ---------- it's dont't working. can you tell me what someting wrong? shukree try like this: cmdgroup.showindocumenttype = swconst.swdocumenttypes_e.swdocpart or _ swconst.swdocumenttypes_e.swdocassembly or swconst.swdocumenttypes_e.swdocdrawing --stav. in this world i am nobody... and nobody is perfect ;) !!! --------- solidworks office 2008 sp4.0 dell precision pws390 nvidia quadro fx 3450/4000 sdi edited: 04/21/2008 at 12:16 pm by stavros antoniou thanks. stavros i try to follow your suggestion it's don't working. it's show in partdoc only. the attach file below is my application (vb.net2005) thanks, shukree hey shukree, i personally dont like the commandgroup so i exclusively create my menu's and toolbars using the following comamnds... for menus: sldworks::addmenu sldworks::addmenuitem3 for toolbars: sldworks::addtoolbar4 sldworks::addtoolbarcommand2 you can explicitly specify the doc type you want your toolbar/menu to appear in with this commands using: doctype = swdoctemplatetypes_e.swdoctemplatetypeassembly or _ swdoctemplatetypes_e.swdoctemplatetypepart or _ swdoctemplatetypes_e.swdoctemplatetypenone try this instead of the command groups and let me know if it works. in this world i am nobody... and nobody is perfect ;) !!! --------- solidworks office 2008 sp4.0 dell precision pws390 nvidia quadro fx 3450/4000 sdi |
所有的时间均为北京时间。 现在的时间是 06:23 PM. |