Author Topic: OFFSET closed polyline  (Read 5301 times)

0 Members and 1 Guest are viewing this topic.

Andrea

  • Water Moccasin
  • Posts: 2372
OFFSET closed polyline
« on: October 12, 2004, 03:02:07 PM »
Hi,

I need to make an offset of a close polyline INSIDE at 2 unit by selecting
1 time the polyline.

So I have no idea how to get the inside of Polyline..see ?

any help here..

thanks.
Keep smile...

Jassper

  • Guest
OFFSET closed polyline
« Reply #1 on: October 12, 2004, 04:04:06 PM »
Can you be a little more specific -

if it will not offset to the inside then the "offset Distance" is too Large

or am I missing something?

Little


Command: _pline
Specify start point:
Current line-width is 0.0000
Specify next point or [Arc/Halfwidth/Length/Undo/Width]:
Specify next point or [Arc/Close/Halfwidth/Length/Undo/Width]:
Specify next point or [Arc/Close/Halfwidth/Length/Undo/Width]:
Specify next point or [Arc/Close/Halfwidth/Length/Undo/Width]:
Specify next point or [Arc/Close/Halfwidth/Length/Undo/Width]: c

Command:
OFFSET
Specify offset distance or [Through] <2.0000>:

Select object to offset or <exit>:
Specify point on side to offset:
Select object to offset or <exit>:

Command:
OFFSET
Specify offset distance or [Through] <2.0000>:

