English

How To: split an arc at its midpoint

Procedure

How to split an arc at its exact midpoint.

Answer:

1. For COGO arcs (two nodes, no vertices), use the ARCEDIT BREAKLINE command.

Code:
BREAKLINE PARTS 2

2. For non-COGO arcs (two nodes, one or more vertices), use the following AML:
Code:
/*A------------------------------AUTHOR---------------------------------
/*
/*Original Coding: ESRI
/*
/*N-------------------------------NAME----------------------------------
/*
/*HALF.AML
/*Copyright 1995, Environmental Systems Research Institute, Inc.
/*
/*P-----------------------------PURPOSE---------------------------------
/*
/*This macro allows a user to select an arc and have it be split at the
/*exact midpoint coordinate. This AML is to be run from the Arcedit
/*module. The user will be prompted to select an arc to be split in half.
/*
/*U------------------------------USAGE----------------------------------
/*
/*HALF.AML
/*
/*============================DISCLAIMER================================
/*You may use, copy, modify, merge, distribute, alter, reproduce and/or
/*create derivative works of this AML for your own internal use. All
/*rights not specifically granted herein are reserved to ESRI.
/*
/*THIS AML IS PROVIDED "AS-IS" WITHOUT WARRANTY OF ANY KIND, EITHER
/*EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
/*WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE,
/*WITH RESPECT TO THE AML.
/*
/*ESRI shall not be liable for any damages under any theory of law
/*related to your use of this AML, even if ESRI is advised of the
/*possibilites of such damage. This AML is not supported by ESRI.
/*======================================================================
/*
&sev &error &routine bail

&if [show editfeature] <> ARC &then &do
&type Edifeature must be ARC.
&return
&end

&s mess = [show &messages]
&s weed = [show weedtolerance]
&s selset = [unquote '[show number select]']

&s key = 0
&type Select an arc to half
&do &until %key% = 1
&type 1 = Select arc 4 = Accept arc 9 = Quit
&flushpoints
&getpoint &current
&if %pnt$key% = 1 &then &do
&pushpoint 1,%pnt$x%,%pnt$y%
&messages &off
select one
&messages %mess%
&if %selset% = 1 &then &type Arc [show select 1] now selected
&end
&if %pnt$key% = 4 &then &do
&if %selset% = 0 &then &type Cannot accept, no arc selected
&else &s key = 1
&end
&if %pnt$key% = 9 &then &return
&end

&s arcrecno = [show select 1]
&type Arc %arcrecno% accepted
&s totallength = [show arc %arcrecno% item length]
&s halflength = [calc %totallength% / 2]

&s overlength = 0
&s i = 0
&do &until %overlength% >= %halflength%
&s i = %i% + 1
&s point1 = [show arc %arcrecno% vertex %i%]
&s point2 = [show arc %arcrecno% vertex [calc %i% + 1]]
&s overlength = [calc %overlength% + [invdistance %point1% %point2%]]
&end

&s overdist = [calc %overlength% - %halflength%]
&flushpoints
&if %overdist% = 0 &then &do
&pushpoint 1,%point2%
&pushpoint 1,0,0
&messages &off
split vertex
&messages %mess%
&end
&else &do
&s d = [calc [invdistance %point1% %point2%] - %overdist%]
&s angle = [invangle %point1% %point2%]
&s dx = [calc %d% * [cos %angle%]]
&s dy = [calc %d% * [sin %angle%]]
&s x = [calc [before %point1% ,] + %dx%]
&s y = [calc [after %point1% ,] + %dy%]
&pushpoint 1,%x%,%y%
&messages &off
weedtolerance 0
split
weedtolerance %weed%
&messages %mess%
&end
&flushpoints
&return

&routine bail
&sev &error &ignore
weedtolerance %weed%
&messages %mess%
&return &warning An error has occured in HALF.AML.