Opening a Topology

AutoCAD Map 3D AutoLISP

Up a level
Opening a Topology
 
 

The following numbered steps describe how to load and open a topology for read access, get information about the topology, and then close it.

To open a topology
  1. Prompt for the topology name.
  2. (setq name (getstring "\nEnter the topology name"))
    
  3. First, use Topology Access functions to see if the topology is already loaded and, if not, load it.
  4. Check to see if the topology is loaded with tpm_acexist.

    (setq result (tpm_acexist name T T))
    (if result
       (prompt "\nTopology is already loaded.") 
    )
    

    Using T for both the source and loaded parameters causes tpm_acexist to check for topologies in both current and source drawings that are already loaded in memory.

  5. If it is not loaded, load it with tpm_acload.
  6. (setq result (tpm_acload name))
    

    You can add code here to handle errors or announce successful loading.

  7. Open the topology for read access. The tpm_acopen function opens a topology and creates a new topology_ID (*) that provides access to it. Using the nil value for the write_access parameter sets access to read.
  8. (setq tpm_id (tpm_acopen name nil))
    
  9. Use Topology Information functions to get information about the topology.
  10. Get the description of the topology with tpm_infodesc.

    (prompt (strcat "\nTopology desc: " 
          (tpm_infodesc tpm_id))) 
    

    Get the type of the topology with tpm_infotype.

    (prompt (strcat "\nTopology type: " 
          (itoa (tpm_infotype tpm_id)))) 
    

    Test the topology to see if it is correct with tpm_infocorrect.

    (if (tpm_infocorrect tpm_id)
          (prompt "\nTopology is correct.") 
          (prompt "\nTopology is not correct.")) 
    

    Test the topology to see if it is complete with tpm_infocomplete.

    (if (tpm_infocomplete tpm_id)
          (prompt "\nTopology is complete.") 
          (prompt "\nTopology is not complete.")) 
    

    Get the version of the topology with tpm_infoversion.

    (prompt (strcat "\nTopology version: " (tpm_infoversion tpm_id)))
    
  11. Close the topology.
  12. (tpm_acclose tpm_id)
    

    When you use tpm_acopen to open or test the status of a topology, always close the topology with tpm_acclose. Otherwise, you run the risk of leaving the topology open with multiple IDs pointing to it.