几何尺寸与公差论坛------致力于产品几何量公差标准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, 10:12 AM   #1
yang686526
高级会员
 
注册日期: 06-11
帖子: 14579
精华: 1
现金: 224494 标准币
资产: 234494 标准币
yang686526 向着好的方向发展
默认 【转帖】decal macro

decal macro
hi,
i have an urgent need to get a macro working, well everything works fine except for one thing - this is an example from the api help to add a decal to a selected face - but the fitwidth and fitheight properties that are set to true don't actually check the boxes in the decal/mapping properties. i ned to get this working asap or face a lot of manual decal editing.
here is the code from the api help, which if you try it you will see that those 2 properties are not set properly.
'--------
'
' preconditions: part document is open that
' contains a model. a face on the
' model is selected. photoworks
' was selected as an add-in
' in solidworks (select tools,
' add-ins, photoworks)
'
' postconditions: decal is applied to the selected
' face.
'
'--------
option explicit
dim swapp as sldworks.sldworks
dim swmodel as sldworks.modeldoc2
dim swselmgr as sldworks.selectionmgr
dim swmodeldocext as sldworks.modeldocextension
dim swface as sldworks.face2
dim swdecal as sldworks.decal
dim swmaterial as sldworks.rendermaterial
dim boolstatus as boolean
dim strname as string
dim ndecalid as long
sub main()
set swapp = application.sldworks
set swmodel = swapp.activedoc
set swselmgr = swmodel.selectionmanager
set swmodeldocext = swmodel.extension
set swface = swselmgr.getselectedobject6(1, -1)
swmodel.clearselection2 true
' apply the decal
set swdecal = swmodeldocext.createdecal
set swmaterial = swdecal
boolstatus = swmaterial.addentity(swface)
strname = "c:\program iles\solidworks\solidworks\data\graphics\decals\logos\sw.p2d"
swmaterial.filename = strname
strname = "c:\program iles\solidworks\solidworks\data\graphics\decals\logos\sw.bmp"
swmaterial.texturefilename = strname
swmaterial.mappingtype = 0
swmaterial.fixedaspectratio = false
swmaterial.fitheight = true
swmaterial.fitwidth = true
boolstatus = swmodeldocext.adddecal(swdecal, ndecalid)
' rebuild the model to show the newly applied decal
call swmodel.rebuild(swrebuildall)
end sub
scott nelson (zander)
nelson parametrics
you are correct it does not check the boxes. you may also notice it does not set the fixedaspectratio to anything either.
the odd thing is if you get the decal again through code and check the properties they are actually set correctly:
set swdecal = swmodeldocext.createdecal
set swmaterial = swdecal
swmaterial.filename = "c:\program files\solidworks\solidworks\data\graphics\decals\logos\sw.p2d"
swmaterial.texturefilename = "c:\documents and settings\lukem\my documents\my pictures\bsod.bmp"
swmaterial.mappingtype = 0 ' label/surface
swmaterial.fixedaspectratio = true
swmaterial.fitheight = true
swmaterial.fitwidth = true
swmaterial.addentity swface
boolstatus = swmodeldocext.adddecal(swdecal, swdecal.decalid)
set swdecal = swmodeldocext.getdecal(swdecal.decalid, "")
set swmaterial = swdecal
msgbox swmaterial.fitwidth
i am guessing you are required to select the face and give it a mask id for the function to pick up on the face correctly to map to it, but i have tried a load of mask ids and combinations to no avail.
also, remove the clearselections code for now as it will benefit the code trying to solve it when the face is still selected. you should drop a line to apisupport@solidworks.com they should be able to solve it for you.

edited: 09/26/2008 at 05:31 am by luke malpass
quick
yang686526离线中   回复时引用此帖
GDT自动化论坛(仅游客可见)
回复


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

高级搜索
显示模式

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

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

相似的主题
主题 主题发起者 论坛 回复 最后发表
【转帖】custom property macro bugging ou yang686526 SolidWorks二次开发 0 2009-04-13 10:09 AM
【转帖】macro for inserting and mating a new part in an assembly yang686526 SolidWorks二次开发 0 2009-04-12 09:38 PM
【转帖】how do i slow a macro down yang686526 SolidWorks二次开发 0 2009-04-12 09:10 PM
【转帖】copy an existent sketch into a macro yang686526 SolidWorks二次开发 0 2009-04-12 08:31 PM


所有的时间均为北京时间。 现在的时间是 05:47 AM.


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