Draw vector on the screen that rubber bands

Draw vector on the screen that rubber bands

jaimuthu
Advocate Advocate
697 Views
5 Replies
Message 1 of 6

Draw vector on the screen that rubber bands

jaimuthu
Advocate
Advocate

HOW DO I DRAW A VECTOR ON THE SCREEN THAT RUBBER BANDS AS THE USER PICKS SUCCESSIVE POINTS WHILE PASSING THE POINTS BACK TO THE PROGRAM

 

 

 

 

(DEFUN C:JJ()

(SETQ

P1(GETPOINT "\n PICK FIRST POINT :")

P2(GETPOINT P1 "\n PICK SECOND POINT :")

P3(GETPOINT P2 "\n PICK SECOND POINT :")

DI(RTOS(DISTANCE P1 P2) 2 1)

DI1(RTOS(DISTANCE P2 P3) 2 1)

DI2(RTOS(DISTANCE P3 P1) 2 1)

ANG1(ANGLE P1 P2) c1(/ 180 pi) FANG1(* C1 ANG1)

ANG2(ANGLE P2 P3) c1(/ 180 pi) FANG2(* C1 ANG2)


ANG3(ANGLE P3 P1) c1(/ 180 pi) FANG3(* C1 ANG3)

 

;DI2(RTOS(DISTANCE P1 P3) 2 1)

)

(setq

P1w (trans P1 1 0)

P2w (trans P2 1 0)


)

; (COMMAND "_.UCS" "3" P1 P2 "")

(setq

P1 (trans P1w 0 1)

P2 (trans P2w 0 1)

;P3 (trans P3 0 1)
)

(progn
(redraw)

(grdraw p1 p2 1 1)
(grdraw p2 P3 1 1)
(grdraw P3 p1 1 1)
)

 


(COMMAND "LINE" P1 P2 "")

(COMMAND "LINE" P2 P3 "")

(COMMAND "LINE" P3 P1 "")

 

(COMMAND "_.TEXT" "_J" "_BC" "_M2P" P1 P2 8 FANG1 DI)

(COMMAND "_.TEXT" "_J" "_BC" "_M2P" P2 P3 8 FANG2 DI1)

(COMMAND "_.TEXT" "_J" "_BC" "_M2P" P3 P1 8 FANG3 DI2)

)

 
 
0 Likes
Accepted solutions (2)
698 Views
5 Replies
Replies (5)
Message 2 of 6

komondormrex
Mentor
Mentor

use grdraw function with highlight set.

0 Likes
Message 3 of 6

jaimuthu
Advocate
Advocate

HOW I DO THIS RUBBER BAND DIRECTION ?

0 Likes
Message 4 of 6

komondormrex
Mentor
Mentor

oops, you already have it

0 Likes
Message 5 of 6

komondormrex
Mentor
Mentor
Accepted solution

well, jj-command is programmed in a way that you can see only first 'grdraw-ed' line if there will be no successive zooming. it is non-dynamic. after a third point is picked the triangle is quickly drawn and all is redrawn.

 

(defun c:jj()
	(setq p1 (getpoint "\nPick first point :")
		  p2 (getpoint p1 "\nPick second point :")
	)
	(grdraw p1 p2 1 1)
	(setq p3(getpoint p2 "\n Pick third point :"))
	(grdraw p2 p3 1 1)
	(grdraw p3 p1 1 1) 
	(setq di (rtos (distance p1 p2) 2 1)
		  di1 (rtos (distance p2 p3) 2 1)
		  di2 (rtos (distance p3 p1) 2 1)
		  ang1 (angle p1 p2) 
		  c1 (/ 180 pi) 
		  fang1 (* c1 ang1)
		  ang2 (angle p2 p3) 
		  c1 (/ 180 pi) 
		  fang2 (* c1 ang2)
		  ang3 (angle p3 p1) 
		  c1 (/ 180 pi) 
		  fang3 (* c1 ang3)
	)
	(command "_line" p1 p2 p3 p1 "")
	(command "_.text" "_j" "_bc" "_m2p" p1 p2 8 fang1 di)
	(command "_.text" "_j" "_bc" "_m2p" p2 p3 8 fang2 di1)
	(command "_.text" "_j" "_bc" "_m2p" p3 p1 8 fang3 di2)
	(redraw)
	(princ)
)

 

Message 6 of 6

johnyDFFXO
Advocate
Advocate
Accepted solution

There is no built-in way to have two rubber bands. You can play with grread and you're going to fight with osnaps : see http://www.lee-mac.com/grsnap.html

 

(defun c:JJGRREAD ()


(SETQ P1(GETPOINT "\n PICK FIRST POINT :")
P2(GETPOINT P1 "\n PICK SECOND POINT :")
P3 '(0 0 0))

(setq L1 (entget (entmakex (list '(0 . "LINE") (cons 10 P1) (cons 11 P3) '(62 . 30)))))
(setq L2 (entget (entmakex (list '(0 . "LINE") (cons 10 P2) (cons 11 P3) '(62 . 30)))))

(prompt "\n SPECIFY DIRECTION : .....")
(while (= 5 (car (setq GR (grread T 0))))

(setq P3 (cadr GR))
(setq L1 (entmod (subst (cons 11 P3) (assoc 11 L1) L1)))
(setq L2 (entmod (subst (cons 11 P3) (assoc 11 L2) L2)))

)

(entdel (cdr (assoc -1 L1)))
(entdel (cdr (assoc -1 L2)))

(print P3)
(princ)
)