几何尺寸与公差论坛------致力于产品几何量公差标准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-13, 08:41 AM   #1
yang686526
高级会员
 
注册日期: 06-11
帖子: 14579
精华: 1
现金: 224494 标准币
资产: 234494 标准币
yang686526 向着好的方向发展
默认 【转帖】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
yang686526离线中   回复时引用此帖
GDT自动化论坛(仅游客可见)
回复


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

高级搜索
显示模式

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

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

相似的主题
主题 主题发起者 论坛 回复 最后发表
【转帖】accessselections failing when the component is a sub-assembly yang686526 SolidWorks二次开发 0 2009-04-12 10:56 PM
【转帖】renaming component in an assembly yang686526 SolidWorks二次开发 0 2009-04-12 10:13 PM
【转帖】examinig part component mates yang686526 SolidWorks二次开发 0 2009-04-12 08:51 PM
【转帖】renaming component in an assembly yang686526 SolidWorks二次开发 0 2009-04-12 07:27 PM


所有的时间均为北京时间。 现在的时间是 09:27 PM.


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