Friday, April 10, 2009

Shortest path find

Hi Friends,
To start with our AutoCAD programming. we are posting a tool to find out the shortest path between two points.

(Defun GetShortestPath (pt1 pt2 Toponame)
(setq returnset (ssadd))
;;(if (tpm_acexist Toponame) (tpm_acload Toponame))
(setq topo_id (tpm_acopen Toponame nil))
(setq trace_id (tpm_tracealloc topo_id))
(setq node1_id (tpm_elemfind topo_id 1 pt1))
(setq node2_id (tpm_elemfind topo_id 1 pt2))
(setq TS (tpm_traceshort trace_id node1_id node2_id))
(if TS
(progn
(setq loop T)
(setq ctr 0)
(setq tracelen (tpm_traceqty trace_id 2))
(while (< ctr tracelen)
(setq elem_id (tpm_traceelemid trace_id 2 ctr))
(setq eleminfo (tpm_elemget topo_id elem_id))
(if eleminfo
(progn
(setq ent (cdr (assoc -2 eleminfo)))
(if ent (setq returnset (ssadd ent returnset)))
)
)
(setq ctr (1+ ctr))
)
)
)
(tpm_tracefree trace_id)
(tpm_acclose topo_id)
;;(tpm_acunload Toponame)
(princ)
returnset
)

Please post ur comments on this.

Welcome

Hi Friends,
we have started this blog to help you in AutoCAD programming.
we are experts in different modules of AutoCAD prograaming.
1. Auto/Visual Lisp
2. AutoCAD VBA.
3. ObjectARX
4. AutoCAD FDO
5. AutoCAD map programing

Please post your doubts/requirements in these domains..

Regards