Search the Community
Showing results for tags 'create panel lisp'.
-
Hi All, I was trying to write a lisp program to create Panels in a given rectangular area. Program would ask user to provide the Width and Height of the rectangular area. Then it asks for Panel Width and Panel Height. Then it will prompt for the bottom left corner of the rectangular area. Done... But something is holding me back. The loop doesn't end and it keeps creating the first column only. What could be wrong? Here is the code (defun c:pn () (setq Width (getdist "\nWidth of area to be filled : "));Getting the total Width of the area to fill (setq Height (getdist "\nHeight of area to be filled : "));Getting the total Height of the area to fill (setq PanelWidth (getdist "\nWidth of the panel : "));Getting Width of the panel (setq PanelHeight (getdist "\nHeight of the panel : "));Getting Height of the panel (setq XNumberOfPanels (fix (/ Width PanelWidth)));Calculating Number of panels in X Direction (setq YNumberOfPanels (fix (/ Height PanelHeight)));Calculating Number of panels in Y Direction (setq Gap (/(- Width (* XNumberOfPanels PanelWidth)) (+ XNumberOfPanels 1)));Calculating Gap between the panels (setq Pnt (getpoint "\nPick the Bottom Left Corner of the area to be filled : "));Getting the insertion Point (setq YPnt Pnt) (setq x 0);Counter for X Direction (setq y 0);Counter for Y Direction (setq COSMode (getvar 'OSMODE));Storing the value of Current OSMode (setvar 'OSMODE 0);Switching Off all Object snaps (setq Pnt (List (+ (car Pnt) Gap) (+ (cadr Pnt) Gap)));Computing the starting point of the first Rectangle, which is away by one Gap distance along X and one Gap distance along Y (while (<= x XNumberOfPanels) (while (<= y YNumberOfPanels) (setq Pnt1 (list (car Pnt) (+ (cadr pnt) Gap))) (setq Pnt2 (Polar Pnt1 (rad 90) PanelHeight)) (setq Pnt3 (Polar Pnt2 (rad 0) PanelWidth)) (setq Pnt4 (Polar Pnt3 (rad 270) PanelHeight)) (command "PLine" Pnt1 Pnt2 Pnt3 Pnt4 "Close") (setq Pnt Pnt2) ;(alert (strcat "x is " (itoa x))) (setq x (+ x 1)) );Ending While Loop for Y Direction (setq Pnt (list (+ (car YPnt) Gap (* PanelWidth y)) (+ (cadr YPnt) Gap))) (set y (+ y 1)) );Ending While Loop for X Direction (setvar 'OSMODE COSMode);Setting OSMode back to initial value (princ);Silent ending ) ;Function to convert Degrees to Radians (defun rad (Ang) (* 0.01745329 Ang) )