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

drawing line with programming
hi......i'm new in solidwork...............i have to do programming with vba in solid work for my final year project......let say i want to draw line with 5 cm......when i run my programming the line will show in solidwork........can someone hlp me how to do this......i'm really appreciate for the help.....
dim swapp as object
dim part as modeldoc2
sub main()
set swapp = application.sldworks
set part = swapp.activedoc
part.sketchmanager.createline(0#, 0#, 0#, 0.05, 0#, 0#)
end sub
part.sketchmanager.createline(0#, 0#, 0#, 0.05, 0#, 0#)
an error occured in this line.......
try removing the brackets. so it should be like this
part.sketchmanager.createline 0#, 0#, 0#, 0.05, 0#, 0#
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
i have tried.......when i run it say object variable or with block variable not set.........i've just copy the codding and paste it to code........if i miss the important part..........
1. select a plane
2. start a sketch
3. start recording a macro
4. draw a line
5. dimension it 5mm
6. stop recording the macro
7. edit the macro to see the code
cad monkey
sw2k7 sp5.0
sw2k8 sp3.0
edited: 08/08/2008 at 09:07 am by dan eldred
dim swapp as sldworks.sldworks
dim part as modeldoc2
sub main()
set swapp = application.sldworks
set part = swapp.activedoc
part.sketchmanager.insertsketch true
part.sketchmanager.createline 0#, 0#, 0#, 0.05, 0#, 0#
end sub
i have applied the to record the lines and modified the codding, so when i put 5mm in my program the lines will appear..................but the problem is the program can communicate with the file that it record......how to build a program so that it can communicate with any files in solid work.........
dim swapp as sldworks.sldworks
dim part as modeldoc2
sub main()
set swapp = application.sldworks
set part = swapp.activedoc
part.sketchmanager.insertsketch true
part.sketchmanager.createline 0#, 0#, 0#, 0.05, 0#, 0#
end sub
tq luke............this code is usefull.........
i a confuse with this code
part.sketchmanager.createline 0#, 0#, 0#, 0.05, 0#, 0#
this code means that the line will create in horizontal........where should i change the value so that the line will create vertical.....
and finally i want to operate it to become the rectangular.........
hi zam
have a look in the solidworks api help every function is documented:
syntax (ole automation)
retval = sketchmanager.createline ( x1, y1, z1, x2, y2, z2)
input:
(double) x1
x coordinate of the line start point
input:
(double) y1
y coordinate of the line start point
input:
(double) z1
z coordinate of the line start point
input:
(double) x2
x coordinate of the line end point
input:
(double) y2
y coordinate of the line end point
input:
(double) z2
z coordinate of the line end point
output:
(lpsketchsegment) retval
sketch segment for the line
if you want a rectangle call the function four times with the appropraite values.
regards
tom mulder.
compac nw8440
intel core 2 t7400 2.16ghz
ati mobility firegl v5200
solidworks 2008 sp4.0
windows xp professional sp2
ps. if you run functions as a macro you will need to omit the brackets
regards
tom mulder.
compac nw8440
intel core 2 t7400 2.16ghz
ati mobility firegl v5200
solidworks 2008 sp4.0
windows xp professional sp2
yang686526离线中   回复时引用此帖
GDT自动化论坛(仅游客可见)
回复


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

高级搜索
显示模式

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

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

相似的主题
主题 主题发起者 论坛 回复 最后发表
【转帖】cant make 3d-line snap to heli yang686526 SolidWorks二次开发 0 2009-04-13 09:34 AM
【转帖】line name yang686526 SolidWorks二次开发 0 2009-04-12 09:33 PM


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


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