How to i solve this ucs problem ??

How to i solve this ucs problem ??

jaimuthu
Advocate Advocate
326 Views
2 Replies
Message 1 of 3

How to i solve this ucs problem ??

jaimuthu
Advocate
Advocate

1) I want D-B-C Triangle for the value of D to B = 228 B to C = 101.8 D to C = 199.8 (ucs world)

2)Triangle shape is wrong but text is not mirror or down

3) i change the ucs 3 point method and use this program Triangle shape is correct but text is mirror or down font also bold

4)how to solve this problem

(defun c:tri( / unit mxv v^v transptucs transptwcs p1 p2 loop g p h gp p3 )

(defun unit ( v / d )
(mapcar '(lambda ( x y ) (/ x y)) v (list (setq d (distance '(0.0 0.0 0.0) v)) d d))
)

(defun mxv ( m v )
(mapcar '(lambda ( r ) (apply '+ (mapcar '* r v))) m)
)

(defun v^v ( u v )
(list
(- (* (cadr u) (caddr v)) (* (cadr v) (caddr u)))
(- (* (car v) (caddr u)) (* (car u) (caddr v)))
(- (* (car u) (cadr v)) (* (car v) (cadr u)))
)
)

(defun transptucs ( pt p1 p2 p3 / ux uy uz )
(setq uz (unit (v^v (mapcar '- p2 p1) (mapcar '- p3 p1))))
(setq ux (unit (mapcar '- p2 p1)))
(setq uy (unit (mapcar '- p3 p1)))

(mxv (list ux uy uz) (mapcar '- pt p1))
)

(defun transptwcs ( pt pt1 pt2 pt3 / pt1n pt2n pt3n )
(setq pt1n (transptucs '(0.0 0.0 0.0) pt1 pt2 pt3))
(setq pt2n (transptucs '(1.0 0.0 0.0) pt1 pt2 pt3))
(setq pt3n (transptucs '(0.0 1.0 0.0) pt1 pt2 pt3))
(transptucs pt pt1n pt2n pt3n)
)

(defun acos ( x )

(if (<= -1.0 x 1.0)

(atan (sqrt (- 1.0 (* x x))) x)

)


)

(setq

TA(GETSTRING "\n ENTER START POINT OF TEXT:");A

TB(GETSTRING "\n ENTER END POINT OF TEXT:");B

TC(GETSTRING "\n ENTER THIRD POINT OF TEXT:");C
)

(setq p1 (getpoint "\n Pick specify start point : "))

(setq p2 (getpoint "\n Pick or specify end point : " p1))

(setq h(getdist p1(STRCAT TA "<----->" TC " LENGTH"))) ;AC

(setq k(getdist p2(STRCAT TB "<----->" TC " LENGTH"))) ;BC

(SETQ
AB(DISTANCE P1 P2)

)

(SETQ

B2(* h h) C2(* AB AB) A2(* k k) CV(* 2 h AB) CB(* 2 k AB) CC(* 2 k h)

ANGA(/(-(+ B2 C2)A2)CV)

ANSA(acos anga);ANGLE A

)

(setq loop t)
(while loop
(setq g (grread t 15 0))
(if (eq (car g) 5)
(progn
(setq p (mapcar '(lambda ( a b ) (/ (+ a b) 2.0)) p1 p2))
;(setq h (/ (distance p1 p2)2 ))
(setq gp (cadr g))
(if (not (minusp (cadr (transptucs gp p1 (polar p1 (angle p1 p2) 1.0) (polar p1 (+ (angle p1 p2) (* 0.5 pi)) 1.0)))))
(progn
(redraw)
(setq p3 (polar p1 ANSA h))
(grdraw p1 p2 1 1)
(grdraw p2 p3 1 1)
(grdraw p3 p1 1 1)
)
(progn
(redraw)
(setq p3 (polar p1 (- ANSA) h))
(grdraw p1 p2 1 1)
(grdraw p2 p3 1 1)
(grdraw p3 p1 1 1)
)
)
)


(progn
(entmake (list '(0 . "LWPOLYLINE") '(100 . "AcDbEntity") '(100 . "AcDbPolyline") '(90 . 3)
(if (eq (getvar 'plinegen) 1) '(70 . 129) '(70 . 1))
(cons 38 (caddr (trans p1 1 (trans '(0.0 0.0 1.0) 1 0 t)))) (cons 10 (list (car (trans p1 1 (trans '(0.0 0.0 1.0) 1 0 t)))
(cadr (trans p1 1 (trans '(0.0 0.0 1.0) 1 0 t))))) (cons 10 (list (car (trans p2 1 (trans '(0.0 0.0 1.0) 1 0 t)))
(cadr (trans p2 1 (trans '(0.0 0.0 1.0) 1 0 t))))) (cons 10 (list (car (trans p3 1 (trans '(0.0 0.0 1.0) 1 0 t)))
(cadr (trans p3 1 (trans '(0.0 0.0 1.0) 1 0 t))))) (cons 210 (trans '(0.0 0.0 1.0) 1 0 t))))
(setq loop nil)
)


)
)

(redraw)
(print ansa)

(setq
c1(/ 180 pi)
)

(command "text" "j" "bc" p1 8 0 "A" "" "")(command "text" "j" "bc" "M2P" P1 P2 8 (* c1(ANGLE P1 P2)) (RTOS (DISTANCE P1 P2) 2 2))
(command "text" "j" "bc" p2 8 0 "B" "" "")(command "text" "j" "bc" "M2P" P3 P1 8 (* c1(ANGLE P3 P1)) (RTOS (DISTANCE P3 P1) 2 2))
(command "text" "j" "bc" p3 8 0 "C" "" "")(command "text" "j" "bc" "M2P" P2 P3 8 (* c1(ANGLE P2 P3)) (RTOS (DISTANCE P2 P3) 2 2))

)

 

 

 

 

 

 

 

 

 

 

 

 

0 Likes
327 Views
2 Replies
Replies (2)
Message 2 of 3

1LandSurveyor
Enthusiast
Enthusiast

I did not get through all your code and can't fix it.

For the texts i can see clearly that you are using (COMMAND "TEXT" ...) which implies that you are creating the texts according to the current UCS axis directions. The created text is plane with the XY plane and facing the positive Z axis. In your second example, you set the UCS in a direction such that the Z axis is pointing away from you (look at a right hand system definition). 

You need to either :

  • prior to using your command, set the UCS so that the Z axis is pointing toward you (maybe use command UCS > Entity and select the line, instead of UCS 3 point method)
  • In your command, change the current UCS to World first
  • Instead of creating the texts using (COMMAND "TEXT" ...) which will draw according to the UCS, use autolisp function (ENTMAKE ...) using current view rotation to find the good rotation for your text.

Also, i think that texts appear bold when they are not perfectly aligned on the same plane as the current view. To test this, if you set command "UCS > Entity > click on the Bold text", then you perform command "Plan > Current UCS" the last texts should read fine and the other ones become bold. Correcting your code to draw on the current view plan should fix the bold text issues.

 

0 Likes
Message 3 of 3

jaimuthu
Advocate
Advocate

error

0 Likes