Visual LISP, AutoLISP and General Customization
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic to the Top
- Bookmark
- Subscribe
- Printer Friendly Page
Re: AutoLisp and Fields
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
<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) )
command: Oarea
HTH
Re: AutoLisp and Fields
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
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))))
by
(vla-put-width sst (* 2(distance (Car tm)(list (caadr tm)(cadar tm)))))
and worked!
Thanks
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
Re: AutoLisp and Fields
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
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?
angie
Re: AutoLisp and Fields
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
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.
Re: AutoLisp and Fields
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
...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.
Angie


