Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Lisp Routine to place lights in a room evenly

52 REPLIES 52
Reply
Message 1 of 53
mwhea
6695 Views, 52 Replies

Lisp Routine to place lights in a room evenly

Hello,

 

I was wondering if anyone had a lisp routine that divided up a normal square / rectangle room and insert a block at each given point.

 

At present if the room was to have four lights width ways and three lights length ways we would divide the width by eight to give us 1/2 1 1 1/2 so the lights would be placed on every second point after the divde command (dividing the room by twice the amound of lights needed). 

 

Hopefully someone already has a lisp routine that does this dividing for simple rooms as obviously its a bit more tricky when it comes to rooms that are odly shaped. Any help would be appreciated.

 

Kind Regards,

Mark

52 REPLIES 52
Message 21 of 53
jason.estas
in reply to: pbejse

G'day,

 

I myself was after this very same lisp routine. But since I am not the best lisp creator I engaged the very one and only Lee Mac to write a program for me at a cost.

 

I have attached the program which he created for me as a kind of pay it forward situation.

 

Please do not modify the code in anyway and always leave Lee Mac at the Top.

 

Please enjoy as I know this little Lisp routine has help myself and my organization greatly.

 

Jasaon

Message 22 of 53
scot-65
in reply to: mwhea


@mwhea wrote:
...thought about wanting to add into it later on like ceiling tiles for instances where we cant just space our lights evenly but based on an actual grid tile setout point. 

Mwhea,

 

Attached files is what I showed earlier.

Giving more thought to the commercial (suspended ceilings) as well as residential,

I have developed the interface some more... Have a WIP look:

 

RLA02.gif

 

The LSP side of the above dialog has not been straightened out yet...

 

Scot-65

 

 


Scot-65
A gift of extraordinary Common Sense does not require an Acronym Suffix to be added to my given name.


Message 23 of 53
scot-65
in reply to: scot-65

REVISED, REWORKED, and STABILIZED.

 

Hopefully I have covered everything regarding light placement types for both Commercial and Residential.

The following interface is stabilized, and the help facility is developed, but not finished.

This is a working interface, the executing program is missing... Have a look.

 

RLA04.gif

 

Scot-65

 

 


Scot-65
A gift of extraordinary Common Sense does not require an Acronym Suffix to be added to my given name.


Message 24 of 53
mwhea
in reply to: jason.estas

Scot65,

 

From looking at your previous posts, the program you have made seems pretty in depth and would be very useful for companies (maybe post it serpately so more people may see it?) though in australia we use metric system so the imperial (inches) and what not doesn't work so much for us as we would be doing calculations all the time before inserting.

 

Mark 

Message 25 of 53
scot-65
in reply to: mwhea

mwhea,

 

My brief taste into light layout included the required lumens value at floor level

based on the fixture output at the height specified above said floor level.

With this in mind one calculates the spacing between the lights. Stop here.

The interface begins where the spacing of the lights is known, and the

program will determine total number of fixtures in the given area.

Simple enough? (apologies if I did not understand you...)

 

Regarding metric, the executable part of the interface is not developed.

The interface can be reworded without much trouble to say CM or Meters...

Since I do not know "standard" Metric sizing's, I will leave this converting

up to you.

 

And Yes, this routine will be developed for our office. Production will

kneel at my feet and kiss the back of my hand when I release this...

Maybe they can each in turn buy me lunch for the next 3 months?

 

Scot-65   🙂

 


Scot-65
A gift of extraordinary Common Sense does not require an Acronym Suffix to be added to my given name.


Message 26 of 53
jason.estas
in reply to: mwhea

mwhea,

 

Did you not see the lisp routine in my previous post? I too am from Australia and that program for which my company paid to get developed works a treat.

 

Let me know if it is what you are after!

 

Jason

Message 27 of 53
Lexusmax
in reply to: Kent1Cooper

You sir are a genius 

 

Is there any way to pick block directly on drawing instead to type the block name.

Could we choose the side of Rectangular instead we choose the corner of the Rectangular .

Please help me this master. I deeply need your help.

Please reply me via my email tltrung@secvn.com

 

Thank you very much.

 

Le Trung

Tags (1)
Message 28 of 53
Kent1Cooper
in reply to: Lexusmax


@Lexusmax wrote:

You sir are a genius 

 

Is there any way to pick block directly on drawing instead to type the block name.

Could we choose the side of Rectangular instead we choose the corner of the Rectangular .

Please help me this master. I deeply need your help.

Please reply me via my email tltrung@secvn.com

 

Thank you very much.

 

Le Trung


Welcome to the Forums!

 

I assume you mean you want to select a Polyline rectangle along any side, since either choosing something like a Line or choosing two endpoints of a side would not provide enough information.  If it's a closed Polygon rectangle, this simple edit of the routine seems to work.

 

