Author Topic: Create Polyline Offset  (Read 16453 times)

0 Members and 1 Guest are viewing this topic.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Create Polyline Offset
« Reply #15 on: October 17, 2014, 06:48:19 AM »
Please use the Polyline option.
and please type the responses ; don't just hit enter to accept the defaults.

Something like this :

Command: FILLET
Current settings: Mode = TRIM, Radius = 100.0000
Select first object or [Undo/Polyline/Radius/Trim/Multiple]: r
Specify fillet radius <100.0000>: 222
Select first object or [Undo/Polyline/Radius/Trim/Multiple]: poly
Select 2D polyline or [Radius]:
2 lines were filleted


OR this

Command: FILLET
Current settings: Mode = TRIM, Radius = 222.0000
Select first object or [Undo/Polyline/Radius/Trim/Multiple]: Poly
Select 2D polyline or [Radius]: Rad
Specify fillet radius <222.0000>: 333
Select 2D polyline or [Radius]:
2 lines were filleted
« Last Edit: October 17, 2014, 06:53:46 AM by Kerry »
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

tdtboy04

  • Guest
Re: Create Polyline Offset
« Reply #16 on: October 17, 2014, 06:54:20 AM »
did you mean ?
Command: pl
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]: *Cancel*

Command: f
FILLET
Current settings: Mode = TRIM, Radius = 300.0000
Select first object or [Undo/Polyline/Radius/Trim/Multiple]: r
Specify fillet radius <300.0000>: 500

Select first object or [Undo/Polyline/Radius/Trim/Multiple]: p
Select 2D polyline:
3 lines were filleted

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Create Polyline Offset
« Reply #17 on: October 17, 2014, 07:00:51 AM »
Good,
Now try the fillet using the Polly Option before the RAD option ... as per the second example in Reply #15 ( 2 above )


ADDED:
Are you using an English version of AutoCAD ??
« Last Edit: October 17, 2014, 07:03:55 AM by Kerry »
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

tdtboy04

  • Guest
Re: Create Polyline Offset
« Reply #18 on: October 17, 2014, 07:05:06 AM »
Command: f
FILLET
Current settings: Mode = TRIM, Radius = 500.0000
Select first object or [Undo/Polyline/Radius/Trim/Multiple]: poly
Select 2D polyline: rad


*Invalid selection*
Expects a point or Window/Last/Crossing/BOX/Fence/WPolygon/CPolygon
Select 2D polyline: 800

3 lines were filleted

I am using English version .
« Last Edit: October 17, 2014, 07:08:34 AM by tdtboy04 »

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Create Polyline Offset
« Reply #19 on: October 17, 2014, 07:09:23 AM »

GREAT !!

The AC2007 command sequence is different, we need to ask for the radius first, then the Poly Option, SO ;

Try

Code - Auto/Visual Lisp: [Select]
  1. (command "_Fillet" "_Radius" *filletDist*  "_Polyline" (entlast))

In the Lisp file.
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

tdtboy04

  • Guest
Re: Create Polyline Offset
« Reply #20 on: October 17, 2014, 07:16:30 AM »
I Change
(command-s "Fillet" "Polyline" "Radius" *filletDist* (entlast))

to
(command "_Fillet" "_Radius" *filletDist*  "_Polyline" (entlast))

and the message :
Start point..:
Specify next point.. (ESC) to cancel:
Specify next point.. (ESC) to cancel:
Specify next point.. (ESC) to cancel:
Specify next point.. (ESC) to cancel:
Specify next point.. (ESC) to cancel:

Invalid point.

Specify next point.. (ESC) to cancel: *Cancel*


Offset Distance <<200.0000>>: 500


Fillet Distance <<300.0000>>: 500
_Fillet
Current settings: Mode = TRIM, Radius = 500.0000
Select first object or [uNdo/Polyline/Radius/Trim/mUltiple]: _Polyline Select
2D polyline: _Radius

*Invalid selection*
Expects a point or Window/Last/Crossing/BOX/Fence/WPolygon/CPolygon
Select 2D polyline:

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Create Polyline Offset
« Reply #21 on: October 17, 2014, 07:23:54 AM »
Can you please post the c:DOIT function.
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

