几何尺寸与公差论坛

 找回密码
 注册
查看: 645|回复: 0

【转帖】create tangent relationship

[复制链接]
发表于 2009-4-12 20:34:57 | 显示全部楼层 |阅读模式
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
您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|Archiver|小黑屋|几何尺寸与公差论坛

GMT+8, 2024-12-23 09:04 , Processed in 0.037453 second(s), 19 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表