Author Topic: Create Polyline Offset  (Read 15463 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 #30 on: October 17, 2014, 08:25:13 AM »
tdtboy04,
I'm trying to make sense of your results and I can't.

Did you try Test1 ?

You may need to try Test1 and Test 2 again.

Then try the commands again manually,
once using Polyline first option
and once using Polyline second option


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 #31 on: October 17, 2014, 08:43:40 AM »
Code: [Select]
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: FFEE30C0>
 TEST2 Unknown command "TEST2".  Press F1 for help.

Command: nil

Command:  TEST2
Select object: *Cancel*
; error: Function cancelled


Command: f
FILLET
Current settings: Mode = TRIM, Radius = 123.0000
Select first object or [Undo/Polyline/Radius/Trim/Multiple]: poly
Select 2D polyline: r


*Invalid selection*
Expects a point or Window/Last/Crossing/BOX/Fence/WPolygon/CPolygon
Select 2D polyline:
1 line was filleted
1 was too short

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

Select first object or [Undo/Polyline/Radius/Trim/Multiple]: poly
Select 2D polyline:
2 lines were filleted
The fillet command work when i specify fillet radius then poly

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Create Polyline Offset
« Reply #32 on: October 17, 2014, 08:58:56 AM »
Just for fun,
Does this work in 2007 ??

Code - Auto/Visual Lisp: [Select]
  1. (defun c:Test3 ()
  2.   (setq pl (car (entsel))
  3.         *filletDist* 125
  4.   )
  5.   (setvar "FILLETRAD" *filletDist*)
  6.   (command "_Fillet" "Polyline" pl)
  7. )
  8.  
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 #33 on: October 17, 2014, 09:41:06 AM »
Yes , it works
Command: test3

Select object: _Fillet
Current settings: Mode = TRIM, Radius = 125.0000
Select first object or [uNdo/Polyline/Radius/Trim/mUltiple]: Polyline Select 2D
polyline:
3 lines were filleted


Command: nil
« Last Edit: October 17, 2014, 09:47:03 AM by tdtboy04 »

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Create Polyline Offset
« Reply #34 on: October 17, 2014, 06:15:52 PM »
In that case, make these changes to c:doit and all should be well
Code - Auto/Visual Lisp: [Select]
  1. (if (and offsetDist filletDist)
  2.     (progn
  3.           (vla-offset plineObj offsetDist)
  4.           (setvar "FILLETRAD" *filletDist*)
  5.           (command "_Fillet" "Polyline" (entlast))
  6.           (vla-delete plineObj)
  7.     )
  8.   )
« Last Edit: October 18, 2014, 12:11:15 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 #35 on: October 17, 2014, 11:27:46 PM »
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: *Cancel*


Offset Distance <<20.0000>>: 200


Fillet Distance <<20.0000>>: 200
_Fillet
Current settings: Mode = TRIM, Radius = 200.0000
Select first object or [uNdo/Polyline/Radius/Trim/mUltiple]: Polyline Select 2D
polyline:
Command:

the code : (vla-delete plineObj) works , but the fillet command doesn't work ( like we did not select the polyline ? ).
« Last Edit: October 17, 2014, 11:40:58 PM by tdtboy04 »

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Create Polyline Offset
« Reply #36 on: October 18, 2014, 12:14:17 AM »
The snippet was filleting the object from the test3 code.  :cry:  my bad!

change the code
(command "_Fillet" "Polyline" pl)
 to :
Code - Auto/Visual Lisp: [Select]
  1. (command "_Fillet" "Polyline" (entlast))
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 #37 on: October 18, 2014, 12:58:41 AM »
Finally , it works perfectly  :-)
Thank you so much , Kerry ! :angel:
This lisp so helpful for me .



edit-kdub : attachment removed.
« Last Edit: October 18, 2014, 01:38:38 AM by Kerry »

ScottMC

  • Newt
  • Posts: 191
Re: Create Polyline Offset
« Reply #38 on: December 11, 2019, 01:17:37 PM »
Using this with my A2K, This always avoided selection so I added at Line 111 and 307:
...
     111->>  (setq e (car (entsel "\nSelect a Polyline or Line: " )))
                   (command "convertpoly" "H" e "")
