teknomatika Posted October 20, 2016 Posted October 20, 2016 Hello! Does anyone know a routine that enables provide real-time the sum of areas of rectangles as you draw consecutively? Quote
tzframpton Posted October 20, 2016 Posted October 20, 2016 You can use Data Extraction for this. It provides real-time updating (granted, you have to manually Update the Table) but it will take each RECTANGLE, show the Area of each one, and you can add a footer that sums all the values. I've tested it and it works: Quote
BIGAL Posted October 21, 2016 Posted October 21, 2016 I like the data extract idea. Sum of areas, you could via a lisp invoke the rectang or pline or circle command and just keep remembering to add the area displaying after the object is drawn. Or at any time current area. Something like ask which C - P - R - T each time run. Teknomatica if you really want this ask. ; needs front end what to draw c - p - r - T ; this is generic code may not work on some objects (if (= obarea nil)(setq obarea 0.0)) (setq obj (vlax-ename->vla-object (entlast))) (setq obarea (+ (vla-get-area obj) obarea)) (Alert (strcat "Total Area is " (rtos obarea 2 3))) Quote
teknomatika Posted October 21, 2016 Author Posted October 21, 2016 I use this routine Lee Mac, which is great. It solves and my need. But the sum intended to be provided in real time and sequentially to the design of ractangles. Sorry the translated English. ;;---------------------=={ Total Area }==---------------------;; ;; ;; ;; Displays the total area of selected objects at the ;; ;; command line. ;; ;;------------------------------------------------------------;; ;; Author: Lee Mac, Copyright © 2010 - www.lee-mac.com ;; ;;------------------------------------------------------------;; (defun c:tArea nil ;; © Lee Mac 2010 ( (lambda ( SelSet Total i / entity ) (if SelSet (princ (strcat "\nTotal Area: " (rtos (while (setq entity (ssname SelSet (setq i (1+ i)))) (setq Total (+ (vlax-curve-getArea entity) Total) ) ) ) ) ) ) ) (ssget (list (cons 0 "CIRCLE,ELLIPSE,*POLYLINE,SPLINE") (cons -4 "<NOT") (cons -4 "<AND") (cons 0 "POLYLINE") (cons -4 "<OR") (cons -4 "&=") (cons 70 16) (cons -4 "&=") (cons 70 64) (cons -4 "OR>") (cons -4 "AND>") (cons -4 "NOT>") ) ) 0.0 -1 ) (princ) ) Quote
teknomatika Posted October 21, 2016 Author Posted October 21, 2016 tzframpton, Thanks for the collaboration. It is a possibility but for what I want does not seem the most practical solution. Quote
BIGAL Posted October 21, 2016 Posted October 21, 2016 teknomatika the question is why do you need to know the area as you draw ? The suggestion I made was a possible answer draw something and add area and display, Thinking about it more I would draw something then "TOTA" for total area which uses a preloaded lisp. It could also write to a file similar to dataextract with say "Circle area". The advantage of an independant command is you only add correct objects as you create. It is feasible to have a reactor that you start and it would keep adding areas till you stop it. Quote
tzframpton Posted October 22, 2016 Posted October 22, 2016 If all you need to do is pick a rectangle and see the Area, you can do that in Properties. No need for Lee Mac's code. Quote
teknomatika Posted October 24, 2016 Author Posted October 24, 2016 If all you need to do is pick a rectangle and see the Area, you can do that in Properties. No need for Lee Mac's code. I did not understand me. I want to draw many rectangles consecutively and simultaneously I want to know the value of the sum of the respective areas. That is, the area of each new rectangle is added to the previous area, and so on. Quote
Lee Mac Posted October 24, 2016 Posted October 24, 2016 I did not understand me. I want to draw many rectangles consecutively and simultaneously I want to know the value of the sum of the respective areas. That is, the area of each new rectangle is added to the previous area, and so on. Something like this perhaps? ([color=BLUE]defun[/color] c:recarea ( [color=BLUE]/[/color] are fun ocs pt1 pt2 tot ) ([color=BLUE]setq[/color] ocs ([color=BLUE]trans[/color] '(0 0 1) 1 0 [color=BLUE]t[/color]) fun ([color=BLUE]if[/color] ([color=BLUE]zerop[/color] ([color=BLUE]getvar[/color] 'worlducs)) [color=BLUE]getpoint[/color] [color=BLUE]getcorner[/color]) tot 0.0 ) ([color=BLUE]while[/color] ([color=BLUE]and[/color] ([color=BLUE]setq[/color] pt1 ([color=BLUE]getpoint[/color] [color=MAROON]"\nSpecify first point <exit>: "[/color])) ([color=BLUE]setq[/color] pt2 (fun pt1 [color=MAROON]"\rSpecify opposite corner <exit>: "[/color])) ) ([color=BLUE]entmake[/color] ([color=BLUE]list[/color] '(000 . [color=MAROON]"LWPOLYLINE"[/color]) '(100 . [color=MAROON]"AcDbEntity"[/color]) '(100 . [color=MAROON]"AcDbPolyline"[/color]) '(090 . 4) '(070 . 1) ([color=BLUE]cons[/color] 038 ([color=BLUE]caddr[/color] ([color=BLUE]trans[/color] pt1 1 ocs))) ([color=BLUE]cons[/color] 010 ([color=BLUE]trans[/color] pt1 1 ocs)) ([color=BLUE]cons[/color] 010 ([color=BLUE]trans[/color] ([color=BLUE]list[/color] ([color=BLUE]car[/color] pt2) ([color=BLUE]cadr[/color] pt1)) 1 ocs)) ([color=BLUE]cons[/color] 010 ([color=BLUE]trans[/color] pt2 1 ocs)) ([color=BLUE]cons[/color] 010 ([color=BLUE]trans[/color] ([color=BLUE]list[/color] ([color=BLUE]car[/color] pt1) ([color=BLUE]cadr[/color] pt2)) 1 ocs)) ([color=BLUE]cons[/color] 210 ocs) ) ) ([color=BLUE]setq[/color] are ([color=BLUE]apply[/color] '[color=BLUE]*[/color] ([color=BLUE]mapcar[/color] '[color=BLUE]abs[/color] ([color=BLUE]mapcar[/color] '[color=BLUE]-[/color] pt1 pt2 '(0 0)))) tot ([color=BLUE]+[/color] tot are) ) ([color=BLUE]princ[/color] ([color=BLUE]strcat[/color] [color=MAROON]"\nArea: "[/color] ([color=BLUE]rtos[/color] are) [color=MAROON]" | Total: "[/color] ([color=BLUE]rtos[/color] tot))) ) ([color=BLUE]princ[/color]) ) Quote
Grrr Posted October 24, 2016 Posted October 24, 2016 I was thinking about area field object, which would include every new drawn rectangle, so it would work even when the rectangle(s) are modified. Or some kind of reactor. Quote
teknomatika Posted October 26, 2016 Author Posted October 26, 2016 Exactly. For the task I want to save me several steps and time. Lee Mac, fantastic job again. Thank you! You are one of the best! Something like this perhaps? ([color=BLUE]defun[/color] c:recarea ( [color=BLUE]/[/color] are fun ocs pt1 pt2 tot ) ([color=BLUE]setq[/color] ocs ([color=BLUE]trans[/color] '(0 0 1) 1 0 [color=BLUE]t[/color]) fun ([color=BLUE]if[/color] ([color=BLUE]zerop[/color] ([color=BLUE]getvar[/color] 'worlducs)) [color=BLUE]getpoint[/color] [color=BLUE]getcorner[/color]) tot 0.0 ) ([color=BLUE]while[/color] ([color=BLUE]and[/color] ([color=BLUE]setq[/color] pt1 ([color=BLUE]getpoint[/color] [color=MAROON]"\nSpecify first point <exit>: "[/color])) ([color=BLUE]setq[/color] pt2 (fun pt1 [color=MAROON]"\rSpecify opposite corner <exit>: "[/color])) ) ([color=BLUE]entmake[/color] ([color=BLUE]list[/color] '(000 . [color=MAROON]"LWPOLYLINE"[/color]) '(100 . [color=MAROON]"AcDbEntity"[/color]) '(100 . [color=MAROON]"AcDbPolyline"[/color]) '(090 . 4) '(070 . 1) ([color=BLUE]cons[/color] 038 ([color=BLUE]caddr[/color] ([color=BLUE]trans[/color] pt1 1 ocs))) ([color=BLUE]cons[/color] 010 ([color=BLUE]trans[/color] pt1 1 ocs)) ([color=BLUE]cons[/color] 010 ([color=BLUE]trans[/color] ([color=BLUE]list[/color] ([color=BLUE]car[/color] pt2) ([color=BLUE]cadr[/color] pt1)) 1 ocs)) ([color=BLUE]cons[/color] 010 ([color=BLUE]trans[/color] pt2 1 ocs)) ([color=BLUE]cons[/color] 010 ([color=BLUE]trans[/color] ([color=BLUE]list[/color] ([color=BLUE]car[/color] pt1) ([color=BLUE]cadr[/color] pt2)) 1 ocs)) ([color=BLUE]cons[/color] 210 ocs) ) ) ([color=BLUE]setq[/color] are ([color=BLUE]apply[/color] '[color=BLUE]*[/color] ([color=BLUE]mapcar[/color] '[color=BLUE]abs[/color] ([color=BLUE]mapcar[/color] '[color=BLUE]-[/color] pt1 pt2 '(0 0)))) tot ([color=BLUE]+[/color] tot are) ) ([color=BLUE]princ[/color] ([color=BLUE]strcat[/color] [color=MAROON]"\nArea: "[/color] ([color=BLUE]rtos[/color] are) [color=MAROON]" | Total: "[/color] ([color=BLUE]rtos[/color] tot))) ) ([color=BLUE]princ[/color]) ) Quote
Lee Mac Posted October 26, 2016 Posted October 26, 2016 Exactly. For the task I want to save me several steps and time. Lee Mac, fantastic job again. Thank you! You are one of the best! Thank you for your kind words, I'm pleased that the program will help you and others. 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.