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
CODES removed
I think i may have mis-understood the "spacing issue" can you post an example dwg or an image so i may understand it better?
EDIT: I asked a HVAC designer co-worker about spacing and here's the code based on his explanation of
"1/2 1 1 1/2"
(defun c:inb (/ def bn ll ur w l pt lst) ;;; pBe 14Jan2013 ;;; (defun def (v) (cond ((getint (strcat "\nEnter number of rows" (if v (strcat " <" (itoa v) ">: ") ": ") )))(v))) (setq bn "YourBlockName") (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 lst nil pt (list (+ (car ll) w)(+ (cadr ll) l))) (repeat row (foreach pts (cons pt (mapcar '(lambda (k) (list (+ (* w (setq i (+ i 2))) (car k))(cadr k))) (repeat (1- col) (setq lst (cons pt lst))))) (command "_.insert" bn "_non" pts "" "" "")) (setq lst nil i 0 pt (polar pt (/ pi 2.0) (* l 2)) ) ) ) ) (princ) )
Command: inb
Pick Lower Left Corner
Pick Upper Right Corner
Enter number of rows: 3
Enter number of rows: 4
HTH
Hey,
Thanks heaps for your help so far, I have attached a drawing showing steps of how we go about breaking a room up to insert our lights. I hope this makes sense - I am currently at home and don't have my CAD setup so I have done the best I could.
Thanks again
@Anonymous wrote:Hey,
Thanks heaps for your help so far, I have attached a drawing showing steps of how we go about breaking a room up to insert our lights. I hope this makes sense - I am currently at home and don't have my CAD setup so I have done the best I could.
Thanks again
I see, the revised code will work then as regards to the spacing issue. but what about the attributes? do you need to label those? and are you going to use this exclusively on one particualr block name?
If possible it would be nice for the routine to obviously ask some questions to the user like:
How many Columns of Lights
How many Rows of Lights
What Block to Insert (this can be skipped as we have created a dynamic block for all lights needed)
What Attribute Name (as with most cases with standard lighting in a room you keep to one light type)
If this is possible it would greaty enhance productivity i'll give the lisp routine a try at work tomorrow (aussie here) and i'll let you know how it goes.
thanks for your help mate 🙂
@Anonymous wrote:If possible it would be nice for the routine to obviously ask some questions to the user like:
How many Columns of Lights
How many Rows of Lights
What Block to Insert (this can be skipped as we have created a dynamic block for all lights needed)
What Attribute Name (as with most cases with standard lighting in a room you keep to one light type)
If this is possible it would greaty enhance productivity i'll give the lisp routine a try at work tomorrow (aussie here) and i'll let you know how it goes.
thanks for your help mate 🙂
A Dynamic block then? I guess the attribute issue is only for your sample drawing , shoot me the name of the DBlock.. better yet give me the visiblity parameter name as well.
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.
@Anonymous 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) )
You sir are a genius 🙂
Just had a quick test of it and works amazing 😄
Is there away to ask for the type of fitting it is being inserted (example drawing had type F1 fitting) As the blocks have ID 1 and ID2 for descriptions of the light. If this is not possible its not hard to select all the new drawings and just go to properties and add "F1" or whatever the light is to be called.
Thanks again 🙂
@Anonymous wrote:You sir are a genius 🙂
Just had a quick test of it and works amazing 😄
Is there away to ask for the type of fitting it is being inserted (example drawing had type F1 fitting) As the blocks have ID 1 and ID2 for descriptions of the light. If this is not possible its not hard to select all the new drawings and just go to properties and add "F1" or whatever the light is to be called.
Thanks again 🙂
Glad it works for you.
Yes its possible ,that is why i put a note in the code "prep for Dynamic Block Manipulation" .... or by "descriptions" you mean visibiltiy parameter? Yes it can be arranged to worked on any Dblocks
Looks good!
I would have used ARRAY after finding the first insertion point...
🙂
Scot-65
A gift of extraordinary Common Sense does not require an Acronym Suffix to be added to my given name.
@scot-65 wrote:Looks good!
I would have used ARRAY after finding the first insertion point...
🙂
True, But what i had in mind are the eventual options that will go with this routine in the future:
(setq opt (getkword "\nChoose option [Regular/Numbered/Block List] <N>:))
wherein options are
R = use ARRAY as you suggested
N = use Copy
: LTR/TTB/BTT/ :<------ number order
B = use INSERT
:Properties/Visiblity/Name list
:N option shows a listbox and an option to select two or more blocks
I opted to use insert for this example as i was counting on labelling the blocks, as it is easier to "capture" or modify the object on the fly after insertion.
but like i said. in the future.
Good call scot-65
Cheers
One of the greatest things about this board is one can
be inspired to create macros that can benefit the work
environment, and therefore become more productive.
With that said, I have created a preliminary interface that will be
taken to completion very shortly, as I can use something like this:
The routine will start by asking the user to select 2 corners of the area (getcorner).
When successful, this dialog will appear.
If you want the beginnings, I'd be happy to attach the DCL and LSP.
They are in an easy to read format and with some tweaking, can
be tailored to your liking (or used as a template).
🙂
Scot-65
A gift of extraordinary Common Sense does not require an Acronym Suffix to be added to my given name.
scot-65,
I'll be happy to look at the beggings of this 🙂 anything that simplifies work is for the better.
pbejse lisp routine works really well for what we are after atm, though there are somethings i have thought about wanting to add into it later on llike ceiling tiles for instances where we cant just space our lights evenly but based on an actual grid tile setout point.
@Anonymous wrote:scot-65,
I'll be happy to look at the beggings of this 🙂 anything that simplifies work is for the better.
@pbejse lisp routine works really well for what we are after atm, though there are somethings i have thought about wanting to add into it later on llike ceiling tiles for instances where we cant just space our lights evenly but based on an actual grid tile setout point.
post an example. mwhea
@Anonymous wrote:.... I have attached a drawing showing steps of how we go about breaking a room up to insert our lights. ....
Are you aware of the MINSERT command? It inserts a Block in rectangular-array rows and columns all in one drawing entity. It's a significant memory saver compared to all those Blocks separately inserted, and has other advantages. If you need to do anything to the Blocks, such as change the Layer, Move, Erase, etc., they are collectively one thing, so one pick gets them all, one grab of grip to Move them takes them all together, etc. [In some ways that's similar to having them in a Group, but with Minsert they're actually a single entity.] If you want to round off the spacing to ceiling tile increments, you just set one row and one column spacing, and they are all regularly spaced. And if you decide to change the spacing, changing that in one place alters all the positions at once. They can't accidentally get moved out of alignment with each other. And so on....
In your example drawing, it would simply be a matter of calculating one insertion point [in that case, an eighth of the way across the room from one side or the other, and a sixth of the way up or down], and making one Minsert with the desired numbers of rows and columns, and appropriate spacings -- no need to calculate all those insertion points separately.
However, there may be reasons not to use it. If the Block has Attributes, they would need to be the same in every one in the Minsert array, which may be fine if it's just a fixture type designation, but may not be if they need to be differentiated in some way. And I'm not sure what effects there may be on Dynamic Blocks. Or if there's reason to have any not on the regular-interval spacing, or perhaps not at the same rotation, they would need to be independent of any Minsert that contains most of them.
Kent1Cooper wrote:
mwhea wrote:
.... I have attached a drawing showing steps of how we go about breaking a room up to insert our lights. ....
Are you aware of the MINSERT command?...
If you want to round off the spacing to ceiling tile increments, you just set one row and one column spacing, and they are all regularly spaced. And if you decide to change the spacing, changing that in one place alters all the positions at once. They can't accidentally get moved out of alignment with each other. And so on....
MINSERT,now thats interesting. Had not use that command in ages. Come to think of it, i think i never did. 🙂
......-- no need to calculate all those insertion points separately.
Yes, that too.
I thought about scot's suggestion regarding ARRAY. I realize making a selection set isnt really that hard.
My mind was set in using insert for every condition i had in my "option" list. But after reading thru the other posts made me think twice.
The insert command is still play a vital role of course, mix with copy, array and even minsert will make it loads easier to code.
Thank for your input [Scot-65 / Kent Cooper]
Cheers
@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
Can't find what you're looking for? Ask the community or share your knowledge.