(defun C:arb (/ c1 c2 wid ht rows cols blk); = Lights in Rectangular [& orthogonal] Room
  (setq
    pl (car (entsel "\nSelect Polyline rectangle: "))
    c1 (cdr (assoc 10 (entget pl)))
    c2 (vlax-curve-getPointAtParam pl 2)
    wid (abs (- (car c1) (car c2)))
    ht (abs (- (cadr c1) (cadr c2)))
    rows (getint "\nNumber of rows (---): ")
    cols (getint "\nNumber of columns (|||): ")
    blk (cdr (assoc 2 (entget (car (entsel "\nSelect Block to Minsert: ")))))
  ); setq
  (command
    "_.minsert" blk
    (mapcar '+ ; insertion point
      (list (min (car c1) (car c2)) (min (cadr c1) (cadr c2))); lower left of room
      (list (/ wid cols 2) (/ ht rows 2)); fractions of width/height
    ); mapcar
    "" "" "" ; X, Y, rotation defaults -- edit if needed
    rows cols (/ ht rows) (/ wid cols); numbers and spacings
  ); command
  (princ)
); defun

 

But ideally, it should be more sophisticated.  It could be made to check whether you selected a Polyline rectangle and a Block, and it could use the usual error handling and other controls.  But see whether it does what you want.

Kent Cooper, AIA
Message 29 of 53
Lexusmax
in reply to: Kent1Cooper

Hi Kent1Cooper,

I am grateful for your response.
Now I attach the .lsp file and drawing showed the case.
The attached lisp is to determine effect area by choose 02 corners.
But I need to determine by select 04 edge (using object osnap) as attached
drawing.
Please adjust my lisp file and send back to me.

Thank you very much.

Le Trung
Message 30 of 53
Kent1Cooper
in reply to: Lexusmax

[nothing attached...]

Kent Cooper, AIA
Message 31 of 53
thajmul2501
in reply to: scot-65

bro

 

i can' understand ur lisp,can u make example, then how to  change inch to meter. can u solve this.


@scot-65 wrote:

REVISED, REWORKED, and STABILIZED.

 

Hopefully I have covered everything regarding light placement types for both Commercial and Residential.

The following interface is stabilized, and the help facility is developed, but not finished.

This is a working interface, the executing program is missing... Have a look.

 

RLA04.gif

 

Scot-65

 

 


 

Message 32 of 53
thajmul2501
in reply to: Kent1Cooper

hi kent

 

ur lisp quietly help. when i load ur lisp, poops up function error. can u explain me. what does that mean "miinsert.blk" . i change the lisp location also i can't get exacltly. pls explain.

 

thanks 

 

hussain

Message 33 of 53
Kent1Cooper
in reply to: thajmul2501


@thajmul2501 wrote:

.... 

ur lisp quietly help. when i load ur lisp, poops up function error. can u explain me. what does that mean "miinsert.blk" . i change the lisp location also i can't get exacltly. pls explain.

....


Which code -- from Post 20 or 28?

 

There's no "miinsert.blk" in either code -- is that part of an error message, or did you type it differently from what you meant?

 

Does the "function error" message say anything more than just that?

Kent Cooper, AIA
Message 34 of 53
patrick_35
in reply to: mwhea

Hi

 

I arrived a little late, but I had the same problem and I do this lisp

 

@+

Message 35 of 53
danglar
in reply to: patrick_35

... in some cases you need  to array  "dirty maked" blocks.. I mean you need to combine blocks array with change insertion point of the block and even to rotate it around base point.

I "dirty" combined these subroutines into one (see attached lisp)

and now I need some improvement: When first subroutine ended to work the second one must to use previous selection set and when second one ended the third one will use previous selection set ..

Is it possible to do?

Message 36 of 53
thajmul2501
in reply to: Kent1Cooper

hi kent

 

i appreciate your response thanks kent. i got ur lisp but what is the problem you know? everything i did after i cannot edit (minsert blk)that is have problem for me. how can i get dynamic block with use your lisp. then lisp want to ask row space & column space that's not happened.

 

i attached the lisp try this . i want to add something that lisp. only can give integer number only, i would like to give decimal number but i could not able to do. pls help me, that lisp how will give equal dimension. god willingly u will understand what i said.


@Kent1Cooper wrote:

@thajmul2501 wrote:

.... 

ur lisp quietly help. when i load ur lisp, poops up function error. can u explain me. what does that mean "miinsert.blk" . i change the lisp location also i can't get exacltly. pls explain.

....


Which code -- from Post 20 or 28?

 

There's no "miinsert.blk" in either code -- is that part of an error message, or did you type it differently from what you meant?

 

Does the "function error" message say anything more than just that?


 

thanks 

 

hussain

Message 37 of 53
thajmul2501
in reply to: pbejse


@pbejse wrote:

@mwhea wrote:

The block name is BL4_07 and visitbiity is 18W FLUOR BATTEN 

I am assuming this will be pretty straight forward to change in the future - as our company is on a bit of a quiet period so we are updating al our stuff hence trying to find new ways of doing things and with this we are creating new dynamic blocks so the names may change.  


I see. for now i wont bother with the Dynamic Properties .

 

