|
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 |
|