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

macro
i am having difficulty with creating ellipses with a macro. after i create the partial ellipse and revolve it, i run the macro and i receive an error saying 'wrong number of arguments or invalid property assignment'. anyone know why this error comes up?
i have seen the macro recorder record the wrong number of arguments for some methods. look at the api help file to find out what arguments it needs. not sure if this is the method that was recorded, but here is what i found in the api help for partial ellipse.
retval = sketchmanager.createellipticalarc ( xc, yc, zc, xmajor, ymajor, zmajor, xminor, yminor, zminor, x1, y1, z1, x2, y2, z2, direction)
input:
(double) xc
x coordinate for the ellipse center point
input:
(double) yc
y coordinate for the ellipse center point
input:
(double) zc
z coordinate for the ellipse center point
input:
(double) xmajor
x coordinate for a point on the ellipse and on the major axis
input:
(double) ymajor
y coordinate for a point on the ellipse and on the major axis
input:
(double) zmajor
z coordinate for a point on the ellipse and on the major axis
input:
(double) xminor
x coordinate for a point on the ellipse and on the minor axis
input:
(double) yminor
y coordinate for a point on the ellipse and on the minor axis
input:
(double) zminor
z coordinate for a point on the ellipse and on the minor axis
input:
(double) x1
x coordinate for counter-clockwise elliptical arc start point
input:
(double) y1
y coordinate for counter-clockwise elliptical arc start point
input:
(double) z1
z coordinate for counter-clockwise elliptical arc start point
input:
(double) x2
x coordinate for counter-clockwise elliptical arc end point
input:
(double) y2
y coordinate for counter-clockwise elliptical arc end point
input:
(double) z2
z coordinate for counter-clockwise elliptical arc end point
input:
(short) direction
+1 : go from the start point to the end point in a counter-clockwise direction
-1 : go from the start point to the end point in a clockwise direction
output:
(lpsketchsegment) retval
sketch segment for the elliptical arc
wayne matus
texas engineering systems
for example:
option explicit
dim swapp as sldworks.sldworks
dim swmodel as modeldoc2
dim sm as sketchmanager
sub main()
set swapp = application.sldworks
set swmodel = swapp.activedoc
if swmodel is nothing then
exit sub
end if
set sm = swmodel.sketchmanager
if sm is nothing then
exit sub
end if
sm.createellipticalarc 0, 0, 0, 0.02, 0, 0, 0, 0.01, 0, 0, 0.01, 0, 0.02, 0, 0, -1
end sub
hi
this is the line code i get when after i record making the ellispe. i added the -1 at the end to see if it was missing an argument. still get the same error. i don't know what vb is for:
part.createellipsevb -0.001791025641026, 0.02134305555556, 0, -0.001791025641026, 0.05776057692308, 0, -0.02417884615385, 0.02134305555556, 0, 0, -0.01495774268682, 0, 0, 0.05764385379793, 0, -1
recorded macro output should always be viewed with suspicion. rarely yields the best way to accomplish a task.
perhaps "createellipticalarcbycentervb"?
shawn,
it looks like you are using solidworks 2007. i get the same createellipsevb method when i record macro in 2007. in 2008 i get what luke and i mentioned. i looked in the 2007 api help and there was not a createellipsevb method listed, but i did find a createellipticalarc2 method. you should be able to change the line you mentioned to:
part.createellipticalarc2 -0.001791025641026, 0.02134305555556, 0, -0.001791025641026, 0.05776057692308, 0, -0.02417884615385, 0.02134305555556, 0, 0, -0.01495774268682, 0, 0, 0.05764385379793, 0
note it does not need the -1 at the end.
wayne matus
texas engineering systems
thanks will try
hi, luke,
your codes don't work in vb.net 2008, do you have a way to fix it?
the code i provided was vb not vb.net, it is easy enough to convert though:
create a new windows forms application, add references to sldworks as required and create a button on the form and add an onclick event, then your coding should look like this:
imports sldworks
imports swcommands
imports swconst
imports swpublished
public class form1
private sub button1_click(byval sender as system.object, byval e as system.eventargs) handles button1.click
dim swapp as sldworks.sldworks
dim swmodel as modeldoc2
dim sm as sketchmanager
swapp = new sldworks.sldworks
swmodel = swapp.activedoc
if swmodel is nothing then
exit sub
end if
sm = swmodel.sketchmanager
if sm is nothing then
exit sub
end if
sm.createellipticalarc(0, 0, 0, 0.02, 0, 0, 0, 0.01, 0, 0, 0.01, 0, 0.02, 0, 0, -1)
end sub
end class
yang686526离线中   回复时引用此帖
GDT自动化论坛(仅游客可见)
 


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

高级搜索
显示模式

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

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



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


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