Help with Area Reactor / MODEMACRO

Help with Area Reactor / MODEMACRO

DC-MWA
Collaborator Collaborator
1,032 Views
10 Replies
Message 1 of 11

Help with Area Reactor / MODEMACRO

DC-MWA
Collaborator
Collaborator

Hello,

I have a cool tool I use all day every day. I know this was from the internet but I do not know whom to give credit for this super cool program. It allows me to touch (activate grips) multiple objects and get the area, length, etc. for those selected objects and displays the information in the task bar. It gives the information in square feet, acres, sq yards and linear feet and at the beginning shows the number of objects selected.

Example:

DCMWA_0-1677777863318.png

 

I'm hoping that one of you gurus can assist me adding HATCH objects to the list of objects this lisp works with. I tried adding HATCH to the ssget but I just get an error message "error: bad argument value: AcDbCurve 65".

My programming skills are very limited as most of know already.

Thanks in advance for any assistance or input.

-DC

 

 

 

0 Likes
Accepted solutions (2)
1,033 Views
10 Replies
Replies (10)
Message 2 of 11

Kent1Cooper
Consultant
Consultant

Hatch patterns are not (vlax-curve-...)-class objects, so properties extracted using those methods can't be pulled from them.  They do have a VLA property as well as a (getpropertyvalue)-approach one for Area, so an (if) function checking for entity type could put their area into the mix, by getting it in a different way from how it does for the other kinds.  But they don't seem to have a VLA or (getpropertyvalue) property for perimeter, so I'm not sure how that could be extracted.  Ordinarily, one might do that by generating the boundary and looking at the properties of the result, but I don't suppose something can be drawn within a reactor feeding a Modemacro entry.  And the result could be more than one boundary object.  Even if single, that could be a Region, which isn't a (vlax-curve-...)-class object either, but conveniently has both Area and Perimeter properties in both VLA and (getpropertyvalue) approaches.

Kent Cooper, AIA
0 Likes
Message 3 of 11

DC-MWA
Collaborator
Collaborator

Well, I was hoping it would be a simple task. I can do the same with property ribbon but it puts square inches first so I have to fill me screen with this huge properties box in order to see the area and Properties does not give perimeter, only length.

Thank you for your time.

0 Likes
Message 4 of 11

ВeekeeCZ
Consultant
Consultant
Accepted solution

