Author Topic: Pane revisited  (Read 3158 times)

0 Members and 1 Guest are viewing this topic.

ELOQUINTET

  • Guest
Pane revisited
« on: October 13, 2004, 03:31:17 PM »
i got this lisp i think from someone here which originally divided an area into equal panes with a gap of 1/8" between them. i was able to modify it to create a 1/4" one as well. now i am trying to create a 1-1/2" one here's what i have but it's not working. Also just out of curiousity how would i modify this to not put a gap on both ends?

Code: [Select]
;;; DIVIDE INTO EQUAL PANES WITH 1-1/2" JOINTS AT ENDS AND BETWEEN

(defun C:Pane1 1/2 (/ p1 p2 x1 x2 y1 y2 Pa Pb wWidth PaneHt PLL
          paneCnt PaneWidth paneWidth PanePt Up left
          Gap usercmd useros)

  (setq usercmd (getvar "CMDECHO"))
  (setvar "CMDECHO" 0)
  (setq useros (getvar "osmode"))
  (setvar "osmode" 175)

  (Setq   Up   (* pi 0.5)
   left pi
  )
  (setq   p1     (getpoint "\nPick glass frame corner")
   p2     (getpoint p1 "\nPick diaganal glass corner")
   x1     (car p1)
   x2     (car p2)
   y1     (cadr p1)
   y2     (cadr p2)
   Pa     (list x1 y2)
   Pb     (list x2 y1)
   wWidth (distance p1 pb) ; window width
   PaneHt (distance p1 pa) ; window Hight
   PLL    (list (if (< x1 x2)x1 x2) ; PLL point Lower Left corner
       (if (< y1 y2) y1 y2)
      )
  )

  (initget 7)
  (setq paneCnt (getint "\nEnter number of panes.  "))
  (initget 7)
  (setq Gap 1.500) ; preset at 1 1/2 inch
  (setq   paneWidth (/ (- wWidth (* (1+ paneCnt) Gap)) paneCnt)
   PanePt     (polar PLL 0 gap)
  )
 
  (setvar "osmode" 0)
  (command "undo" "begin")
  ;; draw the Glass Panes
  (repeat  paneCnt
    (command "_rectang" PanePt (strcat "@" (rtos PaneWidth 2) "," (rtos PaneHt 2)))
    (setq PanePt (polar PanePt 0 (+ PaneWidth Gap)))
  ) ; end repeat
;;;==========  Exit Sequence  ============
  (command "undo" "end")
  (setvar "osmode" useros)
  (setvar "CMDECHO" usercmd)
;;; Exit quietly
  (princ)
) ; end defun
(princ)

whdjr

  • Guest
