Automatic_area_LISP_customization

Automatic_area_LISP_customization

Lukasvop1
Advocate Advocate
3,095 Views
32 Replies
Message 1 of 33

Automatic_area_LISP_customization

Lukasvop1
Advocate
Advocate

Hi guys,

I found great lisp for automatic calculating area inside closed polyline created by Ronald Maneja  but I need customized it for myself. It's probably easy but I'm not programmer so if you have a little bit of time can you watch this? Thank you.

 

I need this 3 things :    1. Change ''.'' to '',''  -  e.g  25.3 to 25,3 

                                        2. Number format   -  e.g. 25 to 25,0  (after whole numbers add ,0)

                                        3. Allow add Suffix -  e.g  25,3 to 25,30 m²

 

 

;;; CADALYST 07/08 www.cadalyst.com/code
;;; Tip 2292: AreaRon.lsp Area of Closed Polylines (c) 2008 Ronald Maneja

;;; PRODUCES TEXT CONTAINING AREA OF SELECTED CLOSED POLYLINES
;;; AND PUTS THEM IN AREARON LAYER
;;; CREATED BY RON MANEJA 31JAN08
;;; USER INPUTS: SCALE, POLYLINE SELECTION
;;;

 

(defun C:AREARON (/
allx
ally
areaobj
counter
ctr
el
entity-name
entnamevla
mysset
pt
tst
vertex
x
y
)
(vl-load-com)
(COMMAND "_.UNDO" "BE")
(set_var)
(if (tblsearch "Layer" "AREARON")
(command "._layer"
"_thaw"
"AREARON"
"_on"
"AREARON"
"_unlock"
"AREARON"
"_set"
"AREARON"
""
) ;_ closes command
(command "._layer"
"_make"
"AREARON"
"_color"
1
"AREARON"
""
) ;_ closes command
)
(if (null sch)
(setq sch 1.0)
)
(initget 6)
(setq temp (getreal (strcat "\nENTER SCALE <"
(rtos sch 2 2)
">: "
)

 

0 Likes
Accepted solutions (2)
3,096 Views
32 Replies
Replies (32)
Message 2 of 33

paullimapa
Mentor
Mentor

no modifications required, check out my free open-source code Area Object Link app

 


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 Likes
Message 3 of 33

Lukasvop1
Advocate
Advocate

..

0 Likes
Message 4 of 33

Lukasvop1
Advocate
Advocate
I saw your app and work's well but if you have large floor plan with 100+ rooms just suck. This is totally different league just customized it..
0 Likes
Message 5 of 33

paullimapa
Mentor
Mentor

Unfortunately the AREAON.lsp you're referring to has the following limitations:

1. Uses vla-get-area function which does not allow for formatting

2. Do not use FIELDS so when the pline changes in shape/size, the area values will not update


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 Likes
Message 6 of 33

Lukasvop1
Advocate
Advocate

Well, maybe have some limitation for some cases but If don't need update individual areas (I think it's really rare ) it's 100x faster than your AOL app (nothing personal).

0 Likes
Message 7 of 33

paullimapa
Mentor
Mentor
I understand what you are trying to do but the code will requires a complete rewrite so not as simple as just modifying it

Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 Likes
Message 8 of 33

Lukasvop1
Advocate
Advocate

I thought it's just a few easy changes, as I write I'm not a programmer so hope it will see some passionate programmer and be able to rewrite it, I really appreciated it and think many other people here too.

0 Likes
Message 9 of 33

_Tharwat
Advisor
Advisor

Could you post the entire codes so me or anyone else could suggest a solution for your desired mods ?

0 Likes
Message 10 of 33

paullimapa
Mentor
Mentor
See link in message 5

Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 Likes
Message 11 of 33

_Tharwat
Advisor
Advisor
Accepted solution

Replace this 

(command "text" "j" "mc" pt (* sch 2.5) "0"(rtos areaobj 2 precision))

With this

(command "text" "j" "mc" pt (* sch 2.5) "0" (strcat 
(vl-string-translate "." "," (rtos areaobj 2 precision)) " m²")
)

 

Message 12 of 33

paullimapa
Mentor
Mentor

excellent trick...I was just thinking of doing this as a bandaid....


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
Message 13 of 33

paullimapa
Mentor
Mentor
Accepted solution

Inspired by @_Tharwat change the same line of code so that it'll be a FIELD that will automatically update the AREA when the PLINE shape changes:

Existing code:

(rtos areaobj 2 precision)

Modified code:

(strcat "%<\\AcObjProp.16.2 Object (%<\\_ObjId " (Get-ObjectIDx64 entnamevla) ">%).Area \\f \"%lu2" "%pr" (itoa precision) "%ps[, m2]%ds44"">%")

 

PS: you'll also need this line of code after  (vl-load-com)

(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 Get-ObjectIDx64


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
Message 14 of 33

Lukasvop1
Advocate
Advocate

Now works well, thank you guys for great job.

0 Likes
Message 15 of 33

Lukasvop1
Advocate
Advocate

I've got one more issue if change suffix from m2 to m² I get this result..

0 Likes
Message 16 of 33

paullimapa
Mentor
Mentor

I’m not at a computer now but try one if the solutions discussed in this thread

https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/mm2/m-p/1639312

 


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 Likes
Message 17 of 33

paullimapa
Mentor
Mentor

Looks like the last solution on that thread worked:

"%ps[, m" (chr 178) "]%ds44"">%")

paulli_apa_0-1662991010730.png

FYI: I also modified the routine to use AutoCAD's built-in geocenter object snap feature to get the pline's center point instead of spending the time calculating it.


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 Likes
Message 18 of 33

Lukasvop1
Advocate
Advocate

Thank you, it looks great but still not work for me, I don't know what's wrong?

 

arearon_m2.png

0 Likes
Message 19 of 33

paullimapa
Mentor
Mentor

not sure what the problem is.

what happens when you open my drawing...does it look like this:

paulli_apa_0-1662994843951.png

 


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 Likes
Message 20 of 33

paullimapa
Mentor
Mentor

FYI, My STANDARD text Style is Arial:

paulli_apa_0-1662995017283.png

 


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 Likes