masoud_123 Posted November 26, 2014 Share Posted November 26, 2014 I was wondering if it is possible to fit mtext entity in a place by knowing the height and width of that place? How we can adjust mtext height to fit in that place in entmake mtext? (entmake (list '(0 . "MTEXT") '(102 . "{ACAD_REACTORS") '(102 . "}") '(100 . "AcDbEntity") '(100 . "AcDbMText") (cons 10 insertion_point) (cons 40 text_height) (cons 62 4) (cons 41 refrence_rectangle_width) '(42 . 2.55) '(43 . 0.18) '(44 . 1.0) '(71 . 5) '(72 . 1) (cons 1 "Your string hear") '(7 . "Text Style") '(210 0.0 0.0 1.0) '(11 1.0 0.0 0.0) '(50 . 0.0) '(73 . 1) ) ) Quote Link to comment Share on other sites More sharing options...
hanhphuc Posted November 26, 2014 Share Posted November 26, 2014 (edited) I was wondering if it is possible to fit mtext entity in a place by knowing the height and width of that place?How we can adjust mtext height to fit in that place in entmake mtext? only for single line hi masoud_123, welcome to the forum i hope this textbox factor makes sense? (defun [color="blue"]Mtext_fit[/color] (pt str / doc bb) ;hanhphuc 26/11/2014 (setq doc (vlax-get-acad-object) [color="red"]str (substr str 1 (vl-string-search "\\" str)) ;<-- added[/color] bb (apply 'mapcar (cons '- (reverse (mapcar ''((x) (cdr (reverse x))) (textbox (list (cons 1 str)))))) ) ;_ end of apply ) ;_ end of setq (vla-AddMText (foreach x '(ActiveDocument ActiveLayout Block) (setq doc (vlax-get doc x))) (vlax-3d-point pt) (* (car bb) (apply '/ (reverse bb))) str ) ;_ end of vla-AddMText ) ;_ end of defun Test (defun c:test (/ *error* pt str var) (set'var (getvar 'dynmode)) (defun *error* (msg) (if var (setvar 'dynmode var) ) ;_ end of if (princ ":-(") ) ;_ end of defun (if (and (setq pt (getpoint "\nInsertion Point..")) (setvar 'dynmode 1) (setq str (getstring "\nInput text: " t)) (setvar 'dynmode var) ) ;_ end of and ([color="blue"]Mtext_fit[/color] pt str) ) ;_ end of if (princ) ) ;_ end of defun Though the above example not entmake method, The width factor is same. Use the example above to addMtext, then entget compare the textbox with dxf index 41,42,43 I think you can figure it out Try it HTH Edited November 28, 2014 by hanhphuc substr Quote Link to comment Share on other sites More sharing options...
BIGAL Posted November 27, 2014 Share Posted November 27, 2014 Only little hiccup is that Fonts are all different in terms of their width and height ratio so may work with one style and not quite with another, also if they start kerning then a different problem again. Quote Link to comment Share on other sites More sharing options...
hanhphuc Posted November 28, 2014 Share Posted November 28, 2014 (edited) Only little hiccup is that Fonts are all different in terms of their width and height ratio so may work with one style and not quite with another, also if they start kerning then a different problem again. Thanks BIGAL. you are correct, this only for single line also not 100%. the different font or formatted string may not work correctly By adding this, it only skips "\\after slash is ignore" (substr str 1 (vl-string-search "\\" str)) example: ([color="blue"]Mtext_fit[/color] (getpoint) "FORMATED MTEXT:\\P\\pi-9.5,l1.5,t9.5;") ;then this will fit to "FORMATED MTEXT:" By manually fitting single or multi-lines, just type & *copy text contents in notepad then, in acad space right click-> paste ,or Crtl+v *automatically paste as Mtext i maybe wrong, just my $0.02 Edited November 28, 2014 by hanhphuc edit: * Quote Link to comment Share on other sites More sharing options...
masoud_123 Posted November 29, 2014 Author Share Posted November 29, 2014 Hi hanhphuc I didn't know anything about textbox... Thank you for mentioning :-) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.