tpm_tracealloc

AutoCAD Map 3D AutoLISP

Up a level
tpm_tracealloc
 
 

Allocates the tracing model.

(tpm_tracealloc tpm_id [node_res link_dir link_forward_res link_reverse_res])

Returns the tracing model ID (real) or nil.

tpm_id Topology ID (real)
node_res Expression for node resistance (string):
nil = Default resistance
link_dir Expression for link direction (string):
nil = Default direction
link_forward_res Expression for forward link resistance (string):
nil = Default resistance
link_reverse_res Expression for reverse link resistance (string):
nil = Default resistance

This function sets the values for the specified topology to the parameters you enter. The values stored in topology object data when the topology was created are used as defaults if you omit parameters. You can enter any valid expression that evaluates to a numeric result.

The tracing model can be used only with a network or polygon topology.

When you enter a value other than nil for any of the optional resistance arguments, this value is used for all objects in the topology of the appropriate type. It overrides the corresponding value attached to the object. For example, if node_res is set to nil, the tracing model uses the value attached to topology object data when calculating the trace. If node_res is set to 10.0, all nodes in the topology are overridden with the value of 10.0 when the trace is calculated.

If you want to omit the optional parameters, you can either enter nil to invoke a default value or leave out the parameter altogether, as with other Visual LISP functions. However, before you omit optional parameters, note the dependency relationships indicated by bracketed groups. For example, if you want to use the link_dir parameter, you must enter a node_res parameter.

Important! When using the Topology API to perform a network trace, such as a Best Route analysis, the source topology used to create the trace topology should not be unloaded or erased until after all API calls relating to the trace have been made. This is because the trace topology references the nodes and links in the source topology. It does not create its own. So, in order to do anything with the elements of the trace, the source topology must remain loaded.

For example, the following Best Route code will silently fail:
; topo_id is the netTopo topology (tmp_id)
(setq topo_id (tpm_acopen topo_name T))

; create the trace model
(setq network_trace_id (tpm_tracealloc topo_id))

; create the best route
(setq bestroute (tpm_tracebestroute topo_id network_trace_id 7.0 1.0 4.0 9.0 5.0 6.0 8.0))

; remove the netTopo topology
; THIS SHOULD NOT BE DONE UNTIL AFTER BESTROUTE TOPO QUERIES ARE DONE.
(tpm_acclose topo_id) (tpm_acunload topo_name)

; this next call fails because the element info is on the source topology
(setq BestRouteTraceElement (tpm_tracebestroutescan network_trace_id 3))

The simple solution is to defer the calls to tpm_acclose and tpm_acunload until after all tpm_tracebestroutescan calls.