(defun c:inb (/ def bn pname allowed n ll ur w l pt lst blk)(vl-load-com)
;;;					pBe 14Jan2013					;;;
(defun def (v) (cond
	((getint (strcat "\nEnter number of rows"
  (if v (strcat " <" (itoa v) ">: ") ": ") )))(v)))      
(setq bn "BL4_07")
(if (and  (tblsearch "BLOCK" bn)
          (setq ll (getpoint "\nPick Lower Left Corner"))
					(setq ur (getcorner ll "\nPick Upper Right Corner"))
          (setq row (def row))
					(setq col (def col)))
    (progn
          (setq w (- (car ur)(car ll))
                l (- (cadr ur)(cadr ll)))
          (setq w (/  w (* 2 col)))
          (setq l (/  l (* 2 row)))
          (setq i 0 sel (ssadd)
                lst nil
                pt (list (+ (car ll) w)(+ (cadr ll) l) 0.0))
  (repeat row
      (foreach pts  
      (cons pt (mapcar '(lambda (k)
                     (list (+ (* w (setq i (+ i 2))) (car k))(cadr k) 0.0))
												(repeat (1- col)
														(setq lst (cons pt lst)))))
;;;	This section is prep for Dynamic Block Properties manipulation	;;;
;;					current coding is a dumb-down version										;;;
(ssadd (vlax-vla-object->ename (vlax-invoke
					(vlax-get (vla-get-ActiveLayout
			    (vla-get-activedocument (vlax-get-acad-object))) 'Block)
			     'InsertBlock pts bn 1 1 1 0)) sel))
      (setq lst nil i 0 pt (polar pt (/ pi 2.0) (* l 2))))
;;;		You can activate this area to "grip" the selection		;;;
;;		and change the visibilty after the program ends				;;;
;(sssetfirst nil sel)
          )
    		)
      (princ)
      )

 


hi 

 

this lisp does not work for me. when i load lisp in command line nothing happen so could you help me. how to solve it?

 

best regards 

hussian

Message 38 of 53
thajmul2501
in reply to: Kent1Cooper


@Kent1Cooper wrote:

@Kent1Cooper wrote:
....

Are you aware of the MINSERT command?  It inserts a Block in rectangular-array rows and columns all in one drawing entity.  ....


In pretty simple terms, without lots of controlling and/or limiting and/or checking and/or default features that could be added, assuming a non-Attributed Block, and minimally tested:

 

(defun C:LRR (/ c1 c2 wid ht rows cols blk); = Lights in Rectangular [& orthogonal] Room
  (setq
    c1 (getpoint "\nCorner of room: ")
    c2 (getpoint "\nOpposite corner: ")
    wid (abs (- (car c1) (car c2)))
    ht (abs (- (cadr c1) (cadr c2)))
    rows (getint "\nNumber of rows (---): ")
    cols (getint "\nNumber of columns (|||): ")
    blk (getstring "\nBlock name: ")
  ); setq
  (command
    "_.minsert" blk
    (mapcar '+ ; insertion point
      (list (min (car c1) (car c2)) (min (cadr c1) (cadr c2))); lower left of room

      (list (/ wid cols 2) (/ ht rows 2)); fractions of width/height
    ); mapcar
    "" "" "" ; X, Y, rotation defaults -- edit if needed
    rows cols (/ ht rows) (/ wid cols); numbers and spacings
  ); command
  (princ)
); defun


hi kent 

 

its good but have a problem in minsert command . how to explode minsert array? could you solve me this?

 

Message 39 of 53
Kent1Cooper
in reply to: thajmul2501


@thajmul2501 wrote:

....

 

its good but have a problem in minsert command . how to explode minsert array? could you solve me this?


Search these Forums and other AutoCAD oriented websites.  There are routines out there to Explode an MINSERT.  This site has two -- I haven't downloaded them to test or compare.

Kent Cooper, AIA
Message 40 of 53
thajmul2501
in reply to: thajmul2501


@thajmul2501 wrote:

hi kent

 

i appreciate your response thanks kent. i got ur lisp but what is the problem you know? everything i did after i cannot edit (minsert blk)that is have problem for me. how can i get dynamic block with use your lisp. then lisp want to ask row space & column space that's not happened.

 

i attached the lisp try this . i want to add something that lisp. only can give integer number only, i would like to give decimal number but i could not able to do. pls help me, that lisp how will give equal dimension. god willingly u will understand what i said.


@Kent1Cooper wrote:

@thajmul2501 wrote:

.... 

ur lisp quietly help. when i load ur lisp, poops up function error. can u explain me. what does that mean "miinsert.blk" . i change the lisp location also i can't get exacltly. pls explain.

....


Which code -- from Post 20 or 28?

 

There's no "miinsert.blk" in either code -- is that part of an error message, or did you type it differently from what you meant?

 

Does the "function error" message say anything more than just that?


 

thanks 

 

hussain


hi kent 

.

i think you misunderstanding as i mentioned. check above post i had attached the lisp the  name of (addarray lisp). include also dcl file. that lisp i want to modify . i could not able to do decimal point like (1.50) so i would like to add decimal point. kindly make for me.

 

best regards 

hussain

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost