+ Reply to Thread
Results 1 to 8 of 8
  1. #1
    Forum Newbie
    Using
    Civil 3D 2013
    Join Date
    Jun 2013
    Posts
    2

    Default Wierdness with rectangle command

    Registered forum members do not see this ad.

    I have the following code to draw a fixed-width rectangle with the length of a given line:
    Code:
    (command "RECTANGLE" (list (car start)                          (- (cadr start) 0.33))
    	             (list (+ (car start) (distance start end)) (+ (cadr start) 0.33)))
    For some reason, though, the rectangles are starting at the line's start point rather than 0.33 units lower. My X and Y values are in the millions, in case that helps identify it as an overflow error.

  2. #2
    Luminous Being Tharwat's Avatar
    Discipline
    Mechanical
    Tharwat's Discipline Details
    Occupation
    MEP AutoCAD Draughtsman
    Discipline
    Mechanical
    Details
    HVAC, Drainage, Water Supply, Fire Fighting and a little about Electricity.
    Using
    AutoCAD 2015
    Join Date
    Oct 2009
    Location
    Great Syria , Living in Abu Dhabi
    Posts
    6,085

    Default

    So what is the problem with that ?

  3. #3
    Super Member fixo's Avatar
    Computer Details
    fixo's Computer Details
    Operating System:
    Windows 7
    Motherboard:
    E7500
    CPU:
    Intel(R)Core(TM)2 DUO CPU 2.93HGz
    RAM:
    4098 Gb
    Graphics:
    1024 Gb
    Using
    AutoCAD 2009
    Join Date
    Jul 2005
    Location
    Thanks God, I'm far enough from Hitleropa
    Posts
    1,697

    Default

    Try to take this code as basic,
    then add your changes to the variables
    Code:
     
    (defun C:MREC (/ dxf ang ang+  dis elist em_list end ln  pi_2 pts 
    pt_lr pt_ur  start)
     
    (defun dxf (key alist)(cdr (assoc key 
    alist)))
     
    (while
    (setq ln (entsel "\nSelect line: 
    "))
          (progn
     (setq ln (car 
    ln)
           elist (entget 
    ln)
           start (dxf 10 
    elist)
           end (dxf 11 
    elist)
           ang (angle start 
    end)
           dis (distance start 
    end)
           pi_2 (/ pi 
    2.0)
           ang+    (+ ang 
    pi_2)
     pt_ur    (polar end ang+ 
    dis)
     pt_lr   (polar start ang+ 
    dis))
           (setq pts (mapcar '(lambda(p)(list 
    (car p) (cadr p)))
      (mapcar '(lambda(q) (trans q 1 0))(list start 
    end pt_ur pt_lr))))
     
     
    (setq em_list
       (append 
     
    (list 
          '(0 . 
    "LWPOLYLINE") 
          '(100 . 
    "AcDbEntity") 
          '(100 . 
    "AcDbPolyline")    
          ;(cons 
    8 "0"))
          (cons 90 (length 
    pts)) 
          (cons 70 
    1)     
       )
      (mapcar '(lambda 
    (p) (list 10 (car p) (cadr p)))pts)
     
     
     )
       )
     
     
       (if (entmake em_list)
     (entupd 
    (entlast))
    )
     )
    )
    (princ)
      )
    The soul is healed by being with children. - Fyodor Dostoyevsky, novelist (1821-1881)

  4. #4
    Luminous Being BlackBox's Avatar
    Computer Details
    BlackBox's Computer Details
    Operating System:
    Windows 8.1 Professional, Server 2012 R2 Datacenter
    Computer:
    Dell Precision T3600
    CPU:
    Hex-Core Intel Xeon 3.2Ghz
    RAM:
    32GB
    Graphics:
    3GB NVIDIA Quadro K4000
    Primary Storage:
    2 x 240GB Samsung EVO SSD (RAID 0)
    Secondary Storage:
    1TB Western Digital VelociRaptor 10K RPM
    Monitor:
    Dual 24" Dell Ultrasharp Widescreen Monitors
    Discipline
    Civil
    BlackBox's Discipline Details
    Occupation
    Senior Civil Designer
    Discipline
    Civil
    Details
    Public/Private Land Development, Transportation, and Utilities.
    Using
    Civil 3D 2016
    Join Date
    Nov 2009
    Posts
    5,282

    Default

    This works fine for me:
    Code:
    ;; <snip>
    (if (and (setq start (trans (getpoint) 1 0))
             (not (initget 32))
             (setq end (trans (getpoint start) 1 0))
        )
      (command "RECTANGLE"
               (list (setq x (car start))
                     (- (setq y (cadr start)) 0.33)
                     (last start)
               )
               (list (+ x (distance start end)) (+ y 0.33) (last end))
      )
    )
    ;; <snip>
    ** TRANS not required.
    "Potential has a shelf life." - Margaret Atwood
    AutoCAD, and Civil 3D Certified Professional | Autodesk Authorized Developer
    Sincpac C3D ~ Exchange Apps ~ Autoloader ~ AutoCAD Security

  5. #5
    Luminous Being Tharwat's Avatar
    Discipline
    Mechanical
    Tharwat's Discipline Details
    Occupation
    MEP AutoCAD Draughtsman
    Discipline
    Mechanical
    Details
    HVAC, Drainage, Water Supply, Fire Fighting and a little about Electricity.
    Using
    AutoCAD 2015
    Join Date
    Oct 2009
    Location
    Great Syria , Living in Abu Dhabi
    Posts
    6,085

    Default

    Quote Originally Posted by BlackBox View Post

    ** TRANS not required.
    But maybe off snap is required with the command call !

  6. #6
    Luminous Being BlackBox's Avatar
    Computer Details
    BlackBox's Computer Details
    Operating System:
    Windows 8.1 Professional, Server 2012 R2 Datacenter
    Computer:
    Dell Precision T3600
    CPU:
    Hex-Core Intel Xeon 3.2Ghz
    RAM:
    32GB
    Graphics:
    3GB NVIDIA Quadro K4000
    Primary Storage:
    2 x 240GB Samsung EVO SSD (RAID 0)
    Secondary Storage:
    1TB Western Digital VelociRaptor 10K RPM
    Monitor:
    Dual 24" Dell Ultrasharp Widescreen Monitors
    Discipline
    Civil
    BlackBox's Discipline Details
    Occupation
    Senior Civil Designer
    Discipline
    Civil
    Details
    Public/Private Land Development, Transportation, and Utilities.
    Using
    Civil 3D 2016
    Join Date
    Nov 2009
    Posts
    5,282

    Default

    Quote Originally Posted by Tharwat View Post
    But maybe off snap is required with the command call !
    You mean "_non"? Sure if you like.

    [Edit] - Again, not required... The first point is the CENter of a circle.... Sorry, wrong thread.
    Last edited by BlackBox; 22nd Jun 2013 at 07:34 pm.
    "Potential has a shelf life." - Margaret Atwood
    AutoCAD, and Civil 3D Certified Professional | Autodesk Authorized Developer
    Sincpac C3D ~ Exchange Apps ~ Autoloader ~ AutoCAD Security

  7. #7
    Super Member fixo's Avatar
    Computer Details
    fixo's Computer Details
    Operating System:
    Windows 7
    Motherboard:
    E7500
    CPU:
    Intel(R)Core(TM)2 DUO CPU 2.93HGz
    RAM:
    4098 Gb
    Graphics:
    1024 Gb
    Using
    AutoCAD 2009
    Join Date
    Jul 2005
    Location
    Thanks God, I'm far enough from Hitleropa
    Posts
    1,697

    Default

    Sorry for my stupidity, perhaps like this
    Code:
    (if (and (setq start (trans (getpoint) 1 
    0))
              (not (initget 
    32))
              (setq end (trans 
    (getpoint start) 1 0))
         )
      
    (progn
       (command 
    "RECTANGLE"
                
    "_non" (list (setq x (car 
    start))
                      
    (- (setq y (cadr start)) 
    0.33)
                      
    (last 
    start)
                
    )
                
    "_non"(list (+ x (distance start end)) (+ y 0.33) (last end))
       
    )
      (command "_rotate" "L" "" "_non" start (/ (* (angle start end) 180) 
    pi)))
     )
    The soul is healed by being with children. - Fyodor Dostoyevsky, novelist (1821-1881)

  8. #8
    Forum Newbie
    Using
    Civil 3D 2013
    Join Date
    Jun 2013
    Posts
    2

    Default

    Registered forum members do not see this ad.

    Adding "_non" did it! Thanks for the help.

Similar Threads

  1. autoCAD wierdness
    By cadmoney in forum AutoCAD 2D Drafting, Object Properties & Interface
    Replies: 2
    Last Post: 18th Oct 2012, 01:43 am
  2. Replies: 2
    Last Post: 4th Oct 2010, 12:16 pm
  3. Polygon & Rectangle Command Doesn't Work
    By gsksun4 in forum AutoCAD Beginners' Area
    Replies: 3
    Last Post: 7th Jun 2010, 07:54 pm
  4. erase everything outside a rectangle - need command
    By mark.meyers in forum AutoCAD General
    Replies: 1
    Last Post: 6th Aug 2009, 04:42 pm
  5. Replies: 6
    Last Post: 16th Oct 2008, 01:06 pm

Bookmarks

Posting Permissions

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