(polar pt (+ (/ pi 2) ang) 0.08)
(polar pt (+ (/ pi 2) ang) 0.08)
Hi ronjonp, I don't know how to use it thisCode: [Select](polar pt (+ (/ pi 2) ang) 0.08)
Can you be more specific?
Thanks
I try to align the textin the midle center and I want the dimension text be 0.08m over the line . Can anyone help?Ronjon's code will return a "moved" point (i.e. the XYZ value) from the one saved in the variable pt by moving it 0.08 units perpendicular to the angle saved in the variable ang.
Irneb commented the code he wrote for you ... I'm sure you can figure it out.Look for where I commented "The insertion point of the text" and replace the pt with either that code or another variable you've set to the return value of that code.
... but what about the midle center of the textIf you compare an entity list from a left aligned text with that of a middle center aligned text you will find the group code items that need to be added to, or changed in, the entmakex list.
(cons 72 1) ;Horizontal text justification type
(cons 73 2) ;Vertical text justification type
71
Text generation flags (optional, default = 0):
2 = Text is backward (mirrored in X).
4 = Text is upside down (mirrored in Y).
72
Horizontal text justification type (optional, default = 0) integer codes (not bit-coded)
0 = Left; 1= Center; 2 = Right
3 = Aligned (if vertical alignment = 0)
4 = Middle (if vertical alignment = 0)
5 = Fit (if vertical alignment = 0)
See the Group 72 and 73 integer codes table for clarification.
73
Vertical text justification type (optional, default = 0): integer codes (not bit- coded):
0 = Baseline; 1 = Bottom; 2 = Middle; 3 = Top
See the Group 72 and 73 integer codes table for clarification.
(
(-1 . <Entity name: cb2deb0>)
(0 . "TEXT")
(5 . "AC")
(330 . <Entity name: caeb090>)
(100 . "AcDbEntity")
(67 . 0)
(410 . "Model")
(8 . "0")
(100 . "AcDbText")
(10 819.719 207.205 0.0)
(40 . 100.0)
(1 . "aaa")
(50 . 0.0)
(41 . 1.0)
(51 . 0.0)
(7 . "Standard")
(71 . 0)
(72 . 0)
(11 0.0 0.0 0.0)
(210 0.0 0.0 1.0)
(100 . "AcDbText")
(73 . 0)
)
(
(-1 . <Entity name: cbe0e38>)
(0 . "TEXT")
(5 . "AD")
(330 . <Entity name: caeb090>)
(100 . "AcDbEntity")
(67 . 0)
(410 . "Model")
(8 . "0")
(100 . "AcDbText")
(10 703.319 157.205 0.0) ; <-- First alignment point. Not the insertion point.
(40 . 100.0)
(1 . "aaa")
(50 . 0.0)
(41 . 1.0)
(51 . 0.0)
(7 . "Standard")
(71 . 0)
(72 . 1) ; <--
(11 819.719 207.205 0.0) ; <-- Second alignment point. Insertion point.
(210 0.0 0.0 1.0)
(100 . "AcDbText")
(73 . 2) ; <--
)
For the first alignment point of a middle center aligned text you can use a dummy point for the entmake(x) list. But gc 10 must be present. At least on BricsCAD this applies.Yep, I can confirm on AutoCAD 2014 it also works. E.g.
(setq ang (rem ang (* pi 0.5)))
Edit: This does not work properly... See #23.
I add this two lines for Middle Center JustificationNote: In the drawing the texts are center aligned. Not middle center aligned.
(defun readableAngle (ang)
(setq ang (rem (+ (rem ang (* pi 2.0)) pi pi) (* pi 2.0)))
(if (< (* pi 0.5) ang (* pi 1.5))
(+ ang pi)
ang
)
)
Is it easy to convert this text to be annotative?
(entmake
(list
(cons 0 "ENDBLK")
(cons 8 "0")
)
)
(
(lambda ( lst )
(regapp "ACAD")
(regapp "AcadAnnotative")
(entmod
(append (subst (cons 70 1) (assoc 70 lst) lst)
(list
(list -3
(list "ACAD"
(cons 1000 "DesignCenter Data")
(cons 1002 "{")
(cons 1070 1)
(cons 1070 1)
(cons 1002 "}")
)
(list "AcadAnnotative"
(cons 1000 "AnnotativeData")
(cons 1002 "{")
(cons 1070 1)
(cons 1070 1)
(cons 1002 "}")
)
)
)
)
)
)
(entget (cdr (assoc 330 (entget (tblobjname "BLOCK" partnumber)))))
)
(vl-load-com)
(setq BLOCKS
(vla-get-Blocks
(vla-get-activedocument
(vlax-get-acad-object)
)
)
BLK (vla-Item BLOCKS partnumber)
)
(vla-put-explodable (vla-Item BLOCKS partnumber) :vlax-false)
roy_43 You are talking something about this !!! Is not working ?
(defun readableAngle (ang)
(setq ang (rem (+ (rem ang (* pi 2.0)) pi pi) (* pi 2.0)))
(if (< (* pi 0.5) ang (* pi 1.5))
(+ ang pi)
ang
)
)
(defun c:test (/ e p ht scl len pt ang)
...
...
(setq ang (angle '(0.0 0.0 0.0) (vlax-curve-getFirstDeriv e (vlax-curve-getParamAtPoint e pt)))) ;Get angle at midpoint
(setq ang (readableAngle ang))
...
...
)
(defun c:test (/ e p ht scl len pt ang)
(vl-load-com)
(setvar "cmdecho" 0)
(COMMAND "_layer" "_m" "dist" "_c" "3" "" "_lw" "0.30" "" "")
(SETQ scl (GETVAR "useri1"))
(SETQ ht (* 0.00175 SCL))
(SETQ kl (* 0.0004 SCL))
(COMMAND "style" "diast" "romans.shx")
(while (> (getvar "CmdActive") 0) (command ""))
(if (and (setq e (entsel "\n select line or polyline :"))
(setq e (car e))
(member (cdr (assoc 0 (entget e)))
'("LINE" "LWPOLYLINE" "POLYLINE")
)
)
(progn (setq len (vlax-curve-getDistAtParam e (vlax-curve-getEndParam e))
;Get the length of the line/pline to its end
pt (vlax-curve-getPointAtDist e (/ len 2.0))
;Get the point at mid of line/pline
ang (angle '(0.0 0.0 0.0)
(vlax-curve-getFirstDeriv
e
(vlax-curve-getParamAtPoint e pt)
)
)
)
(setq txtent
(entmakex (list '(0 . "TEXT")
'(100 . "AcDbEntity")
'(100 . "AcDbText")
(cons 40 ht)
'(7 . "diast")
'(72 . 1)
'(10 0.0 0.0 0.0)
(if (> ang pi)
(cons 11 (polar pt (- (/ pi 2) ang) kl))
(cons 11 (polar pt (+ (/ pi 2) ang) kl))
)
(cons 1 (rtos len 2 2))
(cons 50 (readableAngle ang))
)
)
)
(setq txtobj (vlax-ename->vla-object txtent))
(if (> ang pi)
(vla-put-alignment txtobj acAlignmentTopCenter)
(vla-put-alignment txtobj acAlignmentBottomCenter)
)
)
(princ
"\nSelect a LINE or POLYLINE !! Error selection .... Try again...."
)
)
(princ)
)
(defun readableAngle (ang)
(setq ang (rem (+ (rem ang (* pi 2.0)) pi pi) (* pi 2.0)))
(if (< (* pi 0.5) ang (* pi 1.5))
(+ ang pi)
ang
)
)
roy_043 Thank you but this is not what i want.I have never told you where exactly to change the ang value using the readableAngle function. If you think of the overall program flow it is easy to see where you should use (readableAngle ang) to get what you want. Let's call it a -={Challenge}=-. :-)
If you see the attach file
1) when the direction is from left to right (the red arrow )--> the text is over the line
2) when the direction is from right to left (the green arrow)--> the text is under the line
Now in this two options the text is over the line. I want this to wark with all angles in grad.
Thanks
I add this two lines for Middle Center Justification
roy_043 you are playing with the text style now .I ask for center ,not midle center or top center or bottom center . It is easy to play with the text styles but i am searching for something specific .?
I want the text to be center not left
QuoteI want the text to be center not left
you are not reading all the post.look at page2
pt (vlax-curve-getPointAtDist e (/ len 2.0))
;Get the point at mid of line/pline
(cons 11 (polar pt (+ (/ pi 2) (readableAngle ang)) kl)) ; The insert point of the text when not left aligned.
(princ "\nSelect a LINE or POLYLINE !! Error selection .... Try again....")