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
- Prompt for the topology name.
- First, use Topology Access functions to see if the topology is already loaded and, if not, load it.
- If it is not loaded, load it with tpm_acload.
- 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.
- Use Topology Information functions to get information about the topology.
- Close the topology.
(setq name (getstring "\nEnter the topology name"))
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.
(setq result (tpm_acload name))
You can add code here to handle errors or announce successful loading.
(setq tpm_id (tpm_acopen name nil))
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)))
(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.