<Not Tested for newer version> 2010 onwards
(defun c:Oarea (/ Get-ObjectIDx64 space ss pt are sst tm)(vl-load-com) ;;; Jimmy Bergmark ;;; ;;; http://blog.jtbworld.com/ ;;; (defun Get-ObjectIDx64 (obj / util) (setq util (vla-get-Utility (vla-get-activedocument (vlax-get-acad-object)))) (if (> (vl-string-search "x64" (getvar "platform")) 0) (vlax-invoke-method util "GetObjectIdString" obj :vlax-False) (itoa (vla-get-Objectid obj)) ) ) ;;; pBe Oct 18 2012 ;;; (if (and (setq ss (car (entsel "\n Select Object for Area : "))) (vlax-property-available-p (setq ss (vlax-ename->vla-object ss)) 'Area) (setq pt (getpoint "\n Specify Text Location :")) ) (progn (setq are (rtos (* (vla-get-area ss) 0.0001) 2 2) sst (vlax-invoke (vlax-get (vla-get-ActiveLayout (vla-get-activedocument (vlax-get-acad-object))) 'Block) 'addMText pt 1. (strcat "%<\\AcObjProp Object(%<\\_ObjId " (Get-ObjectIDx64 ss) ">%).Area \\f \"%lu2%pr2%ps[, m²]%ct8[0.0001]\">%") ) tm (textbox (list (cons 1 (strcat (vl-string-translate "1" "0" are) " m²")) (cons 40 (vla-get-height sst)) (cons 7 (getvar 'TextStyle))))) (vla-put-width sst (distance (Car tm)(list (caadr tm)(cadar tm)))) )(princ "\nNo object for Area Text Selected")) (princ) )
For the Arial font does not work only with this value. But if doubling works well.
I changed the code:
(vla-put-width sst (distance (Car tm)(list (caadr tm)(cadar tm))))
(vla-put-width sst (* 2(distance (Car tm)(list (caadr tm)(cadar tm)))))
I intend in the future to increase. I'll put a "GetString" to capture a name for the room. Also select the name of the layer via a hatch field to define the type of flooring. etc
I am working on another project were I need to use a field, but in this case we are showing imperial and metric in the dimension. (with alternate units) the field only shows the primary units. How can I get it to show both? I've tried monkeying around with it a bit using the field expression that shows up when I create the field with no luck.
Is it possible to do this?
I'm not sure how.
but you can convert the value using the following calculation:
1 m² = (3.28083989501) ² = 10.7639104167 ft ²
can see that in my case I need to convert from cm to m² in the following line:
(setq are (rtos (* (vla-get-area ss) 0.0001) 2 2)
believe you can replicate content writing line area and do the conversion to their units (imperial)
I hope someone more expert can give a more concrete help.
...so I cheated a little to make this work.
I drew a line along the edge I was dimensioning. then I had the field reference the length of the line instead of using the measurement. This way I was able to get the units I needed, and if the user stretches the object, the line I drew will stretch along with it and the field will still update. An extra step, but it works.
This rutine is very good
(vl-load-com) (defun c:Test (/ space ss pt) ; Tharwat 14. 06. 2011 (setq space (vla-get-modelspace (vla-get-ActiveDocument (vlax-get-acad-object)) ) ) (if (and (setq ss (car (entsel "\n Select a Dimension : "))) (setq pt (getpoint "\n Specify Text Location :")) ) (vla-addMText space (vlax-3d-point pt) 4. (strcat "%<\\AcObjProp Object(%<\\_ObjId " (itoa (vla-get-ObjectID (vlax-ename->vla-object ss))) ">%).Measurement \\f \"%lu6\">%" ) ) (princ) ) (princ) )
Can you help me how can write the mtext with text height 50? And after I need to explode it to convert for normal text.