Message 1 of 5
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
How do I adjust my text attribute to middle center?
(defun c:TEST
(/
blkname clayerb clayeri clayer1 clayer2 styname htx wdy pnt-north pnt-east
elev2Value insertionPoint pnt pluspnt elevdir *error* twistview pnt-west pnt-south
sclx scly sclz plusymbol ADJ ELEV twistview flag 1x 1y elevdir TOC L72num L73num R72num R73num
)
(defun *error* ( msg )
(setvar "cmdecho" 1)
(if (not (member msg '("Function cancelled" "quit / exit abort")))
(princ (strcat "\nError: " msg))
)
(princ)
)
(setvar "cmdecho" 0)
(setq
blkname "SRVPNOC" ; name of Block
clayerb "-DRN" ; defined block layer
clayer1 "-DRNMARK" ; attribute def #1 layer
clayer2 "-DRNELEV" ; attribute def #2 layer
clayeri "-DRN" ; inserted block layer preferably same as defined block
styname "STANDARD" ; text style
htx 1 ; attribute def height
wdy 0.8 ; attribute def width
sclx 1 ; block insert x scale factor
scly 1 ; block insert y scale factor
sclz 1 ; block insert z scale factor
L72num 0
L73num 3
R72num 2
R73num 3
)
(setq twistview (getvar 'VIEWTWIST))
(setq TOC (car (entsel "\nSelect TOC or Enter For Elevation Input: ")))
(if (= TOC nil)
(setq TOC (getreal "\nEnter TOC Elevation: "))
(setq TOC (atof (getpropertyvalue TOC "ELEV2")))
)
(initget "Yes No")
(if (/= "No" (getkword "\nPlus Symbol Left? [Yes/No] <Y>: "))
(setq plusymbol 1)
(setq plusymbol 2)
)
(setq flag 0)
(setq ADJ 0)
(while (/= ADJ nil)
(setq 1x nil)
(setq 1y nil)
(if (= flag 1)
(progn
(initget "Yes No")
(if (/= "Yes" (getkword "\nSwitch Sides? [Yes/No] <N>: "))
(princ)
(if (= plusymbol 1)(setq plusymbol 2)(setq plusymbol 1))
)
);progn
);if
(setq ADJ nil)
(setq pnt nil)
(setq ADJ (getreal "\nEnter Elevation Adjustment: "))
(if (/= ADJ nil)
(progn
(setq ELEV (+ TOC ADJ))
(setq pnt (getpoint "\nSelect Point: "))
(setq pnt-north (polar pnt 0.0 0.52))
(setq pnt-east (polar pnt (/ pi 2) 0.52))
(setq pnt-south (polar pnt pi 0.52))
(setq pnt-west (polar pnt (* pi 1.5) 0.52))
(setq center-point (list (/ (+ (car pnt) (car pnt-north) (car pnt-east) (car pnt-south) (car pnt-west)) 5)
(/ (+ (cadr pnt) (cadr pnt-north) (cadr pnt-east) (cadr pnt-south) (cadr pnt-west)) 5)))
(if (= plusymbol 1)
(progn
;---------------------------------------------------------------------------block creation------------------------
(entmake
(list
'(0 . "BLOCK")
(cons 2 blkname) ; block name
'(70 . 2)
(cons 8 clayerb) ; layer
(cons 10 pnt) ; insertion point
'(4 . "SRVPNOC") ; comment
)
) ; end of block
; 1=default value ; 2=Tag ; 3=Prompt
(entmake
(list '(0 . "line")
'(100 . "AcDbEntity")
'(8 . "0")
'(100 . "AcDbLine")
(cons 10 pnt)
(cons 11 pnt-north)
)
)
(entmake
(list '(0 . "line")
'(100 . "AcDbEntity")
'(8 . "0")
'(100 . "AcDbLine")
(cons 10 pnt)
(cons 11 pnt-east)
)
)
(entmake
(list '(0 . "line")
'(100 . "AcDbEntity")
'(8 . "0")
'(100 . "AcDbLine")
(cons 10 pnt)
(cons 11 pnt-south)
)
)
(entmake
(list '(0 . "line")
'(100 . "AcDbEntity")
'(8 . "0")
'(100 . "AcDbLine")
(cons 10 pnt)
(cons 11 pnt-west)
)
)
(entmake
(list
'(0 . "ATTDEF")
(cons 8 clayer2) ; layer
(cons 10 pnt) ; insertion point
'(70 . 0) ; attribute flags
'(3 . "Elevation Value") ; 3=Prompt
'(2 . "ELEV2") ; 2=Tag
(cons 1 (rtos ELEV 2 2)) ; 1=default value
(cons 40 htx) ; height
(cons 41 wdy) ; width
(cons 7 styname) ; text style
(cons 11 pnt) ; match insertion point
(cons 72 L72num)
(cons 73 L73num)
)
)
(entmake '((0 . "ENDBLK")) ) ; end of block with attdef
;--------------------------------------------insert----------------------------------------------
; insert the block
(entmake
(list
'(0 . "INSERT")
(cons 2 blkname) ; block name
(cons 8 clayeri) ; layer
'(66 . 1) ; has attributes
(cons 10 pnt) ; insertion point
(cons 41 sclx) ; x scale
(cons 42 sclx) ; y scale
(cons 43 sclx) ; z scale
)
) ; begin insert Block
; attrib #2
(entmake
(list
'(0 . "ATTRIB")
(cons 10 pnt) ; insertion point
(cons 8 clayer2) ; layer
(cons 1 (rtos ELEV 2 2)) ; 1=default value
'(2 . "ELEV2") ; 2=Tag
(cons 40 htx) ; height
'(70 . 0) ; attribute flags
(cons 41 wdy) ; width
(cons 7 styname) ; text style
(cons 11 pnt) ; insertion point
(cons 72 L72num)
(cons 73 L73num)
)
)
(entmake '((0 . "SEQEND")))
(vl-cmdf"_Rotate" (entlast) "" pnt (* -1 (* 180.0 (/ (getvar "VIEWTWIST") pi))))
;---------------------------------------------------------------------------block creation------------------------
);progn
(progn
(entmake
(list
'(0 . "BLOCK")
(cons 2 blkname) ; block name
'(70 . 2)
(cons 8 clayerb) ; layer
(cons 10 pnt) ; insertion point
'(4 . "SRVPNOC Value") ; comment
)
) ; end of block
; 1=default value ; 2=Tag ; 3=Prompt
(entmake
(list '(0 . "line")
'(100 . "AcDbEntity")
'(8 . "0")
'(100 . "AcDbLine")
(cons 10 pnt)
(cons 11 pnt-north)
)
)
(entmake
(list '(0 . "line")
'(100 . "AcDbEntity")
'(8 . "0")
'(100 . "AcDbLine")
(cons 10 pnt)
(cons 11 pnt-east)
)
)
(entmake
(list '(0 . "line")
'(100 . "AcDbEntity")
'(8 . "0")
'(100 . "AcDbLine")
(cons 10 pnt)
(cons 11 pnt-south)
)
)
(entmake
(list '(0 . "line")
'(100 . "AcDbEntity")
'(8 . "0")
'(100 . "AcDbLine")
(cons 10 pnt)
(cons 11 pnt-west)
)
)
(entmake
(list
'(0 . "ATTDEF")
(cons 8 clayer2) ; layer
(cons 10 pnt) ; insertion point
'(70 . 0) ; attribute flags
'(3 . "Elevation Value") ; 3=Prompt
'(2 . "ELEV2") ; 2=Tag
(cons 1 (rtos ELEV 2 2)) ; 1=default value
(cons 40 htx) ; height
(cons 41 wdy) ; width
(cons 7 styname) ; text style
(cons 11 pnt) ; match insertion point
(cons 72 R72num)
(cons 73 R73num)
)
)
(entmake '((0 . "ENDBLK")) ) ; end of block with attdef
;--------------------------------------------insert----------------------------------------------
; insert the block
(entmake
(list
'(0 . "INSERT")
(cons 2 blkname) ; block name
(cons 8 clayeri) ; layer
'(66 . 1) ; has attributes
(cons 10 pnt) ; insertion point
(cons 41 sclx) ; x scale
(cons 42 sclx) ; y scale
(cons 43 sclx) ; z scale
)
) ; begin insert Block
; attrib #2
(entmake
(list
'(0 . "ATTRIB")
(cons 10 pnt) ; insertion point
(cons 8 clayer2) ; layer
(cons 1 (rtos ELEV 2 2)) ; 1=default value
'(2 . "ELEV2") ; 2=Tag
(cons 40 htx) ; height
'(70 . 0) ; attribute flags
(cons 41 wdy) ; width
(cons 7 styname) ; text style
(cons 11 pnt) ; insertion point
(cons 72 R72num)
(cons 73 R73num)
)
)
(entmake '((0 . "SEQEND")))
(vl-cmdf"_Rotate" (entlast) "" pnt (* -1 (* 180.0 (/ (getvar "VIEWTWIST") pi))))
);progn
);if
(setq flag 1)
);progn
);if
);while
(setvar "cmdecho" 1)
(princ) ; end insert block
)
Solved! Go to Solution.