几何尺寸与公差论坛

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

【转帖】add component in assembly 9vb.net0

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

本版积分规则

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

GMT+8, 2024-12-24 01:42 , Processed in 0.169445 second(s), 19 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2023 Discuz! Team.

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