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

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