Completing a Topology

AutoCAD Map 3D AutoLISP

Up a level
Completing a Topology
 
 

This procedure creates a partial topology and uses map_topocomplete to add the missing elements to complete it.

To complete a topology
  1. Create a polygon topology and save it to a file.
  2. Start a new project and attach the drawing using ade_aliasadd, ade_dsattach, and ade_dwgactivate.
  3. Query in some of the topology's objects to create a partial topology. Use query functions.
  4. (ade_qryclear)            ; clear all queries
    (ade_qrysettype "draw")   ; draw query results
     
    (setq pt1 (list 2.9123  8.8513 0.0))
    (setq pt2 (list 5.9134  1.1634 0.0))
    (setq pt3 (list 10.7931  1.7354 0.0))
    (setq pt4 (list 10.0371  8.8742 0.0))
     
    (setq lst (list "polygon" "crossing" pt1 pt2 pt3 pt4))
    (setq qry_id (ade_qrydefine "" "" "" "location" lst ""))
    (if (null qry_id )
       (prompt "\nERROR: Query definition failed.") 
       (progn 
          (prompt "\nQuerying in part of the polygon topology.") 
          (setq result (ade_qryexecute)) 
          (if (null result)  
             (prompt "\nExecution of query failed.") 
          ) 
       ) 
    )
    
  5. Load the topology into memory from the project drawing.
  6. (setq result (tpm_acload name nil)) 
    
  7. Open the topology with read access.
  8. (setq tpm_id (tpm_acopen "test" nil))
    
  9. Test the topology for correctness and completeness.
  10. (if (tpm_infocorrect tpm_id)
       (prompt "\nTopology is correct.") 
       (prompt "\nTopology is not correct.") 
    )
    (if (tpm_infocomplete tpm_id)
       (prompt "\nTopology is complete.") 
       (prompt "\nTopology is not complete.") 
    )
    
  11. Optionally, you can get topology statistics. You can add code to display the statistics.
  12. (setq lst (map_topostat tpm_id))  
    (if (null lst)
       (prompt "\nERROR: Unable to get statistics.")
       (progn 
          (prompt "\nNumber of nodes: ")
          (princ (cdr (assoc "node_count" lst)))
          (prompt "\nNumber of links: ") 
          (princ (cdr (assoc "link_count" lst)))
       )
    )
    
  13. Close the topology.
  14. (tpm_acclose tpm_id)
    
  15. Use map_topocomplete to bring in the missing objects to complete the topology.
  16. (map_topocomplete "test") 
    
  17. Repeat steps 5 through 7 to test the topology for completeness.
  18. Unload the topology.
  19. >
    (tpm_acunload "test")