Author Topic: How to Creating the offset  (Read 2296 times)

0 Members and 1 Guest are viewing this topic.

2e4lite

  • Guest
How to Creating the offset
« on: October 20, 2013, 04:44:10 AM »
   How to Creating the offset ? The specifc requirements are attached.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10365
Re: How to Creating the offset
« Reply #1 on: October 20, 2013, 12:35:12 PM »
Are you working with polylines only?
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.

2e4lite

  • Guest
Re: How to Creating the offset
« Reply #2 on: October 21, 2013, 07:36:26 AM »
Yeah,It only working with polylines .

Master_Shake

  • Swamp Rat
  • Posts: 1447
Re: How to Creating the offset
« Reply #3 on: October 21, 2013, 08:09:47 AM »
I'm so confused?  :-o

Are you looking for the command to do an offset?

ribarm

  • Water Moccasin
  • Posts: 2126
  • Marko Ribar, architect
Re: How to Creating the offset
« Reply #4 on: October 21, 2013, 01:09:18 PM »
Try this, but be sure you don't pick 3d polyline...

Code - Auto/Visual Lisp: [Select]
  1. (defun c:oo (/ *adoc* *error* ch1 ch2 cmde eel el ell es fr od p par pl pll pn pna pneel pnnpl pnpl pnpla pp ppa ppeel pppl pppla ppppl pt ptl ptlu rl)
  2.  
  3.  
  4.   (defun *error* (msg)
  5.     (if cmde (setvar 'cmdecho cmde))
  6.     (if fr (setvar 'filletrad fr))
  7.     (vla-endundomark *adoc*)
  8.     (if msg (prompt msg))
  9.     (princ)
  10.   )
  11.  
  12.   (defun AssocOn (SearchTerm Lst func fuzz)
  13.     (car
  14.       (vl-member-if
  15.         (function
  16.           (lambda (pair) (equal SearchTerm (apply func (list pair)) fuzz))
  17.         )
  18.         lst
  19.       )
  20.     )
  21.   )
  22.  
  23.   (defun mid (p1 p2)
  24.     (mapcar '(lambda (a b) (/ (+ a b) 2.0)) p1 p2)
  25.   )
  26.  
  27.   (vla-startundomark *adoc*)
  28.   (setq cmde (getvar 'cmdecho))
  29.   (setq fr (getvar 'filletrad))
  30.   (setvar 'cmdecho 1)
  31.   (initget 1 "Segment Complete")
  32.   (setq ch1 (getkword "\nSegment or Complete offset [Segment/Complete]: "))
  33.   (if (eq ch1 "Complete")
  34.     (progn
  35.       (initget 1 "Original Bulge")
  36.       (setq ch2 (getkword "\n[O]riginal-classic offset or preserving [B]ulge factors on curving segments (O/B): "))
  37.       (if (eq ch2 "Original")
  38.         (progn
  39.           (command "_.offset")
  40.           (while (> (getvar 'cmdactive) 0) (command "\\"))
  41.         )
  42.         (progn
  43.           (prompt "\nSpecify offset distance <") (princ (getvar 'offsetdist)) (prompt ">: ")
  44.           (initget 6)
  45.           (setq od (getdist))
  46.           (if (null od) (setq od (getvar 'offsetdist)))
  47.           (setq pl (car (entsel "\nSelect object to offset")))
  48.           (setq pt (getpoint "\nSpecify point on side to offset: "))
  49.           (command "_.offset" od pl pt "")
  50.           (setq el (entlast))
  51.           (if (eq (cdr (assoc 90 (entget pl))) (cdr (assoc 90 (entget el))))
  52.             (progn
  53.               (if (eq (cdr (assoc 0 (entget pl))) "LWPOLYLINE")
  54.                 (progn
  55.                   (setq pll (entget pl))
  56.                   (setq ell (entget el))
  57.                   (setq rl (mapcar '(lambda (p1 p2 b) (if (/= b 0.0) (/ (distance p1 p2) (* 2.0 (sin (* 2.0 (atan b))))) 0.0)) (setq ptl (mapcar 'cdr (vl-remove-if-not '(lambda (x) (eq (car x) 10)) pll))) (cdr (reverse (cons (car ptl) (reverse ptl)))) (mapcar 'cdr (vl-remove-if-not '(lambda (x) (eq (car x) 42)) pll))))
  58.                   (setq ptl (mapcar 'cdr (vl-remove-if-not '(lambda (x) (eq (car x) 10)) ell)))
  59.                   (setq ptlu (mapcar '(lambda (p) (trans p el 1)) ptl))
  60.                   (mapcar '(lambda (p1p p1 p2 p2n r) (if (/= r 0.0) (progn (setvar 'filletrad (abs r)) (command "_.fillet" (mid p1p p1) (mid p2 p2n))))) (cons (last ptlu) ptlu) ptlu (cdr (reverse (cons (car ptlu) (reverse ptlu)))) (cddr (reverse (cons (car ptlu) (cons (cadr ptlu) (reverse ptlu))))) rl)
  61.                   (if (/= (last rl) 0.0)
  62.                     (progn
  63.                       (setvar 'filletrad (abs (last rl)))
  64.                       (command "_.fillet" (mid (car ptlu) (cadr ptlu)) (mid (cadr (reverse ptlu)) (car (reverse ptlu))))
  65.                     )
  66.                   )
  67.                 )
  68.                 (progn
  69.                   (command "_.convertpoly" "l" pl "")
  70.                   (command "_.convertpoly" "l" el "")
  71.                   (setq pll (entget pl))
  72.                   (setq ell (entget el))
  73.                   (setq rl (mapcar '(lambda (p1 p2 b) (if (/= b 0.0) (/ (distance p1 p2) (* 2.0 (sin (* 2.0 (atan b))))) 0.0)) (setq ptl (mapcar 'cdr (vl-remove-if-not '(lambda (x) (eq (car x) 10)) pll))) (cdr (reverse (cons (car ptl) (reverse ptl)))) (mapcar 'cdr (vl-remove-if-not '(lambda (x) (eq (car x) 42)) pll))))
  74.                   (setq ptl (mapcar 'cdr (vl-remove-if-not '(lambda (x) (eq (car x) 10)) ell)))
  75.                   (setq ptlu (mapcar '(lambda (p) (trans p el 1)) ptl))
  76.                   (mapcar '(lambda (p1p p1 p2 p2n r) (if (/= r 0.0) (progn (setvar 'filletrad (abs r)) (command "_.fillet" (mid p1p p1) (mid p2 p2n))))) (cons (last ptlu) ptlu) ptlu (cdr (reverse (cons (car ptlu) (reverse ptlu)))) (cddr (reverse (cons (car ptlu) (cons (cadr ptlu) (reverse ptlu))))) rl)
  77.                   (if (/= (last rl) 0.0)
  78.                     (progn
  79.                       (setvar 'filletrad (abs (last rl)))
  80.                       (command "_.fillet" (mid (car ptlu) (cadr ptlu)) (mid (cadr (reverse ptlu)) (car (reverse ptlu))))
  81.                     )
  82.                   )
  83.                   (command "_.convertpoly" "h" pl "")
  84.                   (command "_.convertpoly" "h" el "")
  85.                 )
  86.               )
  87.             )
  88.             (progn
  89.               (prompt "\nOriginal and offseted pline don't have the same number of vertices - unable to perform this kind of offset")
  90.               (entdel el)
  91.             )
  92.           )
  93.         )
  94.       )
  95.     )
  96.     (progn
  97.       (initget 1 "Intersection Normal")
  98.       (setq ch2 (getkword "\nSpecify type of segment offset - ([I]ntersection/[N]ormal): "))
  99.       (if (eq ch2 "Intersection")
  100.         (progn
  101.           (setq pl (car (setq es (entsel "\nPick pline segment to offset"))))
  102.           (setq p (trans (cadr es) 1 0))
  103.           (if (eq (cdr (assoc 0 (entget pl))) "LWPOLYLINE")
  104.             (progn
  105.               (prompt "\nSpecify offset distance <") (princ (getvar 'offsetdist)) (prompt ">: ")
  106.               (initget 6)
  107.               (setq od (getdist))
  108.               (if (null od) (setq od (getvar 'offsetdist)))
  109.               (command "_.copy" pl "" '(0.0 0.0 0.0) '(0.0 0.0 0.0))
  110.               (setq el (entlast))
  111.               (setq par (vlax-curve-getparamatpoint pl (vlax-curve-getclosestpointto pl p)))
  112.               (if (< 1.0 par (- (vlax-curve-getendparam pl) 1.0))
  113.                 (if (/= (vla-getbulge (vlax-ename->vla-object pl) (fix par)) 0.0)
  114.                   (progn
  115.                     (prompt "\nPicked segment is curved - unable to offset this kind of segment")
  116.                     (entdel el)
  117.                   )
  118.                   (if (or (/= (vla-getbulge (vlax-ename->vla-object pl) (fix (+ par 1.0))) 0.0) (/= (vla-getbulge (vlax-ename->vla-object pl) (fix (- par 1.0))) 0.0))
  119.                     (progn
  120.                       (prompt "\nPrevious or next segment of picked one is curved - unable to offset this kind of segment")
  121.                       (entdel el)
  122.                     )
  123.                     (progn
  124.                       (setq pt (getpoint "\nSpecify point on side to offset: "))
  125.                       (command "_.offset" od pl pt "")
  126.                       (setq eel (entlast))
  127.                       (setq ppeel (vlax-curve-getpointatparam eel (fix par)))
  128.                       (setq pneel (vlax-curve-getpointatparam eel (+ (fix par) 1.0)))
  129.                       (setq pppl (vlax-curve-getpointatparam pl (fix par)))
  130.                       (setq pnpl (vlax-curve-getpointatparam pl (+ (fix par) 1.0)))
  131.                       (setq ppppl (vlax-curve-getpointatparam pl (- (fix par) 1.0)))
  132.                       (setq pnnpl (vlax-curve-getpointatparam pl (+ (fix par) 2.0)))
  133.                       (setq pp (inters pneel ppeel ppppl pppl nil))
  134.                       (setq pn (inters ppeel pneel pnnpl pnpl nil))
  135.                       (entdel eel)
  136.                       (setq ell (entget el))
  137.                       (setq pp (trans pp 0 el))
  138.                       (setq pn (trans pn 0 el))
  139.                       (setq pppl (trans pppl 0 el))
  140.                       (setq pnpl (trans pnpl 0 el))
  141.                       (setq pppla (cons 10 (mapcar '+ pppl '(0.0 0.0))))
  142.                       (setq pnpla (cons 10 (mapcar '+ pnpl '(0.0 0.0))))
  143.                       (setq ppa (cons 10 (mapcar '+ pp '(0.0 0.0))))
  144.                       (setq pna (cons 10 (mapcar '+ pn '(0.0 0.0))))
  145.                       (setq ell (subst ppa (assocon (cadr pppla) (vl-remove-if-not '(lambda (x) (eq (car x) 10)) ell) 'cadr 1e-6) ell))
  146.                       (setq ell (subst pna (assocon (cadr pnpla) (vl-remove-if-not '(lambda (x) (eq (car x) 10)) ell) 'cadr 1e-6) ell))
  147.                       (entmod ell)
  148.                       (entupd (cdr (assoc -1 ell)))
  149.                     )
  150.                   )
  151.                 )
  152.                 (progn
  153.                   (prompt "\nPicked segment is start or end segment - unable to offset this kind of segment")
  154.                   (entdel el)
  155.                 )
  156.               )
  157.             )
  158.             (progn
  159.               (command "_.convertpoly" "l" pl "")
  160.               (prompt "\nSpecify offset distance <") (princ (getvar 'offsetdist)) (prompt ">: ")
  161.               (initget 6)
  162.               (setq od (getdist))
  163.               (if (null od) (setq od (getvar 'offsetdist)))
  164.               (command "_.copy" pl "" '(0.0 0.0 0.0) '(0.0 0.0 0.0))
  165.               (setq el (entlast))
  166.               (setq par (vlax-curve-getparamatpoint pl (vlax-curve-getclosestpointto pl p)))
  167.               (if (< 1.0 par (- (vlax-curve-getendparam pl) 1.0))
  168.                 (if (/= (vla-getbulge (vlax-ename->vla-object pl) (fix par)) 0.0)
  169.                   (progn
  170.                     (prompt "\nPicked segment is curved - unable to offset this kind of segment")
  171.                     (entdel el)
  172.                   )
  173.                   (if (or (/= (vla-getbulge (vlax-ename->vla-object pl) (fix (+ par 1.0))) 0.0) (/= (vla-getbulge (vlax-ename->vla-object pl) (fix (- par 1.0))) 0.0))
  174.                     (progn
  175.                       (prompt "\nPrevious or next segment of picked one is curved - unable to offset this kind of segment")
  176.                       (entdel el)
  177.                     )
  178.                     (progn
  179.                       (setq pt (getpoint "\nSpecify point on side to offset: "))
  180.                       (command "_.offset" od pl pt "")
  181.                       (setq eel (entlast))
  182.                       (setq ppeel (vlax-curve-getpointatparam eel (fix par)))
  183.                       (setq pneel (vlax-curve-getpointatparam eel (+ (fix par) 1.0)))
  184.                       (setq pppl (vlax-curve-getpointatparam pl (fix par)))
  185.                       (setq pnpl (vlax-curve-getpointatparam pl (+ (fix par) 1.0)))
  186.                       (setq ppppl (vlax-curve-getpointatparam pl (- (fix par) 1.0)))
  187.                       (setq pnnpl (vlax-curve-getpointatparam pl (+ (fix par) 2.0)))
  188.                       (setq pp (inters pneel ppeel ppppl pppl nil))
  189.                       (setq pn (inters ppeel pneel pnnpl pnpl nil))
  190.                       (entdel eel)
  191.                       (setq ell (entget el))
  192.                       (setq pp (trans pp 0 el))
  193.                       (setq pn (trans pn 0 el))
  194.                       (setq pppl (trans pppl 0 el))
  195.                       (setq pnpl (trans pnpl 0 el))
  196.                       (setq pppla (cons 10 (mapcar '+ pppl '(0.0 0.0))))
  197.                       (setq pnpla (cons 10 (mapcar '+ pnpl '(0.0 0.0))))
  198.                       (setq ppa (cons 10 (mapcar '+ pp '(0.0 0.0))))
  199.                       (setq pna (cons 10 (mapcar '+ pn '(0.0 0.0))))
  200.                       (setq ell (subst ppa (assocon (cadr pppla) (vl-remove-if-not '(lambda (x) (eq (car x) 10)) ell) 'cadr 1e-6) ell))
  201.                       (setq ell (subst pna (assocon (cadr pnpla) (vl-remove-if-not '(lambda (x) (eq (car x) 10)) ell) 'cadr 1e-6) ell))
  202.                       (entmod ell)
  203.                       (entupd (cdr (assoc -1 ell)))
  204.                     )
  205.                   )
  206.                 )
  207.                 (progn
  208.                   (prompt "\nPicked segment is start or end segment - unable to offset this kind of segment")
  209.                   (entdel el)
  210.                 )
  211.               )
  212.               (command "_.convertpoly" "h" pl "")
  213.               (command "_.convertpoly" "h" el "")
  214.             )
  215.           )
  216.         )
  217.         (progn
  218.           (setq pl (car (setq es (entsel "\nPick pline segment to offset"))))
  219.           (setq p (trans (cadr es) 1 0))
  220.           (if (eq (cdr (assoc 0 (entget pl))) "LWPOLYLINE")
  221.             (progn
  222.               (prompt "\nSpecify offset distance <") (princ (getvar 'offsetdist)) (prompt ">: ")
  223.               (initget 6)
  224.               (setq od (getdist))
  225.               (if (null od) (setq od (getvar 'offsetdist)))
  226.               (command "_.copy" pl "" '(0.0 0.0 0.0) '(0.0 0.0 0.0))
  227.               (setq el (entlast))
  228.               (setq par (vlax-curve-getparamatpoint pl (vlax-curve-getclosestpointto pl p)))
  229.               (if (< 1.0 par (- (vlax-curve-getendparam pl) 1.0))
  230.                 (if (/= (vla-getbulge (vlax-ename->vla-object pl) (fix par)) 0.0)
  231.                   (progn
  232.                     (prompt "\nPicked segment is curved - unable to offset this kind of segment")
  233.                     (entdel el)
  234.                   )
  235.                   (if (or (/= (vla-getbulge (vlax-ename->vla-object pl) (fix (+ par 1.0))) 0.0) (/= (vla-getbulge (vlax-ename->vla-object pl) (fix (- par 1.0))) 0.0))
  236.                     (progn
  237.                       (prompt "\nPrevious or next segment of picked one is curved - unable to offset this kind of segment")
  238.                       (entdel el)
  239.                     )
  240.                     (progn
  241.                       (setq pt (getpoint "\nSpecify point on side to offset: "))
  242.                       (command "_.offset" od pl pt "")
  243.                       (setq eel (entlast))
  244.                       (setq ppeel (vlax-curve-getpointatparam eel (fix par)))
  245.                       (setq pneel (vlax-curve-getpointatparam eel (+ (fix par) 1.0)))
  246.                       (setq pppl (vlax-curve-getpointatparam pl (fix par)))
  247.                       (setq pnpl (vlax-curve-getpointatparam pl (+ (fix par) 1.0)))
  248.                       (command "_.ucs" "e" pl)
  249.                       (setq ppppl (trans (polar (trans pppl 0 1) (+ (angle (trans pppl 0 1) (trans pnpl 0 1)) (* pi 0.5)) 1.0) 1 0))
  250.                       (setq pnnpl (trans (polar (trans pnpl 0 1) (+ (angle (trans pnpl 0 1) (trans pppl 0 1)) (* pi 0.5)) 1.0) 1 0))
  251.                       (setq pp (inters pneel ppeel ppppl pppl nil))
  252.                       (setq pn (inters ppeel pneel pnnpl pnpl nil))
  253.                       (entdel eel)
  254.                       (setq ell (entget el))
  255.                       (setq pp (trans pp 0 el))
  256.                       (setq pn (trans pn 0 el))
  257.                       (setq pppl (trans pppl 0 el))
  258.                       (setq pnpl (trans pnpl 0 el))
  259.                       (setq pppla (cons 10 (mapcar '+ pppl '(0.0 0.0))))
  260.                       (setq pnpla (cons 10 (mapcar '+ pnpl '(0.0 0.0))))
  261.                       (setq ppa (cons 10 (mapcar '+ pp '(0.0 0.0))))
  262.                       (setq pna (cons 10 (mapcar '+ pn '(0.0 0.0))))
  263.                       (setq ell (subst ppa (assocon (cadr pppla) (vl-remove-if-not '(lambda (x) (eq (car x) 10)) ell) 'cadr 1e-6) ell))
  264.                       (setq ell (subst pna (assocon (cadr pnpla) (vl-remove-if-not '(lambda (x) (eq (car x) 10)) ell) 'cadr 1e-6) ell))
  265.                       (entmod ell)
  266.                       (entupd (cdr (assoc -1 ell)))
  267.                       (command "_.ucs" "p")
  268.                     )
  269.                   )
  270.                 )
  271.                 (progn
  272.                   (prompt "\nPicked segment is start or end segment - unable to offset this kind of segment")
  273.                   (entdel el)
  274.                 )
  275.               )
  276.             )
  277.             (progn
  278.               (command "_.convertpoly" "l" pl "")
  279.               (prompt "\nSpecify offset distance <") (princ (getvar 'offsetdist)) (prompt ">: ")
  280.               (initget 6)
  281.               (setq od (getdist))
  282.               (if (null od) (setq od (getvar 'offsetdist)))
  283.               (command "_.copy" pl "" '(0.0 0.0 0.0) '(0.0 0.0 0.0))
  284.               (setq el (entlast))
  285.               (setq par (vlax-curve-getparamatpoint pl (vlax-curve-getclosestpointto pl p)))
  286.               (if (< 1.0 par (- (vlax-curve-getendparam pl) 1.0))
  287.                 (if (/= (vla-getbulge (vlax-ename->vla-object pl) (fix par)) 0.0)
  288.                   (progn
  289.                     (prompt "\nPicked segment is curved - unable to offset this kind of segment")
  290.                     (entdel el)
  291.                   )
  292.                   (if (or (/= (vla-getbulge (vlax-ename->vla-object pl) (fix (+ par 1.0))) 0.0) (/= (vla-getbulge (vlax-ename->vla-object pl) (fix (- par 1.0))) 0.0))
  293.                     (progn
  294.                       (prompt "\nPrevious or next segment of picked one is curved - unable to offset this kind of segment")
  295.                       (entdel el)
  296.                     )
  297.                     (progn
  298.                       (setq pt (getpoint "\nSpecify point on side to offset: "))
  299.                       (command "_.offset" od pl pt "")
  300.                       (setq eel (entlast))
  301.                       (setq ppeel (vlax-curve-getpointatparam eel (fix par)))
  302.                       (setq pneel (vlax-curve-getpointatparam eel (+ (fix par) 1.0)))
  303.                       (setq pppl (vlax-curve-getpointatparam pl (fix par)))
  304.                       (setq pnpl (vlax-curve-getpointatparam pl (+ (fix par) 1.0)))
  305.                       (command "_.ucs" "e" pl)
  306.                       (setq ppppl (trans (polar (trans pppl 0 1) (+ (angle (trans pppl 0 1) (trans pnpl 0 1)) (* pi 0.5)) 1.0) 1 0))
  307.                       (setq pnnpl (trans (polar (trans pnpl 0 1) (+ (angle (trans pnpl 0 1) (trans pppl 0 1)) (* pi 0.5)) 1.0) 1 0))
  308.                       (setq pp (inters pneel ppeel ppppl pppl nil))
  309.                       (setq pn (inters ppeel pneel pnnpl pnpl nil))
  310.                       (entdel eel)
  311.                       (setq ell (entget el))
  312.                       (setq pp (trans pp 0 el))
  313.                       (setq pn (trans pn 0 el))
  314.                       (setq pppl (trans pppl 0 el))
  315.                       (setq pnpl (trans pnpl 0 el))
  316.                       (setq pppla (cons 10 (mapcar '+ pppl '(0.0 0.0))))
  317.                       (setq pnpla (cons 10 (mapcar '+ pnpl '(0.0 0.0))))
  318.                       (setq ppa (cons 10 (mapcar '+ pp '(0.0 0.0))))
  319.                       (setq pna (cons 10 (mapcar '+ pn '(0.0 0.0))))
  320.                       (setq ell (subst ppa (assocon (cadr pppla) (vl-remove-if-not '(lambda (x) (eq (car x) 10)) ell) 'cadr 1e-6) ell))
  321.                       (setq ell (subst pna (assocon (cadr pnpla) (vl-remove-if-not '(lambda (x) (eq (car x) 10)) ell) 'cadr 1e-6) ell))
  322.                       (entmod ell)
  323.                       (entupd (cdr (assoc -1 ell)))
  324.                       (command "_.ucs" "p")
  325.                     )
  326.                   )
  327.                 )
  328.                 (progn
  329.                   (prompt "\nPicked segment is start or end segment - unable to offset this kind of segment")
  330.                   (entdel el)
  331.                 )
  332.               )
  333.               (command "_.convertpoly" "h" pl "")
  334.               (command "_.convertpoly" "h" el "")
  335.             )
  336.           )      
  337.         )
  338.       )
  339.     )
  340.   )
  341.   (*error* nil)
  342.   (princ)
  343. )
  344.  

M.R.
« Last Edit: October 22, 2013, 01:35:58 PM by ribarm »
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

ribarm

  • Water Moccasin
  • Posts: 2126
  • Marko Ribar, architect
Re: How to Creating the offset
« Reply #5 on: October 22, 2013, 05:36:41 AM »
Above posted code finally updated... See if you can use it - I've put it in my start-up suite... Please, reply if you're satisfied or you have some bug that I missed...

Sincerely, M.R.
 8-)
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

ribarm

  • Water Moccasin
  • Posts: 2126
  • Marko Ribar, architect
Re: How to Creating the offset
« Reply #6 on: October 22, 2013, 08:58:19 AM »
I have expanded the code to include operations on start/end segments if "S"egment option is chosen...

I'll attach file because now it's much larger...

Regards, M.R.

[EDIT: Included PKENEWELL revisions - it were 5+16 downloads till I uploaded lsp again]
« Last Edit: November 13, 2014, 04:35:20 PM by ribarm »
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

PKENEWELL

  • Bull Frog
  • Posts: 221
Re: How to Creating the offset
« Reply #7 on: October 22, 2013, 12:51:08 PM »
I have expanded the code to include operations on start/end segments if "S"egment option is chosen...

I'll attach file because now it's much larger...

Regards, M.R.

Hi Marko,

Interesting program - I can see how this could be quite useful. A couple of things jumped out when I tested your code:

1) On closed polylines your code is failing to set the radius of the closing segment. I noticed this line in your code needed to be changed in 2 places because a negative fillet value was being inserted:

Code - Auto/Visual Lisp: [Select]
  1. (if (/= (last rl) 0.0)
  2.        (progn
  3.            (setvar 'filletrad (abs (last rl))) ;; Added ABS here to prevent negative fillet radius
  4.            (command "_.fillet" (mid (car ptlu) (cadr ptlu)) (mid (cadr (reverse ptlu)) (car (reverse ptlu))))
  5.        )
  6. )
  7.  

2) Suggestion: You should use your initget and getkword calls with the standard formatting that will work with the context menus as follows:

Code - Auto/Visual Lisp: [Select]
  1.   (initget 1 "Segment Complete") ;; This will work whether the user enters "S" or "Segment", will always return the whole word
  2.   (setq ch1 (getkword "\nSegment or Complete offset [Segment/Complete]: ")) ;; This command line format will allow the options to display in the context menu
  3.   (if (eq ch1 "Complete") ;; Always check for the whole word on this type of initget call
  4.  

Cheers - Phil.
"When you are asked if you can do a job, tell 'em, 'Certainly I can!' Then get busy and find out how to do it." - Theodore Roosevelt

ribarm

  • Water Moccasin
  • Posts: 2126
  • Marko Ribar, architect
Re: How to Creating the offset
« Reply #8 on: October 22, 2013, 01:29:24 PM »
PKENEWELL, yes you're right... Simply, I don't have 4 eyes, so thanks for revisions...

M.R.
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

PKENEWELL

  • Bull Frog
  • Posts: 221
Re: How to Creating the offset
« Reply #9 on: October 22, 2013, 03:40:30 PM »
PKENEWELL, yes you're right... Simply, I don't have 4 eyes, so thanks for revisions...

M.R.

No Problem Marko. Glad to be of help.  :-)

- Phil.
"When you are asked if you can do a job, tell 'em, 'Certainly I can!' Then get busy and find out how to do it." - Theodore Roosevelt

2e4lite

  • Guest
Re: How to Creating the offset
« Reply #10 on: October 24, 2013, 08:50:26 AM »
Above posted code finally updated... See if you can use it - I've put it in my start-up suite... Please, reply if you're satisfied or you have some bug that I missed...

Sincerely, M.R.
 8-)


Hi ribarm,
     This program basically meet the requirement for my use, very good. But not perfect.Can improve the following questions, thank you!
  1.segment offset - ntersection:
    a.changed to Can also choose other line, such as single line or line has been converted to an polyline, to offset making a rectangular or square, rectangular or square length is the length of a line segment, the width is offset distance input, but not to delete the original choice of primitives
    b.If polyline with R, The segment offset are not accessible. The commandline prompt:Picked segment is curved - unable to offset this kind of segment. If polyline with chamfer, The result is not ideal, The result is wrong.
 2.Complete offset-ulge:
   a.Why if the polyline with chamfer , the results of chamfer distance (value) changes, Can be like fillet, Don't change?
   b. When there is Original and offseted pline don't have the same number of vertices, R value or C value that if value is less than zero, can automatically send offseted pline angle corresponding to 0 value to deal with.   

ribarm

  • Water Moccasin
  • Posts: 2126
  • Marko Ribar, architect
Re: How to Creating the offset
« Reply #11 on: October 24, 2013, 10:17:51 AM »
1.a Intersection option works like it was described in request... For multiple segment selection, you'll have to repeat command on returned pline of previous operation...
1.b Curved segments are impossible to offset with this option - result is not predictable if it's not the same as standard offset operation, but then again you can't offset just that single curved segment - you have to operate on complete pline...
Only 2.a I did understood, but it's also impossible to realize... We don't know on what segment would chamfer situation be reflected when "Complete" offset operation is chosen... Pline arcs are all treated the same way if "Bulge" are to be preserved - this can't be reflected on straight segments...
2.b When original and offset pline don't have the same number of vertices it's unpredictable how would fillet operation be performed for curved segments - preserve "Bulge" option is chosen, so this situation is refused from consideration in processing this option...

M.R.
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

2e4lite

  • Guest
Re: How to Creating the offset
« Reply #12 on: October 28, 2013, 10:39:47 AM »
Hi ribarm,
    Complete offset-bulge :Why when The  graphic which will offset display are not all in the window, the size of R will change?