box_animation.mp4
box_animation.mp4
I thought I would have some more fun with this problem. As I posted earlier, I think AutoCAD's parametric features offer a good solution. Here's an easier construct. Open the attached file and go to the Parametric tab and click Show All or enter the command DCDISPLAY and select the box to see the dimensional constraints. Change the value of dimension d3 to see the box in a different position agaist the wall.
The following VLISP program creates a box of user specified dimensions and animates it position and orientation as it slides along the floow and wall. 0,0 is assumed to be the lower corner of the wall.
box_animation.mp4
;Creates an animation of a rectangle slding along a floor
; as it rotates leaning agains a wall.
; 11/13/2026
(defun c:boxanimate
(/ ang boxL boxW dAngle dAngleR p i d vlaObj nSteps dx)
(vl-load-com)
(setq boxL (getreal "\nEnter box length (9): "))
(if (not boxL)
(setq boxL 9)
)
(setq boxw (getreal "\nEnter box width (2) "))
(if (not boxW)
(setq boxW 2)
)
(setq dAngle 1 ; rotation angle increment
ang dAngle ; total rotation
dAngleR (/ (* pi dAngle) 180.)
p (list (- boxL) 0) ; poit of rotation
i 0
d 100 ; delay value
)
(command "_rectangle" "_non" p "_non" (list 0 boxW))
(setq vlaObj (vlax-ename->vla-object (entlast)))
(setq nSteps (/ 90 dAngle))
(setvar "CMDECHO" 0)
(while (< i nsteps)
(setq angR (/ (* pi ang) 180.))
(setq dx (abs (+ (car p) (* boxL (cos angR)))))
(vla-Rotate vlaObj (vlax-3d-point p) dAngleR)
(vla-Move vlaObj
(vlax-3d-point '(0.0 0.0 0.0))
(vlax-3d-point (list dx 0.0 0.0))
)
(setq ang (+ ang dAngle)
p (mapcar '+ p (list dx 0))
)
(vla-update (vlax-get-acad-object))
(command-s "_.REGEN")
(command "_.DELAY" 100)
(setq i (1+ i))
)
(setvar "CMDECHO" 1)
(princ)
) ; end defun
box fit.02.dwg