Author Topic: Window Lisp help.  (Read 2553 times)

0 Members and 1 Guest are viewing this topic.

V-Man

  • Bull Frog
  • Posts: 343
  • I exist therefore I am! Finally Retired!
Window Lisp help.
« on: August 25, 2004, 11:09:36 AM »
I know that this may a little off the beaten path, but I need a little asssitance with my code. I'm trying to write a lisp that will draw in interior windows on any angle or wall thickness. The problem lies in I'm also trying to add a mullion on both ends of the window opening. Thus I need to subtract from 1 end 1-3/4" and add at the other end 1-3/4" and then break out the wall. This make any sense?

Code: [Select]

(defun c:ww1 ()
(setq windowoffset 4.0)
(setq windowwidth 36.0)
(setq pt0 (getpoint "\nSelect offset point: "))
(princ "\nDistance from offset point <")
(princ windowoffset)
(setq windowoffset (getdist ">: "))
(if (not windowoffset) (setq windowoffset 4.0))
(setvar "osmode" 512)
(setvar "orthomode" 1)
(setq pt2 (getpoint pt0
     "\nSelect approximate strike location on same wall: "))
(setq ang2 (angle pt0 pt2)
        pt1  (polar pt0 ang2 windowoffset)
)
(setvar "osmode" 128)
(setq pt3 (getpoint pt1
     "\nSelect opposite face of wall to be opened: "))
     (princ "\nEnter window width <")
     (princ windowwidth)
     (setq windowwidth (getdist ">: "))
     (if (not windowwidth) (setq windowwidth 36.0))
 (setvar "osmode" 0)
 (setq ang1 (angle pt1 pt3)
         ang3 (fix (- ang1 ang2))
         dst1 (distance pt1 pt3)
         dst2 (distance pt1 pt2)
 )
   (setq pt4 (polar pt1 ang2 windowwidth))
   (setq pt5 (polar pt4 ang1 dst1))
; Swap break points to match the wall angle
    (if (minusp (sin (- ang2 (angle pt1 pt3))))
    (setq temp pt1 pt1 pt3 pt3 temp TEMP1 PT4 PT4 PT5 PT5 TEMP1)
    )
(setq 1z_line (ssadd))
(command
       ".break" pt4 pt1
       ".break" pt5 pt3)
(command ".line"  pt1 pt3 "")
(ssadd (entlast) 1z_line)
(command ".line"  pt4 pt5 "")
(ssadd (entlast) 1z_line)
(command ".line"  pt1 pt4 "")
(ssadd (entlast) 1z_line)
(command ".line"  pt3 pt5 "")
(ssadd (entlast) 1z_line)
(SETVAR "OSMODE" 0)
(mid)
)
(defun mid ()
  (setq 1X1 (car PT1))
  (setq 1Y1 (cadr PT1))
  (setq 1Z1 (caddr PT1))
  (setvar "osmode" 128 )
  (setvar "orthomode" 1 )
  (setq 1X2 (car PT3))
  (setq 1Y2 (cadr PT3))
  (setq 1Z2 (caddr PT3))
  (setq 1XMID (/ (+ 1X1 1X2) 2))
  (setq 1YMID (/ (+ 1Y1 1Y2) 2))
  (setq 1ZMID (/ (+ 1Z1 1Z2) 2))
  (setq 1MPT (list 1XMID 1YMID 1ZMID))
  (setq 1X10 (car PT4))
  (setq 1Y10 (cadr PT4))
  (setq 1Z10 (caddr PT4))
  (setvar "osmode" 128 )
  (setvar "orthomode" 1 )
  (setq 1X20 (car PT5))
  (setq 1Y20 (cadr PT5))
  (setq 1Z20 (caddr PT5))
  (setq 1XMID (/ (+ 1X10 1X20) 2))
  (setq 1YMID (/ (+ 1Y10 1Y20) 2))
  (setq 1ZMID (/ (+ 1Z10 1Z20) 2))
  (setq 1MPT1 (list 1XMID 1YMID 1ZMID))
  (setvar "osmode" 0)
  (command ".line" 1MPT 1MPT1 "")
  (ssadd (entlast) 1z_line)
)


AutoCAD 9 - 2023, AutoCADMap 2008 - 2010, Revit 2012 - 2022, Autocad Civil 3D 2023

JohnK

  • Administrator
  • Seagull
  • Posts: 10637
Window Lisp help.
« Reply #1 on: August 25, 2004, 12:39:22 PM »
The function your looking for is called "POLAR"

Here is the section on it from the help files.

I would look up ANGLE as well.

Quote
polar Function

Returns the UCS 3D point at a specified angle and distance from a point

(polar pt ang dist)

Arguments

pt

A 2D or 3D point.

ang

An angle expressed in radians relative to the world X axis. Angles increase in the counterclockwise direction, independent of the current construction plane.

dist

Distance from the specified pt.

Return Values

A 2D or 3D point, depending on the type of point specified by pt.

Examples

Supplying a 3D point to polar:

Command: (polar '(1 1 3.5) 0.785398 1.414214)

(2.0 2.0 3.5)

Supplying a 2D point to polar:

Command: (polar '(1 1) 0.785398 1.414214)

(2.0 2.0)
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

SPDCad

  • Bull Frog
  • Posts: 453
Window Lisp help.
« Reply #2 on: August 25, 2004, 12:42:53 PM »
I just wipped this together quickly, and hopefully it works (not tested).
You should get a rough idea on how to solve your problem though.
 
Code: [Select]
; given - LEN = door width
- OFF = offset distance
- JMB = jamb width
 

(setvar "osmode" 35) ;endpoint, intersection,
(setq Pt0 (getpoint "Reference point: "))
(setvar "osmode" 512) ;nearest point
(setq Pt1 (getpoint Pt0 "Pick a point along the wall: "))
(setvar "osmode" 128) ;perpendicular
(setq Pt3 (getpoint pt1 "Pick opposite wall: ")
      ANG1 (angle PT0 PT1)
      ANG2 (angle PT1 PT3)
      DST (distance PT1 PT3)
      PT1 (polar PT0 ANG1 OFF)
      PT4 (polar PT1 ANG1 LEN)
      PT3 (polar PT1 ANG2 DST)
      PT5 (polar PT3 ANG1 LEN)
      PT7 (polar PT1 (* ANG1 -1) JMB)
      PT6 (polar PT3 (* ANG1 -1) JMB)
      PT8 (polar PT4 ANG1 JMB)
      PT9 (polar PT5 ANG1 JMB)
);


I have a programme I wrote in the past for doors and windows, very similar to what you are asking, but unfortunetly I do not have the source code available, due to I am at work.
When I get home and I remember I will send you the programme. :wink:
AutoCAD 2010, w/ OpenDCL

visit: http://reachme.at/spd_designs