Author Topic: segment offset ?  (Read 12345 times)

0 Members and 1 Guest are viewing this topic.

kdub

  • Mesozoic keyThumper
  • SuperMod
  • Swamp Rat
  • Posts: 1387
  • class keyThumper<T>:ILazy<T>
Re: segment offset ?
« Reply #15 on: February 19, 2009, 01:17:51 AM »
gile,
I just downloaded a copy of this ..

Very NICE !! ..  Saved lots of time :)
called Kerry in my other life

Sometimes the question is more important than the answer.
#ridesober

gile

  • Water Moccasin
  • Posts: 2275
  • Marseille, France
Re: segment offset ?
« Reply #16 on: February 19, 2009, 01:21:00 AM »
You're welcome, Kerry.
Speaking English as a French Frog

CAB

  • Global Moderator
  • Seagull
  • Posts: 10395
Re: segment offset ?
« Reply #17 on: February 19, 2009, 08:03:33 AM »
The coding is very nice and a useful routine. 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.

GDF

  • Water Moccasin
  • Posts: 2059
Re: segment offset ?
« Reply #18 on: February 19, 2009, 10:01:37 AM »
Hi,

Here's my way

EDIT: corrected a missing parent.


Gile

I just saw this and tried it out...VERY NICE. Thanks for sharing it. It will come in handy.

Gary
Why is there never enough time to do it right, but always enough time to do it over?
BricsCAD 2020x64 Windows 10x64

gile

  • Water Moccasin
  • Posts: 2275
  • Marseille, France
Re: segment offset ?
« Reply #19 on: February 19, 2009, 03:04:24 PM »
Thanks to all, you're welcome.

I'm glad you find it usefull.
Speaking English as a French Frog

alanjt

  • Needs a day job
  • Posts: 5340
  • Standby for witty remark...
Re: segment offset ?
« Reply #20 on: February 25, 2010, 09:33:21 AM »
Fantastic code, Gile; very useful. :)
Civil 3D 2019 ~ Windohz 7 64bit
Dropbox

rayakmal

  • Newt
  • Posts: 39
Re: segment offset ?
« Reply #21 on: December 27, 2019, 02:31:56 AM »
Thanks to all, you're welcome.

I'm glad you find it usefull.

Your program is very useful.

My main problem is, polyline that I need to offset resides inside a block.
E.q: When I working with a MEP Drawing, I need to draw a water pipeline, offsetting a parcel line that resides inside site plan block.
 :reallysad:

Lee Mac

  • Seagull
  • Posts: 12499
  • London, England
Re: segment offset ?
« Reply #22 on: December 27, 2019, 06:13:35 AM »
My main problem is, polyline that I need to offset resides inside a block.

You could use NCOPY first.

rayakmal

  • Newt
  • Posts: 39
Re: segment offset ?
« Reply #23 on: December 29, 2019, 08:52:42 PM »
My main problem is, polyline that I need to offset resides inside a block.

You could use NCOPY first.

Wow. I didn't realize Ncopy means Nested Copy  :-)
I'm an old dog, hard to learn new tricks, I meant, when upgrading I don't really learn all new commands.
Thanks. you saved my life again.

BIGAL

  • Swamp Rat
  • Posts: 769
  • 30 + years of using Autocad
Re: segment offset ?
« Reply #24 on: December 30, 2019, 12:39:49 AM »
Would using a xref be better way than "site plan block" as you can edit the xref pretty simply.
A man who never made a mistake never made anything

rayakmal

  • Newt
  • Posts: 39
Re: segment offset ?
« Reply #25 on: January 01, 2020, 01:40:56 PM »
Would using a xref be better way than "site plan block" as you can edit the xref pretty simply.

We don't use an xref extensively. The main reason is our working folders can't be accessed freely by other divisions, when other divisions need our drawings we need to copy all the necessary drawings to a shared folder and sometimes forget to copy the xref files.

ahsattarian

  • Newt
  • Posts: 61
Re: segment offset ?
« Reply #26 on: November 30, 2020, 08:19: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. )