tdtboy04

  • Guest
Re: Create Polyline Offset
« Reply #22 on: October 17, 2014, 07:28:22 AM »
Code: [Select]
;;;------------------------------------------------------------------
;;;------------------------------------------------------------------
;;;
;;; kwb 20021103
;;; KDUB:getdist (msg def bit kwd bpt
;;;
;;; Arguments:
;;; msg : The prompt string.
;;; def : Value to return if response is <enter>.
;;; bit  : initget bit
;;; kwd : Initget keywords string.
;;; bpt : Base point
;;;
;;; Note : Arguments may be set to nil

(defun kdub:getdist (msg def bit kwd bpt / returnvalue)
  (or kwd (setq kwd ""))
  (or bit (setq bit 1))
  (setq msg (strcat "\n"
                    (cond (msg)
                          ("Specify Distance")
                    )
            )
  )
  (if def
    (setq msg (strcat "\n" msg " <<" (rtos def) ">>: ")
          bit (logand bit (~ 1))
              ;; drop the 1 bit if def used
    )
    (setq msg (strcat "\n" msg ": "))
  )
  (initget bit kwd)
  (setq returnvalue
         (if bpt
           (getdist msg bpt)
           (getdist msg)
         )
  )
  (if returnvalue
    returnvalue
    def
  )
)
;;;------------------------------------------------------------------
;;;------------------------------------------------------------------
;;;
;;; kwb 20021103
;;; KDUB:getpoint (msg def bit kwd bpt

;;; Arguments:
;;; msg : The prompt string.
;;; def : Value to return if response is <enter>.
;;; bit   : initget bit
;;; kwd : Initget keywords string.
;;; bpt  : Base point
;;;
;;; requires KDUB:ptos
;;;
(defun kdub:getpoint (promptmsg              ; The prompt string.
                      default                ; return Value if <user enter> in UCS
                      initbit                ; Initget bit
                      keywordlist            ; Initget keywords List of strings
                      basepoint              ; Base point < or nil >  in UCS
                                             ;
                      /               promptmessage   initstring
                      keywordstring   returnvalue     parameterlist
                     )
  ;;------------------------------
  (or initbit (setq initbit 0))
  ;;------------------------------
  (if keywordlist
    (setq initstring    (substr
                          (apply 'strcat
                                 (mapcar '(lambda (item) (strcat " " item)) keywordlist)
                          )
                          2
                        )
          keywordstring (strcat " [" (vl-string-translate " " "/" initstring) "]")
    )
    (setq initstring ""
          keywordstring ""
    )
  )
  ;;------------------------------
  (setq promptmessage
         (strcat
           "\n"
           (cond (promptmsg)
                 ("Specify Point")
           )
           keywordstring
           (if default
             (progn (setq initbit (logand initbit (~ 1)))
                    (if (= (type default) 'str)
                      (strcat " <<" default ">>")
                      ;;
                      ;; else, assume it is a point .. user beware
                      (strcat " <<" (kdub:ptos default nil nil) ">>")
                    )
             )
             ""
           )
           ": "
         )
  )
  ;;------------------------------
  (initget initbit initstring)
  (if (vl-catch-all-error-p
        (setq returnvalue
               (vl-catch-all-apply
                 'getpoint
                 (if basepoint               ; in ucs
                   (list promptmessage basepoint)
                   (list promptmessage)
                 )
               )
        )
      )
    ;; ESC was pressed.
    (setq returnvalue nil
          default nil
    )
  )
  (if returnvalue
    returnvalue
    default
  )
)
;;;------------------------------------------------------------------
;;;------------------------------------------------------------------
;;;
;;; kwb 20021103
;;; KDUB:ptos (pt xmode xprec

;; Return a point formatted as a string
;; Arguments :
;; pt       : point list
;; xmode  : Units to use , can be nil
;; xprec   : display precision to use , can be nil

(defun kdub:ptos (pt xmode xprec)
  (or xmode (setq xmode (getvar "LUNITS")))
  (or xprec (setq xprec (getvar "LUPREC")))
  (if pt
    (strcat (rtos (car pt) xmode xprec)
            ",  "
            (rtos (cadr pt) xmode xprec)
            ",  "
            (rtos (caddr pt) xmode xprec)
    )
  )
)
;;;------------------------------------------------------------------
;;;------------------------------------------------------------------
(defun kdub:draw_lightweightpolyline
       (VertexList la closeflag / modelspace ucsZNormal elev PolyObj)
  (setq ucsZNormal (trans '(0 0 1) 1 0 t)
        elev       (caddr (trans (car VertexList) 1 ucsZNormal))
        modelspace (vla-get-modelspace
                     (vla-get-activedocument (vlax-get-acad-object))
                   )
  )
  (setq PolyObj (vlax-invoke
                  modelspace
                  'addLightWeightPolyline
                  (apply 'append
                         (mapcar '(lambda (pt)
                                    (setq pt (trans pt 1 ucsZNormal))
                                    (list (car pt) (cadr pt))
                                  )
                                 VertexList
                         )
                  )
                )
  )
  (vla-put-elevation PolyObj elev)
  (if la
    (vla-put-layer PolyObj la)
  )
  (vla-put-normal PolyObj (vlax-3d-point ucsZNormal))
  (vla-put-closed PolyObj closeflag)
  PolyObj
)

;;;------------------------------------------------------------------
;;;------------------------------------------------------------------


(defun draw_pline (/ PointList dynamicPoint)
  (setq PointList (list (setq dynamicPoint
                               (kdub:getpoint "Start point.." nil 1 nil nil)
                        )
                  )
  )
  (while (setq dynamicPoint
                (kdub:getpoint
                  "Specify next point.. (ESC) to cancel"
                  nil                        1
                  nil                        dynamicPoint
                 )
         )
    (setq PointList (cons dynamicPoint PointList))
  )
  (kdub:draw_lightweightpolyline
    (reverse PointList)
    (getvar "CLAYER")
    :vlax-false
  )
)



(defun c:doit (/ *error* plineObj offsetDist)
  (defun *error* (msg /)
    ;;----- Cancel any Active Commands -----------------------------
    (while (< 0 (getvar "cmdactive")) (command))
    ;;----- Display error message if applicable _-------------------
    (cond
      ((not msg))
      ((member (strcase msg t)
               '("console break" "function cancelled" "quit / exit abort")
       )
      )
      ((princ (strcat "\nApplication Error: " (itoa (getvar "errno")) " :- " msg)
       )
       ;;----- Display backtrace ---------------------
       (vl-bt)
      )
    )
    (setvar "errno" 0)
    (princ)
  )
  ;;-------------------------------------
  ;;-------------------------------------
  (setq plineObj     (draw_pline)
        *offsetDist* (if *offsetDist*
                       *offsetDist*
                       200.0
                     )
        *filletDist* (if *filletDist*
                       *filletDist*
                       100.0
                     )
        offsetDist   (kdub:getdist "Offset Distance" *offsetDist* nil nil nil)
        filletDist   (kdub:getdist "Fillet Distance" *filletDist* nil nil nil)
  )
  (if offsetDist
    (setq *offsetDist* offsetDist)
  )
  (if filletDist
    (setq *filletDist* filletDist)
  )
  (if (and offsetDist filletDist)
    (progn (vla-offset plineObj offsetDist)
           (command "_Fillet" "_Radius" *filletDist*  "_Polyline" (entlast))
           (vla-delete plineObj)
    )
  )
  (*error* nil)
  (princ)
)

(prompt "\nFile loaded. Command to run:-  DOIT\n")
(princ)


 ;|«Visual LISP© Format Options»
(80 2 45 2 nil "end of " 80 9 1 0 0 nil nil nil T)
;*** DO NOT add text below the comment! ***|;

and the message :
Command: doit

Start point..:
Specify next point.. (ESC) to cancel:
Specify next point.. (ESC) to cancel:
Specify next point.. (ESC) to cancel:
Specify next point.. (ESC) to cancel:
Specify next point.. (ESC) to cancel:

Invalid point.

Specify next point.. (ESC) to cancel: *Cancel*


Offset Distance <<500.0000>>:


Fillet Distance <<500.0000>>:
_Fillet
Current settings: Mode = TRIM, Radius = 500.0000
Select first object or [uNdo/Polyline/Radius/Trim/mUltiple]: _Polyline Select
2D polyline: _Radius

*Invalid selection*
Expects a point or Window/Last/Crossing/BOX/Fence/WPolygon/CPolygon
Select 2D polyline:

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Create Polyline Offset
« Reply #23 on: October 17, 2014, 07:34:37 AM »


Thanks,
Can you please draw 2 polylines manually,
and then run these 2 commands, one on each polyline.
Code - Auto/Visual Lisp: [Select]
  1. (defun c:Test1 ()
  2.         (setq pl (car (entsel)))
  3.         (command "_Fillet" "Polyline" "Radius" 123 pl)
  4. )
  5.  
  6. (defun c:Test2 ()
  7.         (setq pl (car (entsel)))
  8.         (command "_Fillet" "Radius" 123 "Polyline"  pl)
  9. )

For me in ac2015 test1 works , test2 throws an error.
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

tdtboy04

  • Guest
Re: Create Polyline Offset
« Reply #24 on: October 17, 2014, 07:45:12 AM »
Command: test1

Select object: _Fillet
Current settings: Mode = TRIM, Radius = 20.0000
Select first object or [uNdo/Polyline/Radius/Trim/mUltiple]: Polyline Select 2D
polyline: Radius

*Invalid selection*
Expects a point or Window/Last/Crossing/BOX/Fence/WPolygon/CPolygon
; error: Function cancelled
Select 2D polyline:
2 lines were filleted

Command:
Command: test2

Select object: _Fillet
Current settings: Mode = TRIM, Radius = 20.0000
Select first object or [uNdo/Polyline/Radius/Trim/mUltiple]: Radius Specify
fillet radius <20.0000>: 123
Command: Polyline Unknown command "POLYLINE".  Press F1 for help.

Command: <Entity name: FFEBB0A8>
 TEST2 Unknown command "TEST2".  Press F1 for help.

Command: nil

Test 1 work , test 2 error


Manual Fillet

Command: f
FILLET
Current settings: Mode = TRIM, Radius = 20.0000
Select first object or [Undo/Polyline/Radius/Trim/Multiple]: r
Specify fillet radius <20.0000>: 20

Select first object or [Undo/Polyline/Radius/Trim/Multiple]: poly
Select 2D polyline:
2 lines were filleted

ChrisCarlson

  • Guest
Re: Create Polyline Offset
« Reply #25 on: October 17, 2014, 07:57:45 AM »
On 2015 both test functions should work but Test2 seems to fail. Both of which are valid processes if done manually, so what's going on?

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Create Polyline Offset
« Reply #26 on: October 17, 2014, 07:59:58 AM »
This is really weird.
Both tests work for me if I use Command-S ( for AC2015 )
And both work manually from the command line.

Can you please test TEST1 and TEST2 again.

Then try the command sequence in the lisp that seems to work for the Test.

I'll wait till you try it.

ADDED:
Thanks Chris.
What is your result in 2015 if you use Command-S ??

And Added:
If I use Command in 2015
Quote
For me in ac2015 test1 works , test2 throws an error.

Added .. I was wrong .. Test 2 is not working using either command or command-s   :| :|

Thime for bed for me I think.
« Last Edit: October 17, 2014, 08:07:55 AM by Kerry »
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

tdtboy04

  • Guest
Re: Create Polyline Offset
« Reply #27 on: October 17, 2014, 08:08:01 AM »
Command: f
FILLET
Current settings: Mode = TRIM, Radius = 0.0000
Select first object or [Undo/Polyline/Radius/Trim/Multiple]: r
Specify fillet radius <0.0000>: 5

Select first object or [Undo/Polyline/Radius/Trim/Multiple]:
Command: test1

Select object: _Fillet
Current settings: Mode = TRIM, Radius = 5.0000
Select first object or [uNdo/Polyline/Radius/Trim/mUltiple]: Polyline Select 2D
polyline: Radius

*Invalid selection*
Expects a point or Window/Last/Crossing/BOX/Fence/WPolygon/CPolygon
; error: Function cancelled
Select 2D polyline:
2 lines were filleted


Command: test2

Select object: _Fillet
Current settings: Mode = TRIM, Radius = 5.0000
Select first object or [uNdo/Polyline/Radius/Trim/mUltiple]: Radius Specify
fillet radius <5.0000>: 123
Command: Polyline Unknown command "POLYLINE".  Press F1 for help.

Command: <Entity name: FFECB088>
 TEST2 Unknown command "TEST2".  Press F1 for help.

Command: nil

Command:  TEST2
Select object:  _Fillet
Current settings: Mode = TRIM, Radius = 123.0000
Select first object or [uNdo/Polyline/Radius/Trim/mUltiple]: Radius Specify
fillet radius <123.0000>: 123
Command: Polyline Unknown command "POLYLINE".  Press F1 for help.

Command:
Command: nil

Command: doit

Start point..:
Specify next point.. (ESC) to cancel:
Specify next point.. (ESC) to cancel:
Specify next point.. (ESC) to cancel:
Specify next point.. (ESC) to cancel:
Specify next point.. (ESC) to cancel:

Invalid point.

Specify next point.. (ESC) to cancel: *Cancel*


Offset Distance <<200.0000>>: 5


Fillet Distance <<100.0000>>: 5
_Fillet
Current settings: Mode = TRIM, Radius = 123.0000
Select first object or [uNdo/Polyline/Radius/Trim/mUltiple]: _Polyline Select
2D polyline: _Radius

*Invalid selection*
Expects a point or Window/Last/Crossing/BOX/Fence/WPolygon/CPolygon
Select 2D polyline:

Test1 work , but test2 error

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Create Polyline Offset
« Reply #28 on: October 17, 2014, 08:12:43 AM »
If test 1 works then

Code - Auto/Visual Lisp: [Select]
  1.   (if (and offsetDist filletDist)
  2.     (progn (vla-offset plineObj offsetDist)
  3.            (command "_Fillet" "_Polyline" "_Radius" *filletDist*  (entlast))
  4.            (vla-delete plineObj)
  5.     )
  6.   )

SHOULD work in the c:DOIT code in Ac2007. ( I believe :-D )
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

tdtboy04

  • Guest
Re: Create Polyline Offset
« Reply #29 on: October 17, 2014, 08:20:35 AM »
Code: [Select]
(defun c:doit (/ *error* plineObj offsetDist)
  (defun *error* (msg /)
    ;;----- Cancel any Active Commands -----------------------------
    (while (< 0 (getvar "cmdactive")) (command))
    ;;----- Display error message if applicable _-------------------
    (cond
      ((not msg))
      ((member (strcase msg t)
               '("console break" "function cancelled" "quit / exit abort")
       )
      )
      ((princ (strcat "\nApplication Error: " (itoa (getvar "errno")) " :- " msg)
       )
       ;;----- Display backtrace ---------------------
       (vl-bt)
      )
    )
    (setvar "errno" 0)
    (princ)
  )
  ;;-------------------------------------
  ;;-------------------------------------
  (setq plineObj     (draw_pline)
        *offsetDist* (if *offsetDist*
                       *offsetDist*
                       200.0
                     )
        *filletDist* (if *filletDist*
                       *filletDist*
                       100.0
                     )
        offsetDist   (kdub:getdist "Offset Distance" *offsetDist* nil nil nil)
        filletDist   (kdub:getdist "Fillet Distance" *filletDist* nil nil nil)
  )
  (if offsetDist
    (setq *offsetDist* offsetDist)
  )
  (if filletDist
    (setq *filletDist* filletDist)
  )
      (if (and offsetDist filletDist)
       (progn (vla-offset plineObj offsetDist)
              (command "_Fillet" "_Polyline" "_Radius" *filletDist*  (entlast))
              (vla-delete plineObj)
       )
     )
  (*error* nil)
  (princ)
)

(prompt "\nFile loaded. Command to run:-  DOIT\n")
(princ)


 ;|«Visual LISP© Format Options»
(80 2 45 2 nil "end of " 80 9 1 0 0 nil nil nil T)
;*** DO NOT add text below the comment! ***|;
I change the code , but it doesn't work !
I think I should use 2014 version .
Thanks you so much , Kerry ! Nice to know you !