+ Reply to Thread
Page 3 of 3 FirstFirst 1 2 3
Results 21 to 27 of 27
  1. #21
    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.

    Lee, I tried using the routine that you wrote but it didn't work some of the routines that i use it with, that's why i was using jsowinski routine.

  2. #22
    Quantum Mechanic Lee Mac's Avatar
    Computer Details
    Lee Mac's Computer Details
    Operating System:
    Windows 7 Ultimate (32-bit)
    Discipline
    Multi-disciplinary
    Lee Mac's Discipline Details
    Discipline
    Multi-disciplinary
    Details
    Custom Programming / Software Customisation
    Using
    AutoCAD 2013
    Join Date
    Aug 2008
    Location
    London, England
    Posts
    19,360

    Default

    You should've said - what error do you receive?
    Lee Mac ProgrammingTwitterExchange App StoreDropbox (500MB free)

    With Mathematics there is the possibility of perfect rigour, so why settle for less?

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

    Default

    BrianTFC-
    One of the things that happens with using vla-explode is that it can make a copy from the original. I think that's what happened when you found lines on top of the selected rectangle. You can try and delete the rectangle by adding something like this.

    (vl-catch-all-apply 'vla-delete (list VlaObj))


    I placed it into your program. (see below)

    Code:
     
    (defun c:Offsetpline (/ *error* OffsetDist VlaObj sset num Ang Ptdist StartPt EndPt)
    (vl-load-com)
    (defun *error* (msg)
    (princ)
    ); _end defun
    (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)))
    (vlax-put-property vlaobj 'layer "Router - Green-V groove")
    (vl-catch-all-apply 'vlax-invoke-method (list VlaObj 'explode))
    (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
    (vl-catch-all-apply 'vla-delete (list VlaObj))
    (setq VlaObj (vlax-ename->vla-object (entlast)))
    (vl-catch-all-apply 'vlax-put (list VlaObj 'Layer "Router - Blue - Cuts"))
    (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
    Otherwise, since you want to explode the selected rectangle I took another shot at writing the program. I cleaned it up a little. I also put in the layer names you used in your code. I guessed at the order you placed them in. Give it a try and let me know if that works for you. Thanks.

    Code:
     
    (defun c:offsetpline (/ *error* OffsetDist VlaObj)
    (vl-load-com)
    (defun *error* (msg)
    (princ)
    ); _end defun
    (setq OffsetDist (getreal "\nEnter an offset distance: "))
    (while (setq VlaObj (vlax-ename->vla-object (car (entsel "\nSelect a Rectangle: "))))
     (vl-catch-all-apply 'vlax-put (list VlaObj 'Layer "Router - Green-V groove"))
     (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)
     (foreach Obj (vl-catch-all-apply 'vlax-invoke (list VlaObj 'explode))
      (vl-catch-all-apply 'vla-offset (list Obj (- OffsetDist)))
      (vl-catch-all-apply 'vlax-put (list (vlax-ename->vla-object (entlast)) 'Layer "Router - Blue - Cuts"))
     ); _end foreach
     (foreach Obj (vl-catch-all-apply 'vlax-invoke (list VlaObj 'explode))
      (vl-catch-all-apply 'vla-offset (list Obj OffsetDist))
      (vl-catch-all-apply 'vlax-put (list (vlax-ename->vla-object (entlast)) 'Layer "Router - Blue - Cuts"))
     ); _end foreach
     ); _end if
     (vl-catch-all-apply 'vla-delete (list VlaObj))
    ); _end while
    ); _end defun
    jsowinski

  4. #24
    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

    That works good...on ? is there a way to make so i can select multiple rectangles at once?

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

    Default

    Give this a try. Just hit enter when you're done selecting rectangles.

    Code:
     
    (defun c:offsetpline (/ *error* OffsetDist num Rset VlaObj)
    (vl-load-com)
    (defun *error* (msg)
    (princ)
    ); _end defun
    (setq OffsetDist (getreal "\nEnter an offset distance: "))
    (princ "\nSelect the rectangle(s) you want to offset: ")
    (setq num -1)
    (if (setq Rset (ssget '((0 . "LWPOLYLINE"))))
     (repeat (sslength Rset)
      (setq VlaObj (vlax-ename->vla-object (ssname Rset (setq num (1+ num)))))
      (vl-catch-all-apply 'vlax-put (list VlaObj 'Layer "Router - Green-V groove"))
      (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)
       (foreach Obj (vl-catch-all-apply 'vlax-invoke (list VlaObj 'explode))
        (vl-catch-all-apply 'vla-offset (list Obj (- OffsetDist)))
        (vl-catch-all-apply 'vlax-put (list (vlax-ename->vla-object (entlast)) 'Layer "Router - Blue - Cuts"))
       ); _end foreach
       (foreach Obj (vl-catch-all-apply 'vlax-invoke (list VlaObj 'explode))
        (vl-catch-all-apply 'vla-offset (list Obj OffsetDist))
        (vl-catch-all-apply 'vlax-put (list (vlax-ename->vla-object (entlast)) 'Layer "Router - Blue - Cuts"))
       ); _end foreach
      ); _end if
      (vl-catch-all-apply 'vla-delete (list VlaObj))
     ); _end repeat
    ); _end if
    (princ)
    ); _end defun

  6. #26
    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

    That worked Great thanks.....

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

    Default

    Registered forum members do not see this ad.

    You're welcome.

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