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

shaft programming.......
i have program 2 shaft with different diameter.............. when i insert data for example 6m to the shaft1 the shaft is show the correct diameter.........but the problem is the 2nd diameter is not show the 6m diameter.....the shaft will show 6.8m.......here is my code....
private sub cmdpapar_click()
set swapp = application.sldworks
set part = swapp.activedoc
set selmgr = part.selectionmanager
swapp.activedoc.activeview.framestate = 1
part.clearselection2 true
dim skcircle as object
set skcircle = part.sketchmanager.createcircle(0, 0, 0, txt1.text, 5.605184485944e-04, 0)
part.clearselection2 true
boolstatus = part.extension.selectbyid2("arc1", "sketchsegment", 0, 0, 0, false, 0, nothing, 0)
part.featuremanager.featureextrusion2 true, false, false, 0, 0, txt2.text, txt2.text, false, false, false, false, 0.01745329251994, 0.01745329251994, false, false, false, false, 1, 1, 1, 0, 0, false
part.selectionmanager.enablecontourselection = 0
part.clearselection2 true
set swapp = application.sldworks
set part = swapp.activedoc
set selmgr = part.selectionmanager
swapp.activedoc.activeview.framestate = 1
set skcircle = part.sketchmanager.createcircle(0, 0, 0, txt3.text, -1.244946376429, 0)
part.clearselection2 true
boolstatus = part.extension.selectbyid2("arc1", "sketchsegment", 0, 0, 0, false, 0, nothing, 0)
part.featuremanager.featureextrusion true, false, true, 0, 0, txt4.text, txt4.text, false, false, false, false, 0.01745329251994, 0.01745329251994, false, false, false, false, 1, 1, 1
part.selectionmanager.enablecontourselection = 0
part.clearselection2 true
end sub
i'm not exactly sure what your use of this is, but i have changed your code a bit and will try to explain how this works.
option explicit
sub main()
dim swapp as sldworks.sldworks
dim part as sldworks.modeldoc2
dim sketchmanager as sldworks.sketchmanager
dim selmgr as sldworks.selectionmgr
dim boolstatus as boolean
set swapp = application.sldworks
set part = swapp.activedoc
set sketchmanager = part.sketchmanager
set selmgr = part.selectionmanager
swapp.activedoc.activeview.framestate = 1
part.clearselection2 true
dim skcircle as object
'** creates a circle sketch at the x,y,z location 0, 0, 0. the radius of the circle, in inches, is txtradius1.text :: note the other x,y,z values are 0
set skcircle = sketchmanager.createcircle(0, 0, 0, (txtradius1.text / 39.3700787) / 2, 0, 0)
part.clearselection2 true
'** the arc is selected and then subsequently constrained as fixed for the extrusions
boolstatus = part.extension.selectbyid2("arc1", "sketchsegment", 0, 0, 0, false, 0, nothing, 0)
part.sketchaddconstraints "sgfixed"
'** extrudes the circle in one direction, towards the user, of length equal to txtextrustionlength1.text
part.featuremanager.featureextrusion2 true, false, false, 0, 0, txtextrusionlength1.text / 37.3700787, 0, false, false, false, false, 0, 0, false, false, false, false, 1, 1, 1, 0, 0, false
part.selectionmanager.enablecontourselection = 0
part.clearselection2 true
'** creates a circle sketch at the x,y,z location 0, 0, 0. the radius of the circle, in inches, is txtradius2.text :: note the other x,y,z values are 0
set skcircle = sketchmanager.createcircle(0, 0, 0, (txtradius2.text / 39.3700787) / 2, 0, 0)
part.clearselection2 true
'** the arc is selected and then subsequently constrained as fixed for the extrusions
boolstatus = part.extension.selectbyid2("arc1", "sketchsegment", 0, 0, 0, false, 0, nothing, 0)
part.sketchaddconstraints "sgfixed"
'** extrudes the circle in one direction, away from the user, of length equal to txtextrustionlength2.text
part.featuremanager.featureextrusion2 true, false, true, 0, 0, txtextrusionlength2.text / 37.3700787, 0, false, false, false, false, 0, 0, false, false, false, false, 1, 1, 1, 0, 0, false
part.selectionmanager.enablecontourselection = 0
end sub
the reason it was returning two different values before, was the conflicting x,y,z size of the created circles.
referencing the following areas in the help document may also help you.
sketchmanager::createcircle
featuremanager::featureextrusion2
these examples will tell you what each of the true/false as well as numeric values mean in each of those lines of code.
edited: 10/14/2008 at 11:09 am by blake dahle
quick
yang686526离线中   回复时引用此帖
GDT自动化论坛(仅游客可见)
回复


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

高级搜索
显示模式

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

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

相似的主题
主题 主题发起者 论坛 回复 最后发表
【转帖】programming newbie w a yang686526 SolidWorks二次开发 0 2009-04-13 01:40 PM
【转帖】drawing line with programming yang686526 SolidWorks二次开发 0 2009-04-13 10:32 AM
【转帖】beginning programming yang686526 SolidWorks二次开发 0 2009-04-13 09:15 AM


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


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