Adds an element to a topology.
int
tpm_editaddelem(
ade_id tpm_id,
int type,
struct resbuf *res);
Returns RTNORM or an error code.
tpm_id | The topology ID. |
type | The element's type code: 1, 2, or 3, where 1 = Node, 2 = Link, and 3 = Polygon. |
res | The element to add. Depending on the type argument, specify one of the following: If 1, specify a point or the entity name of a point object. If 2, specify the entity name of a line object. If 3, specify a selection set. |
The topology must be open with Write access, (1). If you add a node to a link, the link is split.
Set up the resbuf for the res argument like this:
restype | Depends on the function's type argument: 1, 2, or 3. If 1, use RTPOINT, RT3DPOINT (if the topology's CREATE_NODE variable is set), or RTENAME. If 2, use RTENAME. If 3, use RTPICKS. |
resval | Depending on the given restype, a new point, the entity name of an existing line or point entity, or a selection set. If the topology's CREATE_NODE variable is set (see tpm_varset), and you specify a point that does not yet exist, it is created and added to the topology. |
rbnext | NULL (that is, no more data). |
For a polygon topology only: If you add a link that closes an open sequence of links or is connected to the topology at both ends of the link, tpm_editaddelem creates a new polygon.
The following sample adds a new element to an existing network topology. A resbuf is created containing the information required to draw a new pline. The pline is drawn using acedCmd(). The new pline's entity id is then obtained using acdbEntLast(). The topology that will recieve the new link is loaded and opened using tpm_acload() and tpm_acopen() respectively. A resbuf containing the new pline entity is constructed, then tpm_editaddelem() is called with all required parameters. Appropriate status messages are displayed based on the return code. Topologies are closed and unloaded from memory and the resbufs are released as required.
struct resbuf* pNewPlineRb = acutBuildList( RTSTR, "_pline", RTSTR, "54.0816,50.8243", RTSTR, "68,53", RTSTR, "", 0); int returnCode = acedCmd(pNewPlineRb); ads_name newPline; returnCode = acdbEntLast(newPline); char* pszTopoName = "NetTopo"; int topoWriteAccess = 1; returnCode = tpm_acload(pszTopoName, 0); ade_id topoId = tpm_acopen(pszTopoName, topoWriteAccess); struct resbuf* pNewElementRb = acutBuildList(RTENAME, newPline, 0); int elementType = 2; returnCode = tpm_editaddelem(topoId, elementType, pNewElementRb); if (RTNORM == returnCode){ acutPrintf( "\nThe new element was successfully added."); } else { acutPrintf( "\nThe new element was not added."); } tpm_acclose(topoId); tpm_acunload(pszTopoName); acutRelRb(pNewPlineRb); acutRelRb(pNewElementRb);