- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I have written a code where you place a point and then place the label to that point. I want to write the code to automatically use the move command to place the label where you want it. I tried the concept in a separate function and it worked perfectly.
(defun c:test()
(setq bpt (getpoint "Pick a point: "))
(setq dis (sqrt (* (expt (* textH 0.6) 2) 2)))
(setq a (* dis (cos (+ rAng (/ PI 4)))))
(setq b (* dis (sin (+ rAng (/ PI 4)))))
(setq pntf (list (+ (car bpt) a) (+ (cadr bpt) b)))
(command "._text" pntf textH textA num)
(bns_tcircle (addpnts textH textA pntf num) "Variable" "Rectangles" nil 0.5)
(setq dis (sqrt (* (expt (* textH 0.1) 2) 2)))
(setq rAng (* textA (/ PI 180)))
(setq a (* dis (cos (+ rAng (/ PI 4)))))
(setq b (* dis (sin (+ rAng (/ PI 4)))))
(setq pntb (list (+ (car bpt) a) (+ (cadr bpt) b)))
(setq ss (addpnts textH textA pntf 344))
(command "._move" ss "" pntb)
(princ)
)
I then tried to implement this into my code, but the pntb in the move command doesn't seem to register and since the code is in a loop (not shown here) it asks for the next point before it moves the label. When you click again it just breaks the program and then you can just place the label, but youve already left the loop.
(if (< (getvar "osmode") 16384)
(progn
(setq os 1)
(setvar "osmode" (+ (getvar "osmode") 16384))
)
(setq os 0)
)
(setq pnt2 (getpoint "\nChoose text position: "))
;(setq pnt2 pnt1)
(setq dis (sqrt (* (expt (* textH 0.6) 2) 2)))
(setq rAng (* textA (/ PI 180)))
(setq a (* dis (cos (+ rAng (/ PI 4)))))
(setq b (* dis (sin (+ rAng (/ PI 4)))))
(setq pntf (list (+ (car pnt2) a) (+ (cadr pnt2) b)))
(command "._text" pntf textH textA num)
(if (= m3 1)
(progn
(setq ss (addpnts textH textA pntf num))
(bns_tcircle ss "Variable" "Rectangles" nil 0.5)
) ; progn
) ; if
(setq dis (sqrt (* (expt (* textH 0.1) 2) 2)))
(setq a (* dis (cos (+ rAng (/ PI 4)))))
(setq b (* dis (sin (+ rAng (/ PI 4)))))
(setq pntb (list (+ (car pnt2) a) (+ (cadr pnt2) b)))
(setq sel (addpnts textH textA pntf num))
(command ".move" sel "" pntb)
(if (= os 1) (setvar "osmode" (- (getvar "osmode") 16384)))
I don't understand how my second code is any different than my first, and why it isn't working.
Solved! Go to Solution.