+ Reply to Thread
Results 1 to 4 of 4
  1. #1
    Junior Member
    Computer Details
    mhmtlgrr's Computer Details
    Operating System:
    Windows 7
    Computer:
    HP Workstation Z240
    Discipline
    Architectural
    mhmtlgrr's Discipline Details
    Occupation
    Architect
    Discipline
    Architectural
    Using
    AutoCAD 2015
    Join Date
    Jul 2012
    Posts
    12

    AutoCAD Multi-offset / Get offset distance values from given polyline.

    Registered forum members do not see this ad.

    Dear folks,

    Here I am with an interesting question. Please refer to the attached DWG file for further inspection.

    The scenerio is:
    1. I have a polyline that I use as a base that will be offset to OUTSIDE.
    2. Offset values may vary object to object. So what I need to achieve is to draw a polyline that consists of offset values between verticies like:

    If "-" is polyline length and "x" is vertex:

    ---x-x---x--

    This polyline says:
    Offset the selected polyline 2 units
    then offset new one 3 units
    then offset latest one 1 units
    and lastly 3 units.

    Is it even possible?

    Regards,

    MA
    Attached Files

  2. #2
    Super Member
    Computer Details
    ronjonp's Computer Details
    Operating System:
    Windows 10
    Using
    AutoCAD 2018
    Join Date
    Apr 2009
    Location
    Colorado
    Posts
    888

    Default

    HERE is something that would probably work for you.

  3. #3
    Super Member
    Computer Details
    ronjonp's Computer Details
    Operating System:
    Windows 10
    Using
    AutoCAD 2018
    Join Date
    Apr 2009
    Location
    Colorado
    Posts
    888

    Default

    Here's a quick mod of that code. You need to pick your profile segments in order then select the item(s) to offset.
    Code:
    (defun c:foo (/ _pts lm:clockwise-p a b c e o s)
      ;; Clockwise-p  -  Lee Mac
      ;; Returns T if p1,p2,p3 are clockwise oriented
      (defun lm:clockwise-p	(p1 p2 p3)
        ((lambda (n) (< (car (trans p2 0 n)) (car (trans p1 0 n)))) (mapcar '- p1 p3))
      )
      (defun _pts (e) (mapcar 'cdr (vl-remove-if-not '(lambda (x) (= 10 (car x))) (entget e))))
      (while (setq e (car (entsel "\nPick profile segments in order: ")))
        (setq c (cons (vlax-curve-getdistatparam e (vlax-curve-getendparam e)) c))
      )
      (setq b 0)
      (if (and c (setq s (ssget '((0 . "lwpolyline") (-4 . ">") (90 . 2)))))
        (foreach e (vl-remove-if 'listp (mapcar 'cadr (ssnamex s)))
          (setq a (_pts e))
          (setq a (cond ((lm:clockwise-p (car a) (cadr a) (caddr a)) -)
    		    (+)
    	      )
          )
          (foreach d (reverse c)
    	;; vlax-invoke will return a list of objects rather than an array
    	(setq o (car (vlax-invoke (vlax-ename->vla-object e) 'offset (a (setq b (+ b d))))))
    	;; Use entmod so layer does not need to exist
    	;; (entmod (append (entget (vlax-vla-object->ename o)) (list (cons 8 d))))
          )
        )
      )
      (princ)
    )

  4. #4
    Quantum Mechanic BIGAL's Avatar
    Using
    Civil 3D 2016
    Join Date
    Dec 2005
    Location
    GEELONG AUSTRALIA
    Posts
    10,702

    Default

    Registered forum members do not see this ad.

    I wrote one that use a csv input 1,2,3,-4,-6,-10 now where did I put it. It just converts the input to a list and repeats the offset command. It may be at home I posted here.



    Try these instead AH:test24 is what you want the other is more generic but you dont need to draw the little lines.

    Code:
    ; multiple offsets just enter values
    ; by Alan H July 2018
    ; pick pt3 well away from object and near square off
    ; for angle to work
    
    (defun AH:test23 ( / ent dist1 obj1 x obj2 pt2 pt1 oldsnap)
    (setq oldsnap (getvar 'osmode))
    (setvar 'osmode 512)
    (setq ent (entsel "pick object to offset"))
    (setq obj1 (car ent))
    (setq pt2 (cadr ent))
    (setq  pt3 (getpoint  pt2 "pick right side"))
    (setq ang  (angle pt2 pt3))
    (while
    (setq dist1 (getreal "Enter offset distance -ve for left <Enter> to exit"))
    (setq  pt3 (polar pt2  ang  dist1))
    (command "offset" (abs dist1) obj1 pt3 "")
    )
    (setvar 'osmode oldsnap)
    (princ)
    )
    (AH:test23)
    Code:
    (defun AH:test24 ( / ent dist1 obj1 x obj2 pt2 pt1 oldsnap)
    (setq oldsnap (getvar 'osmode))
    (setvar 'osmode 1)
    (setq ent (entsel "pick object to offset"))
    (setq obj1 (car ent))
    (setq pt2 (cadr ent))
    (setq  pt3 (getpoint  pt2 "pick right side"))
    (setq ang  (angle pt2 pt3))
    (while
    (setq dist1 (getdist pt2 "Enter offset distance -ve for left"))
    (setq  pt3 (polar pt2  ang  dist1))
    (command "offset" (abs dist1) obj1 pt3 "")
    )
    (setvar 'osmode oldsnap)
    (princ)
    )
    (AH:test24)
    Last edited by BIGAL; 10th Jul 2018 at 11:13 am.
    A man who never made mistakes never made anything

Similar Threads

  1. Offset, radius smaller than offset distance
    By zwonko in forum AutoLISP, Visual LISP & DCL
    Replies: 3
    Last Post: 15th Feb 2017, 11:35 pm
  2. Multi Offset with Different Distances
    By sidhu412 in forum AutoLISP, Visual LISP & DCL
    Replies: 32
    Last Post: 24th Aug 2014, 02:23 pm
  3. offset distance to left or right of polyline
    By avenger9mm in forum AutoLISP, Visual LISP & DCL
    Replies: 5
    Last Post: 28th Jul 2012, 01:25 am
  4. Offset to different distance
    By Tetsuo in forum AutoLISP, Visual LISP & DCL
    Replies: 10
    Last Post: 28th Jun 2011, 04:07 am
  5. Multi Offset...?
    By JBullseye74 in forum AutoCAD General
    Replies: 4
    Last Post: 4th Aug 2006, 03:09 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