...
            307 -->>    (retrieve)
            (command "convertpoly" "L" f "")

ahsattarian

  • Newt
  • Posts: 112
Re: Create Polyline Offset
« Reply #39 on: November 30, 2020, 08:17:09 AM »
This Helps U :



Code - Auto/Visual Lisp: [Select]
  1. (defun c:opl ()
  2.   (defun sub1 () (cond (s1 (entdel s1) (setq s1 nil))))
  3.   (defun sub2 ()
  4.     (redraw)
  5.     (cond (s1 (entdel s1) (setq s1 nil)))
  6.     (setq side (trans side 1 normal))
  7.     (setq start nil)
  8.     (setq bulge (vla-getbulge obj param))
  9.     (if (zerop bulge)
  10.       (progn
  11.         (setq ang (- (angle pt side) (angle p1 p2) (* pi 0.5)))
  12.         (setq ofdist (* (abs (cos ang)) (distance pt side)))
  13.         (grdraw pt side 8 1)
  14.         (setq clockwise-p (< (sin (- (angle p1 side) (angle p1 p2))) -1e-14)) ;|  #clockwise  |;
  15.         (if clockwise-p
  16.           (progn
  17.             (setq start (polar p1 (- (angle p1 p2) (* pi 0.5)) ofdist))
  18.             (setq end (polar p2 (- (angle p1 p2) (* pi 0.5)) ofdist))
  19.           )
  20.           (progn
  21.             (setq start (polar p1 (+ (angle p1 p2) (* pi 0.5)) ofdist))
  22.             (setq end (polar p2 (+ (angle p1 p2) (* pi 0.5)) ofdist))
  23.           )
  24.         )
  25.       )
  26.       (progn
  27.         (setq ang (* (atan bulge) 2.0)) ;|  #bulge  |;
  28.         (setq rad (/ (distance p1 p2) (* (sin ang) 2.0)))
  29.         (setq cen (polar p1 (+ (angle p1 p2) (- (* pi 0.5) ang)) rad))
  30.         (setq ofdist (abs (- (distance cen side) (abs rad))))
  31.         (grdraw cen side 8 1)
  32.         (if (< (abs rad) (distance cen side))
  33.           (progn
  34.             (setq start (polar p1 (angle cen p1) ofdist))
  35.             (setq end (polar p2 (angle cen p2) ofdist))
  36.           )
  37.           (if (< ofdist (abs rad))
  38.             (progn
  39.               (setq start (polar p1 (angle p1 cen) ofdist))
  40.               (setq end (polar p2 (angle p2 cen) ofdist))
  41.             )
  42.           )
  43.         )
  44.       )
  45.     )
  46.     (if start
  47.       (progn
  48.         (setq method1 2)
  49.         (cond
  50.           ((= method1 1)
  51.            (if (equal (angle p1 pm) (angle pm p2) fuzzy)
  52.              (command "line" p1 p2 "")
  53.              (command "arc" p1 pm p2)
  54.            )
  55.            (setvar "peditaccept" 1)
  56.            (command "pedit" "last" "")
  57.            (command "offset" "erase" "yes" "layer" "current" ofdist (entlast) side "")
  58.            (setq s1 (entlast))
  59.            (setq obj1 (vlax-ename->vla-object s1))
  60.           )
  61.           ((= method1 2)
  62.            (setq obj1 (vlax-invoke space 'addlightweightpolyline (list (car start) (cadr start) (car end) (cadr end))))
  63.            (vla-setbulge obj1 0 bulge)
  64.            (setq s1 (vlax-vla-object->ename obj1))
  65.           )
  66.         )
  67.         (setq method2 2)
  68.         (cond ((= (vla-get-objectname obj) "AcDb2dPolyline") (setq method2 1)))
  69.         (cond
  70.           ((= method2 1) (setq w1 (nth param w1li)) (setq w2 (nth param w2li)))
  71.           ((= method2 2) (vla-getwidth obj param 'w1 'w2))
  72.         )
  73.         (setq method3 2)
  74.         (cond
  75.           ((= method3 1) (command "pedit" s1 "e" "w" w1 w2 "x" ""))
  76.           ((= method3 2) (vla-setwidth obj1 0 w1 w2))
  77.         )
  78.         (foreach prop '(elevation layer linetype linetypegeneration linetypescale lineweight normal truecolor) ;|  #matchprop  |;
  79.           (cond ((vlax-property-available-p obj prop) (vlax-put obj1 prop (vlax-get obj prop))))
  80.         )
  81.         (setq pt1 (vlax-curve-getclosestpointto s1 pt))
  82.         (grdraw pt pt1 9 1)
  83.         (grdraw side pt1 8 1)
  84.       )
  85.     )
  86.   )
  87.   (defun sub3 ()
  88.     (cond
  89.       ((= (car a) 40) (setq w1li (append w1li (list (cdr a)))))
  90.       ((= (car a) 41) (setq w2li (append w2li (list (cdr a)))))
  91.       ((= (car a) 42) (setq buli (append buli (list (cdr a)))))
  92.     )
  93.   )
  94.   (setq s1 nil)
  95.   (setq es (entsel "\n Select Pline : "))
  96.   (setq s (car es))
  97.   (setq poj (cadr es))
  98.   (setq fuzzy 1e-4)
  99.   (if (= 1 (getvar "cvport"))
  100.   )
  101.   (setvar "autosnap" 39)
  102.   (setvar "orthomode" 0) ;|  #orthomode  |;
  103.   (setvar "osmode" 0)
  104.   (while s
  105.     (redraw s 4)
  106.     (setq en (entget s))
  107.     (setq typ (strcase (cdr (assoc 0 en)) t))
  108.     (setq w1li nil)
  109.     (setq w2li nil)
  110.     (setq buli nil)
  111.     (cond
  112.       ((= typ "lwpolyline") (foreach a en (sub3)))
  113.       ((= typ "polyline")
  114.        (setq sn (entnext s))
  115.        (setq enn (entget sn))
  116.        (setq typn (cdr (assoc 0 enn)))
  117.        (while (/= typn "seqend")
  118.          (foreach a enn (sub3))
  119.          (setq sn (entnext sn))
  120.          (setq enn (entget sn))
  121.          (setq typn (strcase (cdr (assoc 0 enn)) t))
  122.        )
  123.       )
  124.     )
  125.     (setq obj (vlax-ename->vla-object s))
  126.     (setq normal (vlax-get obj 'normal)) ;|  #normal vector  |;
  127.     (setq poj (osnap poj "_nea"))
  128.     (setq pt (trans poj 1 0))
  129.     (setq param (fix (vlax-curve-getparamatpoint obj pt)))
  130.     (setq p1 (trans (vlax-curve-getpointatparam obj param) 0 normal))
  131.     (setq pm (trans (vlax-curve-getpointatparam obj (+ (float param) 0.5)) 0 normal))
  132.     (setq p2 (trans (vlax-curve-getpointatparam obj (1+ param)) 0 normal))
  133.     (setq g 1)
  134.     (while (= g 1)
  135.       (setq gr (grread t 15 0)) ;| #grread |;
  136.       (setq code (car gr))
  137.       (setq side (cadr gr))
  138.       (cond
  139.         ((= code 5) (sub1) (sub2)) ;| Bedune Click |;
  140.         ((= code 3) ;| Click Beshe |;
  141.          (sub1)
  142.          (sub2)
  143.          (setq s1 nil)
  144.          (setvar "offsetdist" ofdist)
  145.         )
  146.         ((= code 2) (redraw) (sub1) (setq g 0)) ;| Type Beshe |;
  147.         ((= code 25) (redraw) (sub1) (setq g 0)) ;| #mouse #right-click |;
  148.       )
  149.     )
  150.     (setq s1 nil)
  151.     (setq es (entsel "\n Select Pline : "))
  152.     (setq s (car es))
  153.     (setq poj (cadr es))
  154.   )
  155.   (redraw s 4)
  156.   (princ "\n *** E N D *** ")
  157. )