几何尺寸与公差论坛

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

【转帖】options in sketchmirror

[复制链接]
发表于 2009-4-13 13:14:45 | 显示全部楼层 |阅读模式
options in sketchmirror
hello all,
i am in the process of building a macro to mirror selected sketches in the feature tree and slowly i am getting there. however, i have come up against something that is just plain odd.
i want to mirror the sketch and destroy the original (or root) entities, but after recording macros with both the copy checkbox checked and unchecked i cannot see where the option for the "mirror without copying" is set. i have trawled the api help, i have scoured the forum, but the only reference to "sketchmirror" gives no clue. if, as i suspect, the only thing to do is to delete the root entities after sketchmirror is executed then why isn't that in the recorded macro? and if someone could give a clue on how to select the root entities for deleting after the mirror whilst leaving the new ones i would be very grateful.
many thanks
robert luck
production engineer ~ cam programmer
and if someone could give a clue on how to select the root entities for deleting after the mirror whilst leaving the new ones i would be very grateful.
robert,
select all the sketch segments first:
dim swsketch as sketch
dim vsksegarr as variant
dim vskseg as variant
dim swskseg as sketchsegment
dim selmgr as selectionmgr
dim seldata as selectdata
dim boolstatus as boolean
dim part as modeldoc2
set part = swapp.activedoc
set swsketch = part.getactiveskecth2
vsksegarr = swsketch.getsketchsegments
for each vskseg in vsksegarr
set swskseg = vskseg
boolstatus = swskseg.select4(true, seldata)
next vskseg
then miror them
then delete them
for each vskseg in vsksegarr
set swskseg = vskseg
boolstatus = swskseg.select4(true, seldata)
next vskseg
part.editdelete
have fun!
mike hauptman
cad applications engineer
tegrant corporation
sw2008 sp3.1
thank you that mike. that was the approach i tried first but the sketch failed to mirror as that last item selected needs to be the mirror line. but i got there in the end with the following code
swmodel.editsketch
set swsketchmgr = swmodel.sketchmanager
set swmirrorline = swsketchmgr.createcenterline(0, 0, 0, 0, 0.01, 0)
vid = swmirrorline.getid
strmirrorline = "line" & cstr(vid(1))
intitemcount = 0
vsketchsegments = swsketch.getsketchsegments
redim preserve strsegid(ubound(vsketchsegments))
for each vsketchsegment in vsketchsegments
set swsketchsegment = vsketchsegment
vid = swsketchsegment.getid
strid = cstr(vid(1))
select case swsketchsegment.gettype
case swsketchline
strtype = "line"
case swsketcharc
strtype = "arc"
case swsketchellipse
strtype = "ellipse"
case swsketchspline
strtype = "spline"
case swsketchtext
strtype = "text"
case swsketchparabola
strtype = "parabola"
case default
debug.assert false
end select
strsegname = strtype & strid
if not strsegname = strmirrorline then
strsegid(intitemcount) = strsegname
intitemcount = intitemcount + 1
end if
next
swmodel.clearselection2 true
intitemcount = 0
do while not strsegid(intitemcount) = ""
bret = swmodelext.selectbyid2(strsegid(intitemcount), "sketchsegment", 0, 0, 0, true, 0, nothing, 0)
intitemcount = intitemcount + 1
loop
bret = swmodelext.selectbyid2(strmirrorline, "sketchsegment", 0, 0, 0, true, 2, nothing, 0)
swmodel.sketchmirror
swmodel.clearselection2 true
intitemcount = 0
do while not strsegid(intitemcount) = ""
bret = swmodelext.selectbyid2(strsegid(intitemcount), "sketchsegment", 0, 0, 0, true, 0, nothing, 0)
intitemcount = intitemcount + 1
loop
bret = swmodelext.selectbyid2(strmirrorline, "sketchsegment", 0, 0, 0, true, 0, nothing, 0)
this may be a sledgehammer to crak a nut, but i find the sketchmirror method a little awkward.
thanks again
bob
robert luck
production engineer ~ cam programmer
quick
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

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

Powered by Discuz! X3.4 Licensed

© 2001-2023 Discuz! Team.

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