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

create tangent relationship
is it possible to create tangent realtionships in a sketch between all horizontal & vertical lines and their adjoining radii by using a macro? my intention is to fully define tha sketch by dimensioning it myself as the fully define function is not suitable for my type of sketches.
feroz mahomed
windows xp professional sp2
sworks 2009 sp2
nvidia quadro fx1500
hey feroz,
are you creating the sketch with the code too? if so you can use the sketch segments of the sketch and add the relations you require.
to add tangent relationships use the following:
modeldoc.sketchaddconstraints("sgtangent")
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
stavros,
i bring in an iges part and create a sketch by using the convert entities function.i then delete all the " on edge " relations.
feroz mahomed
windows xp professional sp2
sworks 2009 sp2
nvidia quadro fx1500
errr from the top of my head...
from the sketch you can get all the sketch segments (sketch::getsketchsegments) and using the sketchsegment::gettype you can see the type of each of the sketch segments to differentiate between lines and other sketch segments.
now i am not sure if the sketch segments (that are returned in an array) are returned continuously i.e. intersecting segments one after the other...
i will try this tomorrow and i'll give you some feedback. in the meantime if you can upload a here an example of a sketch i can play with that will be great.
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
stav,
attached please find part as requested.
feroz mahomed
windows xp professional sp2
sworks 2009 sp2
nvidia quadro fx1500
option explicit
sub main()
dim swapp as sldworks.sldworks
dim swmodel as sldworks.modeldoc2
dim swselmgr as sldworks.selectionmgr
dim swfeat as sldworks.feature
dim swsketch as sldworks.sketch
dim vsketchsega as variant
dim vsketchsegl as variant
dim swsketchseg as sldworks.sketchsegment
dim swseldata as sldworks.selectdata
dim i as long
dim l as sldworks.sketchline
dim a as sldworks.sketcharc
dim j as long
dim a1 as sldworks.sketchpoint
dim a2 as sldworks.sketchpoint
dim l1 as sldworks.sketchpoint
dim l2 as sldworks.sketchpoint
dim c as long
set swapp = application.sldworks
set swmodel = swapp.activedoc
set swselmgr = swmodel.selectionmanager
set swseldata = swselmgr.createselectdata
set swfeat = swselmgr.getselectedobject6(1, 0)
set swsketch = swfeat.getspecificfeature2
' edit sketch
swmodel.editsketch
vsketchsega = swsketch.getsketchsegments
vsketchsegl = swsketch.getsketchsegments
for i = 0 to ubound(vsketchsega)
set swsketchseg = vsketchsega(i)
select case swsketchseg.gettype
case swsketchline
set l = swsketchseg
case swsketcharc
set a = swsketchseg
set a1 = a.getstartpoint2
set a2 = a.getendpoint2
for j = 0 to ubound(vsketchsegl)
set swsketchseg = vsketchsegl(j)
select case swsketchseg.gettype
case swsketchline
set l = swsketchseg
set l1 = l.getstartpoint2
set l2 = l.getendpoint2
a.select false
l.select true
c = 0
if abs(l1.x - l2.x) < 0.0001 or abs(l1.y - l2.y) < 0.0001 then
if l1.x = a1.x and l1.y = a1.y and l1.z = a1.z then
swmodel.sketchaddconstraints "sgtangent"
c = c + 1
end if
if l1.x = a2.x and l1.y = a2.y and l1.z = a2.z then
swmodel.sketchaddconstraints "sgtangent"
c = c + 1
end if
if l2.x = a1.x and l2.y = a1.y and l2.z = a1.z then
swmodel.sketchaddconstraints "sgtangent"
c = c + 1
end if
if l2.x = a2.x and l2.y = a2.y and l2.z = a2.z then
swmodel.sketchaddconstraints "sgtangent"
c = c + 1
end if
end if
if c > 1 then exit for
end select
next j
end select
next i
end sub
edited: 03/09/2009 at 07:17 pm by ivana kolin
ivana,
thank you. this macro works like a charm. it would save me a lot of time.
feroz mahomed
windows xp professional sp2
sworks 2009 sp2
nvidia quadro fx1500
quick
yang686526离线中   回复时引用此帖
GDT自动化论坛(仅游客可见)
回复


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

高级搜索
显示模式

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

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

相似的主题
主题 主题发起者 论坛 回复 最后发表
【转帖】angle to tangent of circle - c-dmis user forum.txt huangyhg PC-DMIS 0 2009-04-06 06:02 PM
【转帖】angle to tangent of circle - c-dmis user forum.txt huangyhg PC-DMIS 0 2009-04-06 05:22 PM


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


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