Cadmando- Posted March 20 Posted March 20 (edited) I used Divide command but its slow. So I tried to create a Divide command, pause for selecting arc, Line exc. Insert c-chair4 block and pause for how many blocks inserted. my lisp command not working. I what Dialog box to open ups and insert number of blocks. would be niece is PREVIEW along with Dialog box can anyone help, or dose anyone know a good AI to help create lisp and dcl routings. here my code:DIB.LSP (defun c:DIB (/ ent num-divisions i pt segment-length) ;; Prompt user to select a line or polyline (setq ent (car (entsel "\nSelect a line or polyline to divide: "))) ;; Ensure that the entity is valid (line or polyline) (if (or (= (vla-get-objectname (vlax-ename->vla-object ent)) "AcDbLine") (= (vla-get-objectname (vlax-ename->vla-object ent)) "AcDbPolyline")) (progn ;; Ask user for the number of divisions (setq num-divisions (getint "\nEnter the number of divisions: ")) ;; Calculate the segment length for each division (setq segment-length (/ (vlax-curve-getLength ent) num-divisions)) ;; Insert the block at each division point (setq i 0) ;; Start the division count (repeat num-divisions ;; Calculate the point at the current division (setq pt (vlax-curve-getPointAtDist ent (* i segment-length))) ;; Insert the block at the division point (command "INSERT" "C-CHAIR4" pt "1" "1" "0") ;; Move to the next division (setq i (1+ i)) ) ) (princ "\nInvalid entity selected. Please select a line or polyline.") ) (princ) ) Edited March 20 by SLW210 Adde Code Tags!! Quote
SLW210 Posted March 20 Posted March 20 Please use Code Tags for your code. (<> in the editor toolbar) Quote
BIGAL Posted March 20 Posted March 20 Not sure divide is the way to go as your placing chairs on an arc that changes radius as you go rather you need some maths to check does a chair box touch another box ? If so the spacing along arc needs to be increased. You can use a VL Getpointatdist function to work out spacing. May need to draw rectangs 2 off then check do they touch if yes do again and increase spacing, if the chair arms cross when installing some one will not be happy. Quote
Steven P Posted March 21 Posted March 21 Just wondering how many churches you lay out like this. If it is just the one I would be tempted to fill the rows with a basic polar array, probably quicker than writing and testing a LISP. If you are doing this multiple times then LISP makes sense though 1 Quote
rlx Posted March 21 Posted March 21 you may also consider using a simple block first , just a rectangle , that way routine might run faster. After you're done , replace simple blocks with actual 3D chairs. 1 Quote
Cadmando- Posted March 23 Author Posted March 23 I have tried the array command, but i am just learning Lisp. It one point I tried using AI program to help right the lisp routine. Just trying to get the most chairs in the Sanctuary as possible. I have drawing the lower Sanctuary few times and just thought someone could help me with writing code. After 4 temps to get max chairs, ya wrist is getting tiered. tried script file, but to pause for select arc and number of segments! Quote
BIGAL Posted March 23 Posted March 23 In terms of a lisp you would insert 2 blocks and check do they touch if so widen spacing if not narrow spacing then insert multiple blocks. Quote
CyberAngel Posted March 25 Posted March 25 Is there a geometric solution? Draw a triangle with the (very) short leg representing the width of the chair. By varying the length of the long legs, you can draw an arc to fit the layout line. Divide the length of that arc into the space available, round it down, and you have the number of chairs that will fit. From there it's a simple polar array insert. Repeat as necessary. Quote
rlx Posted Tuesday at 11:04 PM Posted Tuesday at 11:04 PM Just something to play with , almost no error checking , no dcl etc. Could of course be dialog driven and some parts can be automated but , well , churches & dragons... not the best of combinations probably. ;;; https://www.cadtutor.net/forum/topic/96982-trying-to-layout-church-seating-using-divide-and-insert-block/ ;;; RLX - apr'25 ;;; place block 'blk' along a line ;;; blocks will be evenly spaced along line (= Fit) (defun c:t1 ( / bn blk-dx blk-dy chair-density sel ent line-len p1 p2 p3 max-blk ctr-dist) ;;; change name as needed (setq bn "blk") ;;; I used a simple rectangle block 30x30 just for example (setq blk-dx 30 blk-dy 30) ;;; also just to play with : 'chair-density' , lets say 0.5-1.0 (50-100%) (setq chair-density 0.5) (cond ((not (setq sel (entsel "Select a line : "))) (alert "Nothing selected")) ((not (eq (cdr (assoc 0 (setq dat (entget (setq ent (car sel)))))) "LINE")) (alert (strcat "Sorry but this is not a line (" (vl-princ-to-string (cdr (assoc 0 dat))) ")"))) (t ;;; (angle (getpoint "\np1 :") (getpoint "\np2 :")) (setq p1 (cdr (assoc 10 dat)) p2 (cdr (assoc 11 dat))) (if (not (equal (angle p1 p2) 0 0.1)) (setq p1 p2 p2 (cdr (assoc 10 dat)))) ;;; length line (setq line-len (distance p1 p2)) ;;; max number of block on line (setq max-blk (fix (/ line-len blk-dx))) ;;; create more or less space between chairs (0.5 = 50% of line length will be used for chairs) (setq max-blk (fix (* max-blk chair-density))) ;;; center (fit) blocks on line by distribute leftover space between chairs (setq ctr-dist (/ (- line-len (* max-blk blk-dx)) (1- max-blk))) ;;; block (setq blk-ip (polar p1 0 (/ blk-dx 2.0))) (repeat max-blk (vl-cmdf "-insert" bn blk-ip 1 1 0) (setq blk-ip (polar blk-ip 0 (+ blk-dx ctr-dist))) ) ) ) ) ;;; same but now for arc (defun c:t2 ( / bn blk-dx blk-dy sel ent arc-len spt ept ang max-blk ctr-dist ipt dst par slp ang ) (setq bn "blk" blk-dx 30 blk-dy 30) (cond ((not (setq sel (entsel "Select an arc : "))) (alert "Nothing selected")) ((not (eq (cdr (assoc 0 (setq dat (entget (setq ent (car sel)))))) "ARC")) (alert (strcat "Sorry but this is not an arc (" (vl-princ-to-string (cdr (assoc 0 dat))) ")"))) (t (setq obj (vlax-ename->vla-object ent)) (setq spt (vlax-curve-getStartPoint obj) ept (vlax-curve-getEndPoint obj)) (if (not (equal (angle spt ept) 0 0.1)) (setq stp ept ept (vlax-curve-getStartPoint ent))) (setq arc-len (vlax-curve-getdistatparam ent (vlax-curve-getendparam ent))) (setq mpt (vlax-curve-getPointAtDist obj (* 0.5 arc-len))) (if (vlax-property-available-p obj 'center) (setq ctr (vlax-safearray->list (vlax-variant-value (vla-get-Center obj))))) ;;; max number of block on line (setq max-blk (fix (/ arc-len blk-dx))) ;;; create more space between symbols by occupying 50% of available length ;;; change 0.5 for example to 0.75 will increase chair density (1 is max) (setq max-blk (fix (* max-blk 0.5))) ;;; center blocks on line by distribute leftover space between symbols (setq ctr-dist (/ (- arc-len (* max-blk blk-dx)) (1- max-blk))) (setq dst (/ blk-dx 2.0)) (repeat max-blk (setq ipt (vlax-curve-getPointAtDist obj dst) par (vlax-curve-getParamAtPoint obj ipt) slp (vlax-curve-getFirstDeriv obj par) ang (atan (/ (cadr slp)(car slp)))) (entmake (list '(0 . "INSERT") (cons 2 bn) (cons 10 ipt) (cons 50 ang))) ;(setq dst (+ blk-dx ctr-dist)) (setq dst (+ dst blk-dx ctr-dist)) ) ) ) ) chair-test.dwgFetching info... Quote
SLW210 Posted Wednesday at 10:47 AM Posted Wednesday at 10:47 AM Are they on a flat floor or is it a sloped floor? Are the circles in the image columns? If so, those seats need removed. You also have to consider how good is the view, seats may need to be staggered. Do you know the needed aisle width and the available legal occupancy capacity of the room? There are some YouTube Videos for Blender etc. and Blender Forums, some sights should show the math behind it. A drawing might help. 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.