Try this. The perimeter of HATCH returns 0.

 

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;----------------------------------------------------------------------------------------------;;
;;;;;;;;;;;;;;;;;;;;;;;;;;AREA REACTOR FOR MODEMACRO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;----------------------------------------------------------------------------------------------;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun c:AreaR nil
  (if *AreaR:Reactor*
    (progn (vlr-remove *AreaR:Reactor*)
           (setq *AreaR:Reactor* (prompt "\nTotal Area Reactor is inactive!"))
           (and *AreaR:ModeMacro* (setvar 'MODEMACRO *AreaR:ModeMacro*))
    )
    (progn (vlr-set-notification
             (setq *AreaR:Reactor*
                    (vlr-miscellaneous-reactor
                      nil
                      '((:vlr-pickfirstmodified . AreaR:Reactor))
                    )
             )
             'Active-Document-Only
           )
           (setq *AreaR:ModeMacro* (getvar 'MODEMACRO))
           (prompt "\nTotal Area Reactor active!")
    )
  )
  (princ)
)
(defun AreaR:Reactor (react param / ss area perim data a p i e o)
  (if (setq ss (ssget "_I" '((0 . "AECC_FEATURE_LINE,ARC,CIRCLE,ELLIPSE,LINE,*POLYLINE,SPLINE,AEC_WALL,HATCH"))))
    (progn (setq i -1
                 area 0.
                 perim 0.
                 *AreaR:Info*
                  nil
           )
           (while (setq e (ssname ss (setq i (1+ i))))

	     (setq o (vlax-ename->vla-object e))
             (setq area         (+ area (setq a (if (vl-catch-all-error-p (setq a (vl-catch-all-apply 'vla-get-Area (list o))))
						  0
						  a)))
                   perim        (+ perim (setq p (if (vl-catch-all-error-p (setq p (vl-catch-all-apply 'vlax-curve-getEndParam (list o))))
						   0
						   (vlax-curve-getDistAtParam e p))))
                   data         (entget e)
                   *AreaR:Info* (cons (strcat (cdr (assoc 8 data))
                                              ","
                                              (cdr (assoc 0 data))
                                              ","
                                              (rtos a 2 3)
                                              ","
                                              (rtos p 2 3)
                                      )
                                      *AreaR:Info*
                                )
             )
           )
           (setvar 'MODEMACRO
                   (setq *AreaR:Clipboard*
                          (strcat "("
                                  (itoa (sslength ss))
                                  ") "
				  "Area: "
                                  (rtos (/ area 144) 2 2)
                                  " SF ~ "
                                  (rtos (/ (/ area 144) 43560.0) 2 2)
                                  " AC ~ "
                                  (rtos (/ (/ area 144) 9.00) 2 2)
				  " SY ~ "
                                 ; " SY ~ Length/Perimeter: "
                                  " Length/Perimeter: "
                                  (rtos (/ perim 12) 2 2)
                                  " LF"
                          )
                   )
           )
    )
    (setvar 'MODEMACRO
            (cond (*AreaR:ModeMacro*)
                  ("")
            )
    )
  )
  (princ)
)
(or *AreaR:Reactor* (c:AreaR))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

 

0 Likes
Message 5 of 11

DC-MWA
Collaborator
Collaborator

This seems to work....

0 Likes
Message 6 of 11

Kent1Cooper
Consultant
Consultant

@ВeekeeCZ wrote:

Try this. The perimeter of HATCH returns 0.

....
                                  " Length/Perimeter: "
....

So should that part of the status-line report say something like this?

" Length/Perimeter [except Hatch(es)]: "
Kent Cooper, AIA
0 Likes
Message 7 of 11

DC-MWA
Collaborator
Collaborator
I have added this to our acaddoc file and will continue to stress test. I looks like it works perfectly.
Thank you for your time!!
0 Likes
Message 8 of 11

DC-MWA
Collaborator
Collaborator

That is a great idea.

0 Likes
Message 9 of 11

DC-MWA
Collaborator
Collaborator

First let me say that your assistance with this has made this tool supper helpful. All my drafters are stoked! This is a huge time saver, I am forever grateful!!

This has prompted me to add another item to the list. It seemed easy enough with your programming in place to add AEC_SPACE to the ssget list. The problem is that the AEC SPACE area in in square feet. Wherein, hatch for example area is in square inches. So the MODEMACRO applies *144 to the display.

DCMWA_1-1678209544040.png

Displays 18.69 SF (incorrect)

 

DCMWA_2-1678209614422.png

Displays 2691.80 sf (correct)

 

Is it possible to modify the lisp to recognize if the selected object(s) is a SPACE and apply *144 to area?

Thanks in advance for your time.

0 Likes
Message 10 of 11

ВeekeeCZ
Consultant
Consultant
Accepted solution

Possibly something like this.

 

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;----------------------------------------------------------------------------------------------;;
;;;;;;;;;;;;;;;;;;;;;;;;;;AREA REACTOR FOR MODEMACRO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;----------------------------------------------------------------------------------------------;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun c:AreaR nil
  (if *AreaR:Reactor*
    (progn (vlr-remove *AreaR:Reactor*)
           (setq *AreaR:Reactor* (prompt "\nTotal Area Reactor is inactive!"))
           (and *AreaR:ModeMacro* (setvar 'MODEMACRO *AreaR:ModeMacro*))
    )
    (progn (vlr-set-notification
             (setq *AreaR:Reactor*
                    (vlr-miscellaneous-reactor
                      nil
                      '((:vlr-pickfirstmodified . AreaR:Reactor))
                    )
             )
             'Active-Document-Only
           )
           (setq *AreaR:ModeMacro* (getvar 'MODEMACRO))
           (prompt "\nTotal Area Reactor active!")
    )
  )
  (princ)
)
(defun AreaR:Reactor (react param / ss area perim data a p i e o)
  (if (setq ss (ssget "_I" '((0 . "AECC_FEATURE_LINE,ARC,CIRCLE,ELLIPSE,LINE,*POLYLINE,SPLINE,AEC_WALL,HATCH"))))
    (progn (setq i -1
                 area 0.
                 perim 0.
                 *AreaR:Info*
                  nil
           )
           (while (setq e (ssname ss (setq i (1+ i))))

	     (setq o (vlax-ename->vla-object e))
             (setq area         (+ area (setq a (if (vl-catch-all-error-p (setq a (vl-catch-all-apply 'vla-get-Area (list o))))
						  0
						  (if (= "AEC_SPACE" (cdr (assoc 0 (entget e))))
						    (* a 144)
						    a)
						  )))
                   perim        (+ perim (setq p (if (vl-catch-all-error-p (setq p (vl-catch-all-apply 'vlax-curve-getEndParam (list o))))
						   0
						   (vlax-curve-getDistAtParam e p))))
                   data         (entget e)
                   *AreaR:Info* (cons (strcat (cdr (assoc 8 data))
                                              ","
                                              (cdr (assoc 0 data))
                                              ","
                                              (rtos a 2 3)
                                              ","
                                              (rtos p 2 3)
                                      )
                                      *AreaR:Info*
                                )
             )
           )
           (setvar 'MODEMACRO
                   (setq *AreaR:Clipboard*
                          (strcat "("
                                  (itoa (sslength ss))
                                  ") "
				  "Area: "
                                  (rtos (/ area 144) 2 2)
                                  " SF ~ "
                                  (rtos (/ (/ area 144) 43560.0) 2 2)
                                  " AC ~ "
                                  (rtos (/ (/ area 144) 9.00) 2 2)
				  " SY ~ "
                                 ; " SY ~ Length/Perimeter: "
                                  " Length/Perimeter: "
                                  (rtos (/ perim 12) 2 2)
                                  " LF"
                          )
                   )
           )
    )
    (setvar 'MODEMACRO
            (cond (*AreaR:ModeMacro*)
                  ("")
            )
    )
  )
  (princ)
)
(or *AreaR:Reactor* (c:AreaR))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

 

0 Likes
Message 11 of 11

DC-MWA
Collaborator
Collaborator

Perfect. Thank you so very much! I cannot express my gratitude enough. I truly appreciate your assistance and skillset my friend.

0 Likes