Pane revisited
« Reply #1 on: October 13, 2004, 04:53:50 PM »
I couldn't help myself, but I rewrote the code.  There is not much error checking, but it should work.  I added a prompt for the gap width so that it would be more universal.
I hope this is what your after.
Code: [Select]
(defun c:panel (/ cmd osm pt1 pt2 pt3 pt4 wid hgt pns gap pwid ppt)
  (setq cmd (getvar "CMDECHO")
osm (getvar "OSMODE")
  )
  (mapcar 'setvar '("CMDECHO" "OSMODE") '(0 175))
  (and (setq pt1 (getpoint "\nPick bottom left corner of glass frame:  "))
       (setq pt2 (getpoint pt1 "\nPick top right corner of glass frame:  "))
       (setq pt3 (list (car pt1) (cadr pt2) 0.0))
       (setq pt4 (list (car pt2) (cadr pt1) 0.0))
       (setq wid (distance pt1 pt4))
       (setq hgt (distance pt1 pt3))
  )
  (initget (+ 1 2 4))
  (setq pns (getint "\nEnter number of panes:  "))
  (initget (+ 1 2 4))
  (setq gap  (getreal "\nEnter gap distance in decimal inches:  ")
pwid (/ (- wid (* (1+ pns) gap)) pns)
ppt  (polar pt1 0 gap)
  )
  (setvar "OSMODE" 0)
  (command "undo" "begin")
  (repeat pns
    (command "_rectang"
    ppt
    (strcat "@" (rtos pwid 2 2) "," (rtos hgt 2 2))
    )
    (setq ppt (polar ppt 0 (+ pwid gap)))
  )
  (command "undo" "end")
  (mapcar 'setvar '("CMDECHO" "OSMODE") (list cmd osm))
  (princ)
)

daron

  • Guest
Pane revisited
« Reply #2 on: October 14, 2004, 08:16:30 AM »
Dan, my very first suggestion would to be, do not DEfine a FUNction (DEFUN) with spaces.  c:pane1-1/2 might do better. I'd try and avoid operators as well. Maybe, pane112 or something like that.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Pane revisited
« Reply #3 on: October 14, 2004, 08:27:18 AM »
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

daron

  • Guest
Pane revisited
« Reply #4 on: October 14, 2004, 08:33:17 AM »
Code: [Select]
(setq Gap 1.500) ; preset at 1 1/2 inch

Dan, you might try setting this to accept user input instead of being predetermined. Look into initget and that should give you some idea of what getxxx functions you can use to set a call to the user. This way you don't have to have 100 different routines for 100 different gaptypes. P.S. Are you taking Mark's recent challenge? I hope you are. It would be a good start for you.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Pane revisited
« Reply #5 on: October 14, 2004, 09:08:57 AM »
Thanks Will for the update.
Try this dan.
Code: [Select]
(defun panel (gap / cmd osm pt1 pt2 pt3 pt4 wid hgt pns pwid ppt)
  (setq cmd (getvar "CMDECHO")
        osm (getvar "OSMODE")
  )
  (mapcar 'setvar '("CMDECHO" "OSMODE") '(0 175))
  (and (setq pt1 (getpoint "\nPick bottom left corner of glass frame:  "))
       (setq pt2 (getpoint pt1 "\nPick top right corner of glass frame:  "))
       (setq pt3 (list (car pt1) (cadr pt2) 0.0))
       (setq pt4 (list (car pt2) (cadr pt1) 0.0))
       (setq wid (distance pt1 pt4))
       (setq hgt (distance pt1 pt3))
  )
  (initget (+ 1 2 4))
  (setq pns (getint "\nEnter number of panes:  "))
  (initget (+ 1 2 4))
  (if (or (null gap);  need gap, else got gap
          (not(member (type gap) '(INT REAL))))
    (setq gap  (getreal "\nEnter gap distance in decimal inches:  "))
    (setq gap (abs (float gap))); positive real number
  )
  (setq pwid (/ (- wid (* (1+ pns) gap)) pns)
        ppt  (polar pt1 0 gap)
  )
  (setvar "OSMODE" 0)
  (command "undo" "begin")
  (repeat pns
    (command "_rectang"
             ppt
             (strcat "@" (rtos pwid 2 2) "," (rtos hgt 2 2))
    )
    (setq ppt (polar ppt 0 (+ pwid gap)))
  )
  (command "undo" "end")
  (mapcar 'setvar '("CMDECHO" "OSMODE") (list cmd osm))
  (princ)
)

(defun c:pane18()
  (panel 0.125); pre set gap
  (princ)
)
(defun c:pane115()
  (panel 1.5)
  (princ)
)
(defun c:pane?(); user enters the gap
  (panel nil)
  (princ)
)
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

ELOQUINTET

  • Guest
Pane revisited
« Reply #6 on: October 14, 2004, 09:58:12 AM »
cool wow i was looking at the old thread trying to figure out what i'd need to modify to have it not put the gaps at the ends but the code has changed so much in my eyes i can't compare the two. i would actually like both because sometime i need the gaps sometimes not. thanks guys and don't worry i'm not just sitting here on my arse i'm studying the codes you guys give me  :wink:

ELOQUINTET

  • Guest
Pane revisited
« Reply #7 on: October 14, 2004, 10:04:33 AM »
i'm getting error :no function definiton:panel cab tried typing in pane pane18 pane? same thing for all