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

mathpoint in sw drawing
i am trying to write a macro that automates drawing creation for my fixture layouts and i am having a problem inserting a block into the sheet template. the problem is that no matter what values i put in the variant array to create the mathpoint the result is corrupt. for example the variant array has values of 8 ,8, and 0 but the mathpoint.arraydata shows 2.47e-324, 8, 2.47e-324 respectively.
what am i doing wrong?
many thanks
robert luck
here is my code
sub insertblock(block as string, xpos as double, ypos as double, zpos as double)
const blockpath as string = "j:\solidworks\blocks\"
const distscale as long = 1
dim vpoint(2) as variant
dim swmathpoint as mathpoint
dim swsketchblockdef as sldworks.sketchblockdefinition
dim swblockinst as sldworks.sketchblockinstance
dim swsketchmgr as sldworks.sketchmanager
dim swdraw as sldworks.drawingdoc
dim swsheet as sldworks.sheet
set swapp = application.sldworks
set swmodel = swapp.activedoc
set swdraw = swmodel
set swsheet = swdraw.getcurrentsheet
set swselmgr = swmodel.selectionmanager
vpoint(0) = xpos * distscale
vpoint(1) = ypos * distscale
vpoint(2) = zpos * distscale
set swmathutil = swapp.getmathutility
set swmathpoint = swmathutil.createpoint(vpoint)
set swmodel = swapp.activedoc
set swsketchmgr = swmodel.sketchmanager
swmodel.setaddtodb true
swmodel.edittemplate
swmodel.editsketch
swmodel.clearselection2 true
set swsketchblockdef = swsketchmgr.makesketchblockfromfile(swmathutil.createpoint(vpoint), (blockpath & block), true, 1, 0)
swmodel.setaddtodb false
swmodel.editsheet
swmodel.graphicsredraw2
end sub
robert luck
production engineer ~ cam programmer
try putting the vpoint variable in parenthesis when you use it to create the point. i struggled with this for a while also and the trick seems to be that to pass it as a safe array you must enclose it in parens like this:
set swmathpoint = swmathutil.createpoint((vpoint))
thanks for that matthew. i have tried what you suggest but the results are just the same. i have even tried changing the swmathpoint.arraydata individually after creation, but sw just will not have it - no errors, no alarms - it is just as if the line of code didn't exist.
i am getting very frustrated with this thing.
robert luck
production engineer ~ cam programmer
further to my trials with creating a mathpoint, i have given up. the approach i am now trying is to set the block insertion point to "nothing" eg
set swsketchblockdef = swsketchmgr.makesketchblockfromfile(nothing, (blockpath & block), true, 1, 0)
then move the block instance to tthe position i require. it seem very primitive but i just cannot spend any more time getting the mathpoint to work.
robert luck
production engineer ~ cam programmer
robert, change your const distscale to .0254, as the solidworks api handles coordinates in metric by default. then, each coordinate you select will be converted from metric to inch. let me know if that works.
to defeat the wheat, go against the grain.
quick
yang686526离线中   回复时引用此帖
GDT自动化论坛(仅游客可见)
回复


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

高级搜索
显示模式

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

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

相似的主题
主题 主题发起者 论坛 回复 最后发表
【转帖】inserting sw bom table yang686526 SolidWorks二次开发 0 2009-04-13 12:20 PM
【转帖】can you modelize a drawing view yang686526 SolidWorks二次开发 0 2009-04-13 09:31 AM
【转帖】see what partassembly a drawing points to yang686526 SolidWorks二次开发 0 2009-04-12 10:19 PM
How to start SW 2007 or SW 20006 via SW API? If I have two different versions of SW yogy SolidWorks二次开发 1 2007-05-21 09:19 AM


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


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