Select object to offset or <exit>:
Specify point on side to offset:
Cannot offset that object.
Select object to offset or <exit>:

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
OFFSET closed polyline
« Reply #2 on: October 12, 2004, 04:07:59 PM »
Code: [Select]
(defun c:OffsetInside ( / dist ename vobj )
  (setq dist 2)
  (setq ename (car (entsel "\nSelect object to offset: ")))
  (setq vobj (vlax-ename->vla-object ename))
  (if (vlax-method-applicable-p vobj 'Offset)
    (progn
      ;;(vlax-invoke vobj 'Offset dist) ; outside
      (vlax-invoke vobj 'Offset (- dist))
    )
    (princ "\nCannot offset selected object type ")
  )
  (princ)
) ;end
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

Andrea

  • Water Moccasin
  • Posts: 2372
OFFSET closed polyline
« Reply #3 on: October 13, 2004, 09:02:20 AM »
Hi CAB and thanks for the help.
I have noted a little mistake (in RED).


(defun c:OffsetInside ( / dist ename vobj )
  (setq dist 2)
  (setq ename (car (entsel "\nSelect object to offset: ")))
  (setq vobj (vlax-ename->vla-object ename))
  (if (vlax-method-applicable-p vobj 'Offset)
    (progn
     (vlax-invoke vobj 'Offset dist) ; INSIDE
     ;; (vlax-invoke vobj 'Offset (- dist))
    )
    (princ "\nCannot offset selected object type ")
  )
  (princ)
) ;end


you can also change the (setq dist 2) by (setq dist -2)


thanks again.   :wink:
Keep smile...

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
OFFSET closed polyline
« Reply #4 on: October 13, 2004, 10:58:47 AM »
Quote from: Andrea
Hi CAB and thanks for the help.
I have noted a little mistake (in RED).


Quote from: Help File
The distance to offset the object. The offset can be a positive or negative number, but it cannot equal zero. If the offset is negative, this is interpreted as being an offset to make a "smaller" curve (that is, for an arc it would offset to a radius that is "Distance less" than the starting curve's radius). If "smaller" has no meaning, then it would offset in the direction of smaller X, Y, and Z WCS coordinates.


Andrea negative numbers offset to the inside not positive numbers.
Your correction is incorrect. :wink:
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

Andrea

  • Water Moccasin
  • Posts: 2372
OFFSET closed polyline
« Reply #5 on: October 13, 2004, 11:18:36 AM »
Quote from: CAB

Andrea negative numbers offset to the inside not positive numbers.
Your correction is incorrect. :wink:


CAB,

sorry, but it was tested.
don't tell me why ..??

but it work. :D
Keep smile...

Andrea

  • Water Moccasin
  • Posts: 2372
OFFSET closed polyline
« Reply #6 on: October 13, 2004, 11:45:37 AM »
hey !!  I have made more tests...

the result is...

sometime is offset outside....and sometime offset inside..

????? very strange..

 :?
Keep smile...

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
OFFSET closed polyline
« Reply #7 on: October 13, 2004, 12:34:40 PM »
Hummmm, at 2 units, do you think you were zoomed out too far?
Just a guess 8)
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

Andrea

  • Water Moccasin
  • Posts: 2372
OFFSET closed polyline
« Reply #8 on: October 13, 2004, 12:48:44 PM »
I've tried both....!!

 :cry:
Keep smile...

Serge J. Gianolla

  • Guest
OFFSET closed polyline
« Reply #9 on: October 13, 2004, 08:19:52 PM »
This is due to direction of your pline. +ve value on CCW will be resulting on same as -ve value on CW, and vice-versa.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
OFFSET closed polyline
« Reply #10 on: October 13, 2004, 11:16:31 PM »
Serge,
Never knew that..Guess it never bit me.
So, you need to determine the direction of the polyline before applying the offset.
Andrea do you have the code to do that?
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
OFFSET closed polyline
« Reply #11 on: October 14, 2004, 12:19:12 AM »
Here is one way:
Code: [Select]
(defun c:ofs (/ dist ename vobj)
  (setq dist 5)
  (setq ename (car (entsel "\nSelect object to offset: ")))
  (setq vobj (vlax-ename->vla-object ename))
  (if (vlax-method-applicable-p vobj 'offset)
    (progn
      (if (member (cdr (assoc 0 (entget ename)))
                  '("AECC_CONTOUR" "LWPOLYLINE" "POLYLINE") )
        (if (= "CCW" (@polydir ename))
          (vlax-invoke vobj 'offset dist)
          (vlax-invoke vobj 'offset (- dist))
        )
        (vlax-invoke vobj 'offset dist)
      )
    )
    (princ "\nCannot offset selected object type ")
  )
  (princ)
) ;end

;;===========================================================
;; PolyDir.LSP v1.0 (03-05-02) John F. Uhden, Cadlantic
;; This is freeware dedicated to Noah (?) and Cliff Middleton
;;
;;-----------------------------------------------------------------------
;; This function returns the deflection angle (in radians) of two angles:
;;
(defun @delta (a1 a2)
  (cond
    ((> a1 (+ a2 pi)) (setq a2 (+ a2 (* 2 pi))))
    ((> a2 (+ a1 pi)) (setq a1 (+ a1 (* 2 pi))))
  )
  (- a2 a1)
)
;;-------------------------------------------------------------
;; Function returns a list of 3D points from a continuous list
;; as returned by (vlax-safearray->list (vlax-variant-value X))
;;
(defun @cv_parse_list (data n / item new)
  (foreach element (reverse data)
    (setq item (cons element item))
    (if (= (length item) n)
      (setq new  (cons item new)
            item nil
      )
    )
  )
  new
)

(defun @polydir (e / ent etype object coords flag i p1 p2 p3 sum)
  (cond
    ((/= (type e) 'ename) nil)
    ((not (vl-position (setq etype (cdr (assoc 0 (setq ent (entget e)))))
                       '("AECC_CONTOUR" "LWPOLYLINE" "POLYLINE")))
     (prompt (strcat " Object selected is a(n) " etype))
    )
    ((and (setq flag (cdr (assoc 70 ent))) (> (boole 1 16 flag) 0))
     (prompt " Object selected is a 3DMESH")
    )
    (1
     (setq object (vlax-ename->vla-object e)
           coords (vlax-get object "Coordinates")
           coords (@cv_parse_list coords
                                  (if (= etype "LWPOLYLINE") 2 3))
           i      1
           sum    0.0
     )
     (and flag
          (= (logand 1 flag) 1) ; closed
          (setq coords (reverse (cons (car coords) (reverse coords))))
     )
     (repeat (- (length coords) 2)
       (setq p1  (nth (1- i) coords)
             p2  (nth i coords)
             i   (1+ i)
             p3  (nth i coords)
             sum (+ sum (@delta (angle p1 p2) (angle p2 p3)))
       )
     )
     (if (minusp sum) "CW" "CCW")
    )
  )
)
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

daron

  • Guest
OFFSET closed polyline
« Reply #12 on: October 14, 2004, 08:53:24 AM »
My first reading of this thread implied programming, therefore... *poof*.