+ Reply to Thread
Page 1 of 3 1 2 3 LastLast
Results 1 to 10 of 27
  1. #1
    Senior Member
    Discipline
    Manufacture
    BrianTFC's Discipline Details
    Occupation
    Structral Detailer
    Discipline
    Manufacture
    Using
    AutoCAD 2017
    Join Date
    Jan 2012
    Location
    Indiana
    Posts
    158

    Default Offset rectangle into separate lines ?

    Registered forum members do not see this ad.

    Hi ALL,

    You know how when you offset a rectangle it it stay as a polyline? i need a lisp routine that i can use to offset the rectangle, set the new lines to current layer, and substract the offset distance from both end of the line. i know thats asking alot but has anyone seen a routine like this?

    Thanks,
    Brian

  2. #2
    Quantum Mechanic ReMark's Avatar
    Computer Details
    ReMark's Computer Details
    Operating System:
    Windows 7 Pro 64-bit
    Computer:
    Thinkmate
    Motherboard:
    Intel DX58SO2 LGA1366 X58
    CPU:
    Intel i7-960 Quad-core 3.20GHz 8MB cache
    RAM:
    12GB (3x4GB) PC3-106000 DDR3
    Graphics:
    nVidia Quadro K4200, 4GB GDDR5
    Primary Storage:
    150GB Velocipraptor 10,000 rpm
    Secondary Storage:
    none
    Monitor:
    Dell P24LLH - 24" wide screen LCD
    Discipline
    See details...
    ReMark's Discipline Details
    Occupation
    CAD Draftsman/Designer...chemical manufacturing.
    Discipline
    See details below.
    Details
    I work for a specialty chemical manufacturer. I do a little bit of everything from P&IDs to civil to architectural and structural.
    Using
    AutoCAD 2018
    Join Date
    Nov 2005
    Location
    Norwalk, CT USofA
    Posts
    46,496

    Default

    Explode then Offset.
    "I have only come here seeking knowledge. Things they wouldn't teach me of in college." The Police

    Eat brains...gain more knowledge!

    I'm now a full member of the Society for the Promotion of Mediocrity in CAD. Standards? We don't need no stinkin' standards! Take whatever advice I offer and do the opposite.

  3. #3
    Super Member DANIEL's Avatar
    Discipline
    Mechanical
    DANIEL's Discipline Details
    Occupation
    Industrial
    Discipline
    Mechanical
    Using
    AutoCAD 2013
    Join Date
    May 2005
    Location
    Arlington Texas
    Posts
    1,005

    Default

    Quote Originally Posted by ReMark View Post
    Explode then Offset.
    he's looking for something a bit more than that dude lol.
    If you would like to help my 2 year old niece Alaina in her battle against Leukemia you can donate blood at any Carter Blood Care and put SPON050875 on the donor form. Thank you so much for any contributions in this matter that you can make.

    Luminous beings are we, not this crude matter.

  4. #4
    Quantum Mechanic ReMark's Avatar
    Computer Details
    ReMark's Computer Details
    Operating System:
    Windows 7 Pro 64-bit
    Computer:
    Thinkmate
    Motherboard:
    Intel DX58SO2 LGA1366 X58
    CPU:
    Intel i7-960 Quad-core 3.20GHz 8MB cache
    RAM:
    12GB (3x4GB) PC3-106000 DDR3
    Graphics:
    nVidia Quadro K4200, 4GB GDDR5
    Primary Storage:
    150GB Velocipraptor 10,000 rpm
    Secondary Storage:
    none
    Monitor:
    Dell P24LLH - 24" wide screen LCD
    Discipline
    See details...
    ReMark's Discipline Details
    Occupation
    CAD Draftsman/Designer...chemical manufacturing.
    Discipline
    See details below.
    Details
    I work for a specialty chemical manufacturer. I do a little bit of everything from P&IDs to civil to architectural and structural.
    Using
    AutoCAD 2018
    Join Date
    Nov 2005
    Location
    Norwalk, CT USofA
    Posts
    46,496

    Default

    Yeah, it would probably be too tough to create a macro that would do that. Forget I suggested it.
    "I have only come here seeking knowledge. Things they wouldn't teach me of in college." The Police

    Eat brains...gain more knowledge!

    I'm now a full member of the Society for the Promotion of Mediocrity in CAD. Standards? We don't need no stinkin' standards! Take whatever advice I offer and do the opposite.

  5. #5
    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

    I wonder what the OP could accomplish if they spent the same time learning how to do some of this themselves, instead of posting duplicate threads. Just saying .
    "Potential has a shelf life." - Margaret Atwood
    AutoCAD, and Civil 3D Certified Professional | Autodesk Authorized Developer
    Sincpac C3D ~ Exchange Apps ~ Autoloader ~ AutoCAD Security

  6. #6
    Forum Deity rkent's Avatar
    Computer Details
    rkent's Computer Details
    Operating System:
    WIN7 PRO 64bit
    Computer:
    Dell OptiPlex 7020
    CPU:
    i7 4790 3.6GHz
    RAM:
    16GB, 1600MHz, DDR3 non-ECC 2x8GB
    Graphics:
    AMD Radeon 2GB
    Primary Storage:
    Samsung 480Gb SSD
    Monitor:
    Dell 24" FS (2x)
    Discipline
    Mechanical
    rkent's Discipline Details
    Occupation
    Facilities Design - Semi-conductor manufacturing
    Discipline
    Mechanical
    Details
    Designer: Process Piping, P&ID's, Machine Part Design, Planning / General Arrangement. Facilities Management. Drafting: Electrical, Controls, Architectural.
    Using
    Mechanical 2017
    Join Date
    Nov 2007
    Location
    Lat:35, Long:-106, Elev: 5164'
    Posts
    4,579

    Default

    Quote Originally Posted by BrianTFC View Post
    Hi ALL,

    You know how when you offset a rectangle it it stay as a polyline? i need a lisp routine that i can use to offset the rectangle, set the new lines to current layer, and substract the offset distance from both end of the line. i know thats asking alot but has anyone seen a routine like this?

    Thanks,
    Brian
    If you are trying to automate drawing a steel beam you might look at....
    http://www.draftsperson.net/index.ph...s_LISP_program

    If not, tell us what you are trying to draw, maybe a lisp already exists.
    Sometimes there's a man... I won't say a hero, 'cause, what's a hero? But sometimes, there's a man. And I'm talkin' about the Dude here. Sometimes, there's a man, well, he's the man for his time and place. He fits right in there. And that's the Dude, in Los Angeles. - The Stranger, The Big Lebowski

  7. #7
    Luminous Being
    Using
    Civil 3D 2016
    Join Date
    Dec 2005
    Location
    GEELONG AUSTRALIA
    Posts
    9,879

    Default

    Basic lisp pick two pts look up help about the polar command not very hard

    Code:
    (setq pt1 (getpoint))
    (setq pt2 (getpoint))
    (setq offs (getreal))
    (setq x1 (car pt1))
    (setq y1 (cadr pt1))
     
    now look up polar, distance (hint x1-x2, y1-y2)
    work out the 8 points.
    A man who never made mistakes never made anything

  8. #8
    Forum Deity David Bethel's Avatar
    Discipline
    Multi-disciplinary
    David Bethel's Discipline Details
    Discipline
    Multi-disciplinary
    Details
    Commercial Food Service
    Using
    AutoCAD pre 2000
    Join Date
    Dec 2003
    Location
    Newport News, Virginia
    Posts
    2,534

    Default

    It's actually a fairly involved process:

    Code:
    (defun c:offlin (/ fs fe fd el cf le en ed pl fl mp hd l10 l11)
      (defun mid_pt (s e)
         (mapcar '(lambda (a b) (* (+ a b) 0.5)) s e))
    
      (if (and (princ "\nSelect PLINE To Offset")
               (setq fs (ssget '((0 . "LWPOLYLINE"))))
               (= (sslength fs) 1)
               (setq fe (ssname fs 0)
                     fd (entget fe)
                     el (cdr (assoc 38 fd))
                     cf (if (= (logand (cdr (assoc 70 fd)) 1) 1) T nil)
                     le (entlast)))
          (progn
            (while (eq le (entlast))
                   (command "_.CMDECHO" 1
                            "_.OFFSET" pause fe pause)
                   (if (not (eq le (entlast)))
                       (command))
                   (command "_.CMDECHO" 0))
            (setq en (entlast)
                  ed (entget en))
            (entdel en)
            (foreach p ed
              (if (= 10 (car p))
                  (setq pl (cons (cdr p) pl))))
            (foreach p fd
              (if (= 10 (car p))
                  (setq fl (cons (cdr p) fl))))
            (and cf (setq pl (cons (last pl) pl)
                          fl (cons (last fl) fl)))
            (if (= (length pl) (length fl))
                (progn
                  (while (> (length pl) 1)
                         (setq mp (mid_pt (car pl) (cadr pl))
                               hd (* (distance (car fl) (cadr fl)) 0.5)
                              l10 (polar mp (angle (car pl) (cadr pl)) hd)
                              l11 (polar mp (angle (cadr pl) (car pl)) hd))
                         (entmake (list (cons 0 "LINE")
                                        (cons 10 (append l10 (list el)))
                                        (cons 11 (append l11 (list el)))))
                         (setq pl (cdr pl)
                               fl (cdr fl)))))))
      (prin1))

    error trapping with OFFSET type commands are NOT always accurate.

    This makes the line segments the same length as original PLINE regardless if the offset side is to the inside or outside.

    Have fun! -David
    Last edited by David Bethel; 7th Feb 2012 at 02:28 pm.
    R12 (Dos) - A2K

  9. #9
    Junior Member
    Using
    Architecture 2013
    Join Date
    Jul 2011
    Posts
    10

    Default

    Hi-
    This is what I thought of from reading your post. (see picture below) Let me know if I misunderstood you.


    Offset Rectangle.jpg

    This will work on rectangles only. They can be horizontal or rotated.
    You need to enter an offset distance and select a rectangle. The routine stays open to allow you to select more than one rectangle. I hope that helps.


    Code:
    (defun c:offsetpline (/ CurLayer OffsetDist VlaObj sset num Ang Ptdist StartPt EndPt)
    (vl-load-com)
     
    (defun *error* (msg)
    (princ)
    ); _end defun
     
    (setq CurLayer (getvar "clayer"))
    (setq OffsetDist (getreal "\nEnter an offset distance: "))
     
    (while (setq VlaObj (vlax-ename->vla-object (car (entsel "Select a Rectangle: "))))
     (setq Startpt (vlax-curve-getPointAtParam VlaObj 1))
     (setq Ang (+ (angle (vlax-curve-getStartPoint VlaObj)(vlax-curve-getPointAtParam VlaObj 1))(* (/ pi 180) 90)))
     (setq PtDist (distance Startpt (vlax-curve-getPointAtParam VlaObj 2)))
     
     (if (equal (polar Startpt Ang PtDist)(vlax-curve-getPointAtParam VlaObj 2) 1.0)
      (vl-catch-all-apply 'vlax-invoke-method (list VlaObj 'Offset OffsetDist))
      (vl-catch-all-apply 'vlax-invoke-method (list VlaObj 'Offset (- OffsetDist)))
     ); _end if
     
     (setq VlaObj (vlax-ename->vla-object (entlast)))
     (vl-catch-all-apply 'vlax-put (list VlaObj 'Layer CurLayer))
     (vl-cmdf "explode" (entlast) "")
     (setq sset (ssget "_P"))
     (setq num -1)
     
     (repeat (sslength sset)
      (setq VlaObj (vlax-ename->vla-object (ssname sset (setq num (1+ num)))))
      (setq StartPt (polar (vlax-get VlaObj 'StartPoint)(vlax-get VlaObj 'Angle) OffsetDist))
      (vl-catch-all-apply 'vlax-put (list VlaObj 'StartPoint StartPt))
      (setq EndPt (polar (vlax-get VlaObj 'EndPoint)(- (vlax-get VlaObj 'Angle) pi) OffsetDist))
      (vl-catch-all-apply 'vlax-put (list VlaObj 'EndPoint EndPt))
     ); _end repeat
    ); _end while
     
    (princ)
    ); _end defun
    Last edited by SLW210; 23rd Feb 2012 at 10:27 pm. Reason: code tags!!!!

  10. #10
    Senior Member
    Discipline
    Manufacture
    BrianTFC's Discipline Details
    Occupation
    Structral Detailer
    Discipline
    Manufacture
    Using
    AutoCAD 2017
    Join Date
    Jan 2012
    Location
    Indiana
    Posts
    158

    Default

    Registered forum members do not see this ad.

    That works great thank you for your help.

Similar Threads

  1. Trimming Lines within a rectangle
    By Sundar in forum .NET, ObjectARX & VBA
    Replies: 20
    Last Post: 20th Jan 2012, 05:19 am
  2. finding distance between offset lines
    By fisher22 in forum AutoCAD Beginners' Area
    Replies: 4
    Last Post: 6th Jul 2011, 06:40 pm
  3. automatic offset lines?
    By stephenward in forum AutoCAD 2D Drafting, Object Properties & Interface
    Replies: 10
    Last Post: 28th Jul 2009, 11:07 am
  4. offset 2 lines add dimensions and tag
    By gazzalp in forum AutoLISP, Visual LISP & DCL
    Replies: 15
    Last Post: 18th Dec 2008, 12:35 pm
  5. How to separate text into individual lines?
    By Chris333 in forum AutoCAD Beginners' Area
    Replies: 7
    Last Post: 29th Oct 2007, 01:14 pm

Tags for this Thread

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