efishe.183349
2009-07-28, 09:45 PM
I am creating a quick and dirty routine to do a manual pline drawn Strike through of regular dtext entities.
unfortunately I am having difficulty of getting the P1 and P2 points to Extend beyond the text by 1 character and centered in the text based on the alignment.
It works as is for all caps but doesn't extend the full length,
another problem is that when there are lower case characters, such as y,p,q etc. the strike through basis it's positioning on the overall text box.
any suggestions?
(defun C:Strike ( / textent tb ll ur ul lrx1 y1 x2 y2 p1 p2)
(setvar "CMDECHO" 0)
(setq textent (car (entsel "\nSelect text: ")))
(command "UCS" "ENTITY" textent)
(setq tb (textbox (list (cons -1 textent)))
ll (car tb)
ur (cadr tb)
ul (list (car ll) (cadr ur))
lr (list (car ur) (cadr ll))
ofs (* -2)
x1 (car ll)
y1 (cadr ll)
x2 (car lr)
y2 (cadr lr)
x1 (- x1 ofs)
y1 (- y1 ofs)
x2 (+ x2 ofs)
y2 (- y2 ofs)
p1 (list x1 y1)
p2 (list x2 y2)
);setq
;;;use Ltscale as scaling factor.
(command "LAYER" "s" "0" ""
"PLINE" p1 "W" (* (getvar "LTSCALE") 0.0) "" p2 ""
"UCS" "P"
);command
(princ)
);defun
(princ)
unfortunately I am having difficulty of getting the P1 and P2 points to Extend beyond the text by 1 character and centered in the text based on the alignment.
It works as is for all caps but doesn't extend the full length,
another problem is that when there are lower case characters, such as y,p,q etc. the strike through basis it's positioning on the overall text box.
any suggestions?
(defun C:Strike ( / textent tb ll ur ul lrx1 y1 x2 y2 p1 p2)
(setvar "CMDECHO" 0)
(setq textent (car (entsel "\nSelect text: ")))
(command "UCS" "ENTITY" textent)
(setq tb (textbox (list (cons -1 textent)))
ll (car tb)
ur (cadr tb)
ul (list (car ll) (cadr ur))
lr (list (car ur) (cadr ll))
ofs (* -2)
x1 (car ll)
y1 (cadr ll)
x2 (car lr)
y2 (cadr lr)
x1 (- x1 ofs)
y1 (- y1 ofs)
x2 (+ x2 ofs)
y2 (- y2 ofs)
p1 (list x1 y1)
p2 (list x2 y2)
);setq
;;;use Ltscale as scaling factor.
(command "LAYER" "s" "0" ""
"PLINE" p1 "W" (* (getvar "LTSCALE") 0.0) "" p2 ""
"UCS" "P"
);command
(princ)
);defun
(princ)