Trying to select multiple windows get total area??

Trying to select multiple windows get total area??

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

Trying to select multiple windows get total area??

DC-MWA
Collaborator
Collaborator

I figured out how to get the area from aec windows. Now I'm trying to select mutiple windows and get the total area. 

I think I'm close but....

I appreciate any input I can get.

Thanks.

File attached...

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

dbhunia
Advisor
Advisor

Hi

 

Your code should be like......(only modification .....)

 

 


Debashis Bhunia
Co-Founder of Geometrifying Trigonometry(C)
________________________________________________
Walking is the First step of Running, Technique comes Next....
0 Likes
Message 3 of 11

DC-MWA
Collaborator
Collaborator

Hello,

When I tried yours I get message 

"error: ActiveX Server returned the error: unknown name: "AREA""

this is because are is derived from doing the math on the two items "height" and "width".


;(setq Height (vlax-get obj 'Height))
;(setq Width (vlax-get obj 'Width))

(setq area (vlax-get obj 'Area))  <-- there is no "area' attached to aec windows.

 

 

 

 

 

 

0 Likes
Message 4 of 11

dbhunia
Advisor
Advisor

post drawing

 

or

 

Try with.....

(setq area (vlax-curve-getArea obj))

instead of.....

(setq area (vlax-get obj 'Area))

 

What is "aec windows"....????


Debashis Bhunia
Co-Founder of Geometrifying Trigonometry(C)
________________________________________________
Walking is the First step of Running, Technique comes Next....
0 Likes
Message 5 of 11

DC-MWA
Collaborator
Collaborator

The issue isn't getting the area. I have that figured out.

It's getting it to repeat as i select windows, then give me the total area when done selecting windows.

See the WINDOWAREA.lsp file (it works great on one window only)

See MULTIPLEWINDOWAREA.lsp (this is my attempt to get the program to repeat and add area as described above)

 

0 Likes
Message 6 of 11

dbhunia
Advisor
Advisor

Try this.....

 

(defun c:mwinarea ( / ent obj Height Width)
  (setq count 0)
  (setq Area-Total 0)
  (while (and (< count 100)
              (setq ent (entsel "Select aec doors and windows to get area from: "))
	 )
 	(setq obj (vlax-ename->vla-object (car ent)))
 	(setq Height (vlax-get obj 'Height))
 	(setq Width (vlax-get obj 'Width))
 	(setq area (* (vlax-get obj 'Width) (vlax-get obj 'Height))
 	(setq areasf (/ area 144))
        (print areasf)
        (setq Area-total (+ areasf Area-Total))
        (setq count (1+ count))
  ); end while
(princ (strcat "\nTotal Area:  " (vl-princ-to-string Area-total)))
(princ)
)

To check post a drawing......


Debashis Bhunia
Co-Founder of Geometrifying Trigonometry(C)
________________________________________________
Walking is the First step of Running, Technique comes Next....
0 Likes
Message 7 of 11

DC-MWA
Collaborator
Collaborator

I get error...

 

APPLOAD mwinarea.lsp successfully loaded.
Command: malformed list on input

0 Likes
Message 8 of 11

ronjonp
Mentor
Mentor
Accepted solution

Missing parenthesis on this line:

(setq area (* (vlax-get obj 'width) (vlax-get obj 'height)))

0 Likes
Message 9 of 11

DC-MWA
Collaborator
Collaborator

It seems to work great. I will test on real life senecrio.

Thank you so very much!!

 

0 Likes
Message 10 of 11

ronjonp
Mentor
Mentor

@DC-MWA wrote:

It seems to work great. I will test on real life senecrio.

Thank you so very much!!

 


I just made a small correction, @dbhunia should get the credit. 🙂

0 Likes
Message 11 of 11

ronjonp
Mentor
Mentor

Also why are you picking these one at a time? This would be very easy to modify so that you'd make one selection and get your tally. What doe this return when you pick a window: (print (cdr (assoc 0 (entget (car (entsel))))))

0 Likes