Building a Topology

AutoCAD Map 3D AutoLISP

Up a level
Building a Topology
 
 

The following steps describe building a topology.

The resulting topology is loaded but not open.

Note  For simplicity, cleaning drawing objects before building the topology is omitted. See Drawing Cleanup.

To build a topology
  1. Allocate memory for topology variables. The variables are initialized to their default values.
  2. (setq var_id (tpm_varalloc))
    
  3. Set the topology type, name, and description. This example code prompts for the topology type.
  4. (initget "noDe Network Polygon")
    (setq typ (getkword "Select topology type 
          (noDe/Network/Polygon) <Exit>: ")) 
    (if (null typ)
          (prompt "\nNo topology type entered.") 
    )
    
  5. The next step is to include objects for the topology (nodes, links, centroids), depending on the topology type. This code repeats three times to include each object type.
  6. After prompting for node objects, as shown here, this example prompts for link and centroid objects.

    Set up a filter to get the objects you want. Some automatic filtering is performed by ssget, which places the objects in an AutoCAD selection set. Note that you must include different object types for each type of topology.

    ; Node objects are POINT, TEXT, and INSERT
       (cond  
          ((= indx 1) 
             (setq filter (list (cons -4 "<OR")  
                                         (cons 0 "POINT") 
                                         (cons 0 "TEXT") 
                                         (cons 0 "INSERT") 
                                         (cons -4 "OR>") 
                                  ) 
             ) 
             (prompt "\nSelect node objects.") 
             (setq ss_nod (ssget filter)) 
          ) 
    
        ; Link objects are LINE, PLINE, ARC, and CIRCLE
          ((and (= indx 2)  
                   (or (= typ "NETWORK") 
                         (= typ "POLYGON") 
                   ) 
           ) 
             (setq filter (list (cons -4 "<OR")  
                                         (cons 0 "LINE") 
                                         (cons 0 "PLINE") 
                                         (cons 0 "ARC") 
                                         (cons 0 "CIRCLE") 
                                         (cons -4 "OR>") 
                                ) 
             ) 
             (prompt "\nSelect link objects.") 
             (setq ss_lnk (ssget filter)) 
          ) 
    
        ; Centroid objects are POINT, TEXT, and INSERT
          ((and (= indx 3)(= typ "POLYGON")) 
             (setq filter (list (cons -4 "<OR")  
                                         (cons 0 "POINT") 
                                         (cons 0 "TEXT") 
                                         (cons 0 "INSERT") 
                                         (cons -4 "OR>") 
                                ) 
             ) 
             (prompt "\nSelect centroid objects.") 
             (setq ss_ctr (ssget filter)) 
          ) 
       )  ; cond 
    )  ; repeat
    
  7. Build the type of topology you selected in step 2, using tpm_mntbuild. This sample uses a conditional operation to build the topology.
  8. For type 1, a node topology, tpm_mntbuild includes only nodes.

    (cond
       ((= typ "NODE") 
          (setq result (tpm_mntbuild var_id name desc 1 ss_nod)) 
       ) 
    

    For type 2, a network topology, it includes nodes and links.

      ((= typ "NETWORK") 
          (setq result (tpm_mntbuild var_id name desc 2 ss_nod ss_lnk)) 
       ) 
    

    For type 3, a polygon topology, it includes nodes, links, and centroids.

      ((= typ "POLYGON") 
          (setq result  
                (tpm_mntbuild var_id name desc 3 ss_nod ss_lnk ss_ctr)) 
    

    If no errors occur, the topology is now complete.