Peu Posted April 18, 2011 Posted April 18, 2011 (edited) Hello everyone! I usually acess the forum by a friend's account. But now I really need you help. I found a very good lisp to take the area of a polyline and insert it with field properties with the text size you have active on annotation preset. The only problem is that it shows the measurement as Sq. Ft. But works well on Autocad 2011 x64. This is the Lisp command I found: ;;; AreaText.LSP ver 3.0 ;;; Command name is AT ;;; Select a polyline and where to place the text ;;; Sample result: 2888.89 sq ft ;;; As this is a FIELD it is updated based on the FIELDEVAL ;;; or the settings found in the OPTIONS dialog box ;;; By Jimmy Bergmark ;;; Copyright (C) 2007-2010 JTB World, All Rights Reserved ;;; Website: [url="http://www.jtbworld.com/"]www.jtbworld.com[/url] ;;; E-mail: [email="info@jtbworld.com"]info@jtbworld.com[/email] ;;; 2007-09-05 - First release ;;; 2009-08-02 - Updated to work in both modelspace and paperspace ;;; 2010-10-29 - Updated to work also on 64-bit AutoCAD ;;; Uses TEXTSIZE for the text height (defun Get-ObjectIDx64 (obj / util) (setq util (vla-get-Utility (vla-get-activedocument (vlax-get-acad-object)))) (if (= (type obj) 'ENAME)(setq obj (vlax-ename->vla-object obj))) (if (= (type obj) 'VLA-OBJECT) (if (> (vl-string-search "x64" (getvar "platform")) 0) (vlax-invoke-method util "GetObjectIdString" obj :vlax-False) (rtos (vla-get-objectid obj) 2 0) ) ) ) (defun c:AT (/ entObject entObjectID InsertionPoint ad) (vl-load-com) (setq entObject (vlax-ename->vla-object(car (entsel))) entObjectID (Get-ObjectIDx64 entObject) InsertionPoint (vlax-3D-Point (getpoint "Select point: ")) ad (vla-get-ActiveDocument (vlax-get-acad-object)) ) (vla-addMText (if (= 1 (vla-get-activespace ad)) (vla-get-modelspace ad) (if (= (vla-get-mspace ad) :vlax-true) (vla-get-modelspace ad) (vla-get-paperspace ad) ) ) InsertionPoint 0.0 (strcat "####" )) ) I would be very thankfull if someone can help me changing this lisp to show the measures only as sq meters (with sufix "m²"). I got this line somewhere, I don't know if it is usefull: ("%<[url="file://acobjprop/"]\\AcObjProp[/url] Object(%<[url="file://_objid/"]\\_ObjId[/url] "(rtos objID 2 0)">%).Area [url="file://f/"]\\f[/url] \"%lu2%pr1%ps[Area , m sq]%ct8[1e-006]\">%") Thank you very much! Edited April 19, 2011 by Peu Add info Quote
SLW210 Posted April 18, 2011 Posted April 18, 2011 you need to use Code Tags Just select (#) and you will get Have you tried jtbworld? Quote
Peu Posted April 19, 2011 Author Posted April 19, 2011 SLW210, I just Changed my post with # on codes. Sry. I also found that code on jtbworld, there are none code to area in meters showing the result with field propertis like this one. Thread: Hello everyone! I usually acess the forum by a friend's account. But now I really need you help. I found a very good lisp to take the area of a polyline and insert it with field properties with the text size you have active on annotation preset. The only problem is that it shows the measurement as Sq. Ft. But works well on Autocad 2011 x64. This is the Lisp command I found: ;;; AreaText.LSP ver 3.0 ;;; Command name is AT ;;; Select a polyline and where to place the text ;;; Sample result: 2888.89 sq ft ;;; As this is a FIELD it is updated based on the FIELDEVAL ;;; or the settings found in the OPTIONS dialog box ;;; By Jimmy Bergmark ;;; Copyright (C) 2007-2010 JTB World, All Rights Reserved ;;; Website: [url="http://www.jtbworld.com"]www.jtbworld.com[/url] ;;; E-mail: [email="info@jtbworld.com"]info@jtbworld.com[/email] ;;; 2007-09-05 - First release ;;; 2009-08-02 - Updated to work in both modelspace and paperspace ;;; 2010-10-29 - Updated to work also on 64-bit AutoCAD ;;; Uses TEXTSIZE for the text height (defun Get-ObjectIDx64 (obj / util) (setq util (vla-get-Utility (vla-get-activedocument (vlax-get-acad-object)))) (if (= (type obj) 'ENAME)(setq obj (vlax-ename->vla-object obj))) (if (= (type obj) 'VLA-OBJECT) (if (> (vl-string-search "x64" (getvar "platform")) 0) (vlax-invoke-method util "GetObjectIdString" obj :vlax-False) (rtos (vla-get-objectid obj) 2 0) ) ) ) (defun c:AT (/ entObject entObjectID InsertionPoint ad) (vl-load-com) (setq entObject (vlax-ename->vla-object(car (entsel))) entObjectID (Get-ObjectIDx64 entObject) InsertionPoint (vlax-3D-Point (getpoint "Select point: ")) ad (vla-get-ActiveDocument (vlax-get-acad-object)) ) (vla-addMText (if (= 1 (vla-get-activespace ad)) (vla-get-modelspace ad) (if (= (vla-get-mspace ad) :vlax-true) (vla-get-modelspace ad) (vla-get-paperspace ad) ) ) InsertionPoint 0.0 (strcat "####" )) ) I would be very thankfull if someone can help me changing this lisp to show the measures only as sq meters (with sufix "m²"). I got this line somewhere, I don't know if it is usefull: ("%<[url="file://\\AcObjProp"]\\AcObjProp[/url] Object(%<[url="file://\\_ObjId"]\\_ObjId[/url] "(rtos objID 2 0)">%).Area [url="file://\\f"]\\f[/url] \"%lu2%pr1%ps[Area , m sq]%ct8[1e-006]\">%") Thank you very much! Quote
Cad64 Posted April 20, 2011 Posted April 20, 2011 I have approved your posts. They were moderated by the forum software due to the multiple links in the code you posted. Quote
Peu Posted April 20, 2011 Author Posted April 20, 2011 (edited) Thank you CAD64, I thought I did something wrong =) I gess I am almost there... I tried change some lines, but I still can't insert the measure as meters ans also I could't insert prefix (Area=) This is the last version so far: ;;; AreaText.LSP ver 3.0 ;;; Command name is AT ;;; Select a polyline and where to place the text ;;; Sample result: 2888.89 sq ft ;;; As this is a FIELD it is updated based on the FIELDEVAL ;;; or the settings found in the OPTIONS dialog box ;;; By Jimmy Bergmark ;;; Copyright (C) 2007-2010 JTB World, All Rights Reserved ;;; Website: www.jtbworld.com ;;; E-mail: info@jtbworld.com ;;; 2007-09-05 - First release ;;; 2009-08-02 - Updated to work in both modelspace and paperspace ;;; 2010-10-29 - Updated to work also on 64-bit AutoCAD ;;; Uses TEXTSIZE for the text height (defun Get-ObjectIDx64 (obj / util) (setq util (vla-get-Utility (vla-get-activedocument (vlax-get-acad-object)))) (if (= (type obj) 'ENAME)(setq obj (vlax-ename->vla-object obj))) (if (= (type obj) 'VLA-OBJECT) (if (> (vl-string-search "x64" (getvar "platform")) 0) (vlax-invoke-method util "GetObjectIdString" obj :vlax-False) (rtos (vla-get-objectid obj) 2 0) ) ) ) (defun c:AT (/ entObject entObjectID InsertionPoint ad) (vl-load-com) (setq entObject (vlax-ename->vla-object(car (entsel))) entObjectID (Get-ObjectIDx64 entObject) InsertionPoint (vlax-3D-Point (getpoint "Select point: ")) ad (vla-get-ActiveDocument (vlax-get-acad-object)) ) (vla-addMText (if (= 1 (vla-get-activespace ad)) (vla-get-modelspace ad) (if (= (vla-get-mspace ad) :vlax-true) (vla-get-modelspace ad) (vla-get-paperspace ad) ) ) InsertionPoint 0.0 (strcat "%<[url="file://acobjprop/"]\\AcObjProp[/url] Object(%<[url="file://_objid/"]\\_ObjId[/url] " entObjectID ">%).Area [url="file://f/"]\\f[/url] \"%pr2%lu2%ct4%qf1 m²\">%" )) ) Still needing your help! Thank you! Edited April 20, 2011 by SLW210 Quote
alanjt Posted April 20, 2011 Posted April 20, 2011 This should help... I find it's easiest to construct a mock field and then use vla-fieldcode to retrieve the field coding. Quote
Peu Posted April 20, 2011 Author Posted April 20, 2011 (edited) Alanjt, Thank you very much for you help, but I still can't make it work I got this msg on Autocad Command Line: "Select object: Select point: ; error: bad argument type: stringp nil" I used this one: ;;; AreaText.LSP ver 3.0 ;;; Command name is AT ;;; Select a polyline and where to place the text ;;; Sample result: 2888.89 sq ft ;;; As this is a FIELD it is updated based on the FIELDEVAL ;;; or the settings found in the OPTIONS dialog box ;;; By Jimmy Bergmark ;;; Copyright (C) 2007-2010 JTB World, All Rights Reserved ;;; Website: www.jtbworld.com ;;; E-mail: info@jtbworld.com ;;; 2007-09-05 - First release ;;; 2009-08-02 - Updated to work in both modelspace and paperspace ;;; 2010-10-29 - Updated to work also on 64-bit AutoCAD ;;; Uses TEXTSIZE for the text height (defun Get-ObjectIDx64 (obj / util) (setq util (vla-get-Utility (vla-get-activedocument (vlax-get-acad-object)))) (if (= (type obj) 'ENAME)(setq obj (vlax-ename->vla-object obj))) (if (= (type obj) 'VLA-OBJECT) (if (> (vl-string-search "x64" (getvar "platform")) 0) (vlax-invoke-method util "GetObjectIdString" obj :vlax-False) (rtos (vla-get-objectid obj) 2 0) ) ) ) (defun c:ATF (/ entObject entObjectID InsertionPoint ad) (vl-load-com) (setq entObject (vlax-ename->vla-object(car (entsel))) entObjectID (Get-ObjectIDx64 entObject) InsertionPoint (vlax-3D-Point (getpoint "Select point: ")) ad (vla-get-ActiveDocument (vlax-get-acad-object)) ) (vla-addMText (if (= 1 (vla-get-activespace ad)) (vla-get-modelspace ad) (if (= (vla-get-mspace ad) :vlax-true) (vla-get-modelspace ad) (vla-get-paperspace ad) ) ) InsertionPoint 0.0 (strcat "%<\AcObjProp.16.2 Object(%<\_ObjId 8796088874016>%).Area \f "%lu2%ct4%qf1%pr2 m²%ps[A=,m²]%ct8[144]">%" )) ) Any more hints? =) I am also learning something! Edited April 20, 2011 by SLW210 Quote
alanjt Posted April 20, 2011 Posted April 20, 2011 You don't have your quotes positioned correctly and you aren't applying the object id to the field. try with: (strcat "%<\\AcObjProp.16.2 Object(%<\\_ObjId " entObjectID ">%).Area \\f \"%lu2%pr2%ps[A=,m²]%ct8[144]\">%" ) BTW, you should put Bergmark's header back, not cool at all to remove it. Quote
Peu Posted April 20, 2011 Author Posted April 20, 2011 anlanjt, I'm very grateful! It worked perfectly! Bergmark's will come back for sure. I just removed to insert here in the forum, the web links need the moderator approval and take sometime to appear. Thank you very much! I'll save a lot of time now! =) Quote
SLW210 Posted April 20, 2011 Posted April 20, 2011 I put the headers back. If you need help with something just ask Peu. Mods are here to help. Quote
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.