Page 1 of 2 12 LastLast
Results 1 to 10 of 16

Thread: How to make a routine to create rectangle?

  1. #1
    100 Club
    Join Date
    2005-12
    Location
    Columbus, OH
    Posts
    158
    Login to Give a bone
    0

    Default How to make a routine to create rectangle?

    I'm working on a LISP routine that will drawing a simple rectangle base on two points and a width. My problem is that it only seems to work in a horizontal direction and I'm not sure how I would fix it go in any direction I'd like. Any help would be great, thanks.
    Matt

    I attached what I have so far.

  2. #2
    Administrator Opie's Avatar
    Join Date
    2002-01
    Location
    jUSt Here (a lot)
    Posts
    9,100
    Login to Give a bone
    0

    Default Re: How to make a routine to create rectangle?

    I would change how you are creating your sets of coordinates. Instead of making lists with the x of one coordinate and the y of another coordinate, I would continue your polar function to calculate the coordinates. You already know the distances and angles you want. Moving away from the lists would simplify your code a bit as well.

    Do you have an example image of what you are trying to accomplish?
    If you have a technical question, please find the appropriate forum and ask it there.
    You will get a quicker response from your fellow AUGI members than if you sent it to me via a PM or email.
    jUSt

  3. #3
    100 Club
    Join Date
    2005-12
    Location
    Columbus, OH
    Posts
    158
    Login to Give a bone
    0

    Default Re: How to make a routine to create rectangle?

    Here is a picture of what I'm looking to do.

  4. #4
    Administrator Opie's Avatar
    Join Date
    2002-01
    Location
    jUSt Here (a lot)
    Posts
    9,100
    Login to Give a bone
    0

    Default Re: How to make a routine to create rectangle?

    Quote Originally Posted by mhannan.100562
    Here is a picture of what I'm looking to do.
    The "green" rectangle is to be centered on the wall? Bare with me as I don't work in that field.
    If you have a technical question, please find the appropriate forum and ask it there.
    You will get a quicker response from your fellow AUGI members than if you sent it to me via a PM or email.
    jUSt

  5. #5
    100 Club
    Join Date
    2005-12
    Location
    Columbus, OH
    Posts
    158
    Login to Give a bone
    0

    Default Re: How to make a routine to create rectangle?

    Yes the green line is to be centered.
    I changed everything to polar, but still can't get it to work vertically.

  6. #6
    Administrator rkmcswain's Avatar
    Join Date
    2004-09
    Location
    Earth
    Posts
    9,804
    Login to Give a bone
    0

    Default Re: How to make a routine to create rectangle?

    I take it you are not on 2006 or later, because this is built into the RECTANG command now.

    If not give this a try:

    Code:
    (defun c:thicken-slab ( / ANG1 PNT0 PNT1 PNT2 PNT3 R0 R180 R270 R90 SIZE X)
      (setq r0   0.0
            r90  (* pi 0.5)
            r180 pi
            r270 (* pi 1.5)
            size (getdist "\nWidth of footing: ")
            pnt0 (getpoint "\nSlect start point of footing: ")
            pnt1 (getpoint pnt0 "\nSlect end point of footing: ")
            ang1 (angle pnt0 pnt1)
            x    (/ size 2)
            pnt2 (polar pnt1 (+ ang1 r90) x)
            pnt3 (polar pnt0 (+ ang1 r90) x)
      )
      (command "-layer" "m" "S-Foun-Footing" "c" "3" "S-Foun-Footing" "l" "hidden"
               "S-Foun-Footing" ""
              )
      (command "pline" pnt0 pnt1 pnt2 pnt3 "_C")
    )
    R.K. McSwain | CAD Panacea |

  7. #7
    100 Club
    Join Date
    2005-12
    Location
    Columbus, OH
    Posts
    158
    Login to Give a bone
    0

    Default Re: How to make a routine to create rectangle?

    No weren't yet on 2006. 2005 for now.
    I only got half of the footing.

  8. #8
    Administrator Opie's Avatar
    Join Date
    2002-01
    Location
    jUSt Here (a lot)
    Posts
    9,100
    Login to Give a bone
    0

    Default Re: How to make a routine to create rectangle?

    Quote Originally Posted by mhannan.100562
    Yes the green line is to be centered.
    I changed everything to polar, but still can't get it to work vertically.
    I agree with R.K. The rotation of the RECTANGLE command can now be specified within that command.

    You may try this code.
    Code:
    (defun c:thicken-slab ( / DTR cornerdist CMDE FOOTING_ANGLE OSMD PNT0 PNT1 PNT2 PNT3 PNT4 PNT5 SIZE)
      (setq cmde (getvar "CMDECHO"))
      (setq osmd (getvar "OSMODE"))
      (setvar "CMDECHO" 0)
      (defun DTR (A) (* pi (/ A 180.0)))
      (setq	size (getdist "\nWidth of footing: ")
    	pnt0 (getpoint "\nSlect start point of footing: ")
    	pnt1 (progn (initget 32) (getpoint pnt0 "\nSlect end point of footing: "))
    	footing_angle (angle pnt0 pnt1)
    	cornerdist (sqrt (+ (expt (* size 0.5) 2.0)(expt (* size 0.5) 2.0)))
    	pnt2 (polar pnt1 (- footing_angle (dtr 45.0)) cornerdist)
    	pnt3 (polar pnt1 (+ footing_angle (dtr 45.0)) cornerdist)
    	pnt4 (polar pnt0 (+ footing_angle (dtr 135.0)) cornerdist)
    	pnt5 (polar pnt0 (- footing_angle (dtr 135.0)) cornerdist)
      )
      (command "-layer" "m" "S-Foun-Footing" "c" "3" "S-Foun-Footing" "l" "hidden" "S-Foun-Footing" "")
      (if (and (> osmd 0) (< osmd 16384))
        (setvar "OSMODE" (+ osmd 16384))
      )
      (command "pline" pnt2 pnt3 pnt4 pnt5 "c")
      (setvar "OSMODE" osmd)
      (setvar "CMDECHO" cmde)
    )
    Last edited by Opie; 2006-09-06 at 07:27 PM. Reason: Revised code
    If you have a technical question, please find the appropriate forum and ask it there.
    You will get a quicker response from your fellow AUGI members than if you sent it to me via a PM or email.
    jUSt

  9. #9
    100 Club
    Join Date
    2005-12
    Location
    Columbus, OH
    Posts
    158
    Login to Give a bone
    0

    Default Re: How to make a routine to create rectangle?

    I'm only getting half of the width size. If I use 1'-4" for size it draws it as 8".

    I need it to be 1'-4" wide and extend past each end half the width.

  10. #10
    Administrator Opie's Avatar
    Join Date
    2002-01
    Location
    jUSt Here (a lot)
    Posts
    9,100
    Login to Give a bone
    0

    Default Re: How to make a routine to create rectangle?

    Quote Originally Posted by mhannan.100562
    I'm only getting half of the width size. If I use 1'-4" for size it draws it as 8".

    I need it to be 1'-4" wide and extend past each end half the width.
    Where is the 1'-4" measured from? The center? Total width?
    If you have a technical question, please find the appropriate forum and ask it there.
    You will get a quicker response from your fellow AUGI members than if you sent it to me via a PM or email.
    jUSt

Page 1 of 2 12 LastLast

Similar Threads

  1. DCL Dialog Box Create routine
    By peter in forum AutoLISP
    Replies: 7
    Last Post: 2019-10-28, 07:16 PM
  2. Create rectangle then move at center point
    By CISCO in forum AutoLISP
    Replies: 12
    Last Post: 2010-11-14, 04:33 PM
  3. Replies: 3
    Last Post: 2009-04-15, 07:30 PM
  4. Create an X (2 lines) inside a rectangle
    By CISCO in forum AutoLISP
    Replies: 4
    Last Post: 2008-08-12, 06:00 PM
  5. create an excel of block attributes from within a specified rectangle
    By christopher.r.schroll in forum VBA/COM Interop
    Replies: 1
    Last Post: 2008-05-20, 02:33 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •