Modify op path2: Difference between revisions

From Macros Wiki
Jump to navigationJump to search
ConnerO (talk | contribs)
No edit summary
ConnerO (talk | contribs)
No edit summary
 
(2 intermediate revisions by the same user not shown)
Line 18: Line 18:
| 
| 
|-
|-
|get_op_num_feat opnum, numfeat ||   ! get the number of features
|get_op_num_feat opnum, numfeat ||! get the number of features
|-
|-
|if numfeat<1 then goto done ||     ! make sure there is at least 1
|if numfeat<1 then goto done ||! make sure there is at least 1
|-
|-
|&nbsp;
|&nbsp;
|-
|-
|define_path_list 1  ||             ! create path list
|define_path_list 1  ||! create path list
|-
|-
|&nbsp;
|&nbsp;
|-
|-
|select_op_path_type main      ||   ! select the main path
|select_op_path_type main      ||! select the main path
|-
|-
|get_op_path opnum get a copy of the op path
|get_op_path opnum get a copy of the op path
Line 38: Line 38:
|<nowiki>get_op_path_start opnum, xs, ys, zs</nowiki>
|<nowiki>get_op_path_start opnum, xs, ys, zs</nowiki>
|-
|-
|<nowiki>create_path 1, xs, ys, zs</nowiki>      ||   ! start a new path
|<nowiki>create_path 1, xs, ys, zs</nowiki>      ||! start a new path
|-
|-
|&nbsp;
|&nbsp;
Line 53: Line 53:
|-
|-
|&nbsp;
|&nbsp;
|-
|}
|:get_op_feat_type opnum, ifeat, itype
:get_op_feat_type opnum, ifeat, itype
|-
 
|:progress_set (ifeat / numfeat)
:progress_set (ifeat / numfeat)
|-
{|
|&nbsp;
|&nbsp;
|-
|}
|:if itype = feat_type_line then goto edit_line
:if itype = feat_type_line then goto edit_line
|-
 
|:if itype = feat_type_arc  then goto edit_arc
:if itype = feat_type_arc  then goto edit_arc
|-
{|
|&nbsp;
|&nbsp;
|-
|-
Line 69: Line 69:
|-
|-
|&nbsp;
|&nbsp;
|-
|}
|:add_path_feat 1, 0, ifeat ||    ! copy this feat to the new path
:add_path_feat 1, 0, ifeat &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;! copy this feat to the new path
|-
{|
|&nbsp;
|&nbsp;
|-
|}
|:continue
:continue
|-
{|
|&nbsp;
|&nbsp;
|-
|-
|<nowiki>:</nowiki>edit_line
|<nowiki>:</nowiki>edit_line
|-
|}
|:get_op_feat_start    opnum, ifeat, xs, ys, zs
:get_op_feat_start    opnum, ifeat, xs, ys, zs
|-
 
|:get_op_feat_end      opnum, ifeat, xe, ye, ze
:get_op_feat_end      opnum, ifeat, xe, ye, ze
|-
 
|:get_op_feat_angles  opnum, ifeat, ang1, ang2, ang3
:get_op_feat_angles  opnum, ifeat, ang1, ang2, ang3
|-
{|
|&nbsp;
|&nbsp;
|-
|}
|:x1 = xs + ((xe - xs) / 2)
:x1 = xs + ((xe - xs) / 2)
|-
 
|:y1 = ys + ((ye - ys) / 2)
:y1 = ys + ((ye - ys) / 2)
|-
 
|:z1 = zs + ((ze - zs) / 2)
:z1 = zs + ((ze - zs) / 2)
|-
{|
|&nbsp;
|&nbsp;
|-
|}
|:ang2 = ang1 + 90
:ang2 = ang1 + 90
|-
{|
|&nbsp;
|&nbsp;
|-
|}
|:x2 = x1 + dist * cos(ang2)
:x2 = x1 + dist * cos(ang2)
|-
 
|:y2 = y1 + dist * sin(ang2)
:y2 = y1 + dist * sin(ang2)
|-
 
|:z2 = z1
:z2 = z1
|-
{|
|&nbsp;
|&nbsp;
|-
|}
|:add_path_line 1, x1, y1, z1 || ! mid way along the feature
:add_path_line 1, x1, y1, z1 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;! mid way along the feature
|-
 
|:add_path_line 1, x2, y2, z2 || ! out by the given distance
:add_path_line 1, x2, y2, z2 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;! out by the given distance
|-
 
|:add_path_line 1, x1, y1, z1 || ! back to mid point
:add_path_line 1, x1, y1, z1 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;! back to mid point
|-
 
|:add_path_line 1, xe, ye, ze || ! end of original features
:add_path_line 1, xe, ye, ze &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;! end of original features
|-
{|
|&nbsp;
|&nbsp;
|-
|}
|:continue
:continue
|-
{|
|&nbsp;
|&nbsp;
|-
|-
Line 125: Line 125:
|-
|-
|&nbsp;
|&nbsp;
|-
|}
|:get_op_feat_start    opnum, ifeat, xs, ys, zs
:get_op_feat_start    opnum, ifeat, xs, ys, zs
|-
 
|:get_op_feat_end      opnum, ifeat, xe, ye, ze
:get_op_feat_end      opnum, ifeat, xe, ye, ze
|-
 
|:get_op_feat_angles  opnum, ifeat, ang1, ang2, ang3
:get_op_feat_angles  opnum, ifeat, ang1, ang2, ang3
|-
 
|:get_op_feat_arc_data opnum, ifeat, rad, idir, xc, yc, zc
:get_op_feat_arc_data opnum, ifeat, rad, idir, xc, yc, zc
|-
 
|:if idir=1 then ang3 = -ang3
:if idir=1 then ang3 = -ang3
|-
{|
|&nbsp;
|&nbsp;
|-
|}
|:ang1 = ang1 + (ang3 / 2)  ||   ! angle mid way around arc
:ang1 = ang1 + (ang3 / 2)  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;   ! angle mid way around arc
|-
 
|:if ang1>360 then ang1 = ang1 - 360
:if ang1>360 then ang1 = ang1 - 360
|-
 
|:if ang1<0  then ang1 = ang1 + 360
:if ang1<0  then ang1 = ang1 + 360
|-
{|
|&nbsp;
|&nbsp;
|-
|}
|:ang2 = ang1
:ang2 = ang1
|-
 
|:if idir=0 then ang2 = ang1 + 180
:if idir=0 then ang2 = ang1 + 180
|-
 
|:if ang2 > 360 then ang2 = ang2 - 360
:if ang2 > 360 then ang2 = ang2 - 360
|-
{|
|&nbsp;
|&nbsp;
|-
|}
|:x1 = xc + rad * cos(ang1)
:x1 = xc + rad * cos(ang1)
|-
 
|:y1 = yc + rad * sin(ang1)
:y1 = yc + rad * sin(ang1)
|-
 
|:z1 = zs + ((ze - zs) / 2)
:z1 = zs + ((ze - zs) / 2)
|-
{|
|&nbsp;
|&nbsp;
|-
|}
|:x2 = x1 + dist * cos(ang2)
:x2 = x1 + dist * cos(ang2)
|-
 
|:y2 = y1 + dist * sin(ang2)
:y2 = y1 + dist * sin(ang2)
|-
 
|:z2 = z1
:z2 = z1
|-
{|
|&nbsp;
|&nbsp;
|-
|}
|:if idir=1 then add_path_arc 1, x1, y1, z1, xc, yc, zc, rad, cw
:if idir=1 then add_path_arc 1, x1, y1, z1, xc, yc, zc, rad, cw
|-
 
|:if idir#1 then add_path_arc 1, x1, y1, z1, xc, yc, zc, rad, ccw
:if idir#1 then add_path_arc 1, x1, y1, z1, xc, yc, zc, rad, ccw
|-
{|
|&nbsp;
|&nbsp;
|-
|}
|:add_path_line 1, x2, y2, z2  || ! out by the given distance
:add_path_line 1, x2, y2, z2  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;! out by the given distance
|-
 
|:add_path_line 1, x1, y1, z1  || ! back to mid point
:add_path_line 1, x1, y1, z1  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;! back to mid point
|-
{|
|&nbsp;
|&nbsp;
|-
|}
|:if idir=1 then add_path_arc 1, xe, ye, ze, xc, yc, zc, rad, cw
:if idir=1 then add_path_arc 1, xe, ye, ze, xc, yc, zc, rad, cw
|-
 
|:if idir#1 then add_path_arc 1, xe, ye, ze, xc, yc, zc, rad, ccw
:if idir#1 then add_path_arc 1, xe, ye, ze, xc, yc, zc, rad, ccw
|-
{|
|&nbsp;
|&nbsp;
|-
|-
Line 200: Line 200:
|&nbsp;
|&nbsp;
|-
|-
|copy_path 1, 0      ||  ! copy the new path to path zero
|copy_path 1, 0      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;! copy the new path to path zero
|-
|-
|set_op_path opnum   ||  ! set the op path to use path zero
|set_op_path opnum &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;! set the op path to use path zero
|-
|-
|delete_path_list   ||  ! delete the list of paths
|delete_path_list &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;! delete the list of paths
|-
|-
|&nbsp;
|&nbsp;

Latest revision as of 20:29, 27 July 2010

args opnum, dist
local numfeat, ifeat, itype
local xs, ys, zs, xe, ye, ze, xc, yc, zc, rad, idir
local x1, y1, z1, x2, y2, z2, ang1, ang2, ang3
 
 
! get a copy of the current op path
! ---------------------------------
 
get_op_num_feat opnum, numfeat ! get the number of features
if numfeat<1 then goto done ! make sure there is at least 1
 
define_path_list 1 ! create path list
 
select_op_path_type main ! select the main path
get_op_path opnum get a copy of the op path
! this will be path zero
 
get_op_path_start opnum, xs, ys, zs
create_path 1, xs, ys, zs ! start a new path
 
 
! divide it up
! ------------
 
for ifeat=1 to numfeat
 
get_op_feat_type opnum, ifeat, itype
progress_set (ifeat / numfeat)
 
if itype = feat_type_line then goto edit_line
if itype = feat_type_arc then goto edit_arc
 
  ! not a line or arc, just use this feature as it is
 
add_path_feat 1, 0, ifeat                             ! copy this feat to the new path
 
continue
 
:edit_line
get_op_feat_start opnum, ifeat, xs, ys, zs
get_op_feat_end opnum, ifeat, xe, ye, ze
get_op_feat_angles opnum, ifeat, ang1, ang2, ang3
 
x1 = xs + ((xe - xs) / 2)
y1 = ys + ((ye - ys) / 2)
z1 = zs + ((ze - zs) / 2)
 
ang2 = ang1 + 90
 
x2 = x1 + dist * cos(ang2)
y2 = y1 + dist * sin(ang2)
z2 = z1
 
add_path_line 1, x1, y1, z1                         ! mid way along the feature
add_path_line 1, x2, y2, z2                         ! out by the given distance
add_path_line 1, x1, y1, z1                         ! back to mid point
add_path_line 1, xe, ye, ze                         ! end of original features
 
continue
 
:edit_arc
 
get_op_feat_start opnum, ifeat, xs, ys, zs
get_op_feat_end opnum, ifeat, xe, ye, ze
get_op_feat_angles opnum, ifeat, ang1, ang2, ang3
get_op_feat_arc_data opnum, ifeat, rad, idir, xc, yc, zc
if idir=1 then ang3 = -ang3
 
ang1 = ang1 + (ang3 / 2)                             ! angle mid way around arc
if ang1>360 then ang1 = ang1 - 360
if ang1<0 then ang1 = ang1 + 360
 
ang2 = ang1
if idir=0 then ang2 = ang1 + 180
if ang2 > 360 then ang2 = ang2 - 360
 
x1 = xc + rad * cos(ang1)
y1 = yc + rad * sin(ang1)
z1 = zs + ((ze - zs) / 2)
 
x2 = x1 + dist * cos(ang2)
y2 = y1 + dist * sin(ang2)
z2 = z1
 
if idir=1 then add_path_arc 1, x1, y1, z1, xc, yc, zc, rad, cw
if idir#1 then add_path_arc 1, x1, y1, z1, xc, yc, zc, rad, ccw
 
add_path_line 1, x2, y2, z2                         ! out by the given distance
add_path_line 1, x1, y1, z1                         ! back to mid point
 
if idir=1 then add_path_arc 1, xe, ye, ze, xc, yc, zc, rad, cw
if idir#1 then add_path_arc 1, xe, ye, ze, xc, yc, zc, rad, ccw
 
next ifeat
 
 
! end of path
! -----------
 
copy_path 1, 0                                                 ! copy the new path to path zero
set_op_path opnum                                          ! set the op path to use path zero
delete_path_list                                                ! delete the list of paths
 
:done