Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Converting a graph to a 3D diagram

3 REPLIES 3
SOLVED
Reply
Message 1 of 4
Anonymous
767 Views, 3 Replies

Converting a graph to a 3D diagram

The following code (ref) can be used to generate a 2D diagram when coordinates, nodes, and edges of a graph are given.

(defun graph ( pts sls tls wgt )
( (lambda ( l )
(foreach x l (text (cdr x) (itoa (car x)) 0.0 1))
(mapcar
'(lambda ( a b c / p q r )
(setq p (cdr (assoc a l))
q (cdr (assoc b l))
r (angle p q)
)
(entmake (list '(0 . "LINE") (cons 10 p) (cons 11 q) '(62 . 8)))
(text
(mapcar '(lambda ( x y ) (/ (+ x y) 2.0)) p q)
(itoa c)
(if (and (< (* pi 0.5) r) (<= r (* pi 1.5))) (+ r pi) r)
2
)
)
sls tls wgt
)
)
(mapcar 'cons (vl-sort (append sls tls) '<) pts)
)
)
(defun text ( p s a c )
(entmake
(list
'(0 . "TEXT")
(cons 10 p)
(cons 11 p)
(cons 50 a)
(cons 01 s)
(cons 62 c)
'(40 . 2)
'(72 . 1)
'(73 . 2)
)
)
)


(graph
'((75 25) (115 45) (90 60) (10 5) (45 0) (45 55) (0 25))
'( 1 1 1 1 2 2 3 4 4 5 6)
'( 2 3 4 5 3 6 6 5 7 7 7)
'(50 10 20 80 90 90 30 20 100 40 60)
)


I'd like to ask for suggestions on how the above code has to be modified to draw 3D diagrams when 3D coordinates of nodes are available.

 

(graph
'((75 25 0) (115 45 24) (90 60 21) (10 5 4) (45 0 1) (45 55 23) (0 25 123))
'( 1 1 1 1 2 2 3 4 4 5 6)
'( 2 3 4 5 3 6 6 5 7 7 7)
'(50 10 20 80 90 90 30 20 100 40 60)
)
Tags (1)
3 REPLIES 3
Message 2 of 4
Anonymous
in reply to: Anonymous

Solved.

Message 3 of 4
Sea-Haven
in reply to: Anonymous

Should post how solved, was it over at Cadtutor.

Message 4 of 4
Anonymous
in reply to: Sea-Haven

cross-posted here

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Forma Design Contest


AutoCAD Beta