Author Topic: Dynamic Offset  (Read 43048 times)

0 Members and 1 Guest are viewing this topic.

GDF

  • Water Moccasin
  • Posts: 2072
Re: Dynamic Offset
« Reply #60 on: December 16, 2009, 09:59:10 AM »
Lee

Love your routine.
I would add to your routine, temporarly color changing for all offset entities upon selection.
Why is there never enough time to do it right, but always enough time to do it over?
BricsCAD 2020x64 Windows 10x64

Lee Mac

  • Seagull
  • Posts: 12752
  • London, England
Re: Dynamic Offset
« Reply #61 on: December 16, 2009, 10:02:45 AM »
Do you mean the entities that are being offset - the objects that are moving with the cursor?

Its a good idea, but I fear that it may be confusing as the user can change the colours in the Dialog, and so what they see onscreen would not be a true reflection of the settings in the dialog.

Perhaps I could add a setting to allow the user to press shift to highlight the offset entities?

Lee

nivuahc

  • Guest
Re: Dynamic Offset
« Reply #62 on: December 16, 2009, 10:57:41 AM »
Lee,

That's one nice routine there, buddy.  :mrgreen:

Only minor tick that I found... check out the screenshot

Lee Mac

  • Seagull
  • Posts: 12752
  • London, England
Re: Dynamic Offset
« Reply #63 on: December 16, 2009, 11:07:12 AM »
Thanks nivuahc :-)

I thought this might come up... its due to the direction in which the lines are drawn - after reversing the direction:


Lee Mac

  • Seagull
  • Posts: 12752
  • London, England
Re: Dynamic Offset
« Reply #64 on: December 18, 2009, 10:38:00 AM »
I have updated the code in the first post to Version 2.0 to includes Gary's [GDF] idea to highlight the offset entities, among other bug fixes.

The highlight is Blue, and will override the colour settings as specified in the dialog. The user must have Express Tools installed to be able to use this SHIFT option.

Enjoy!

Lee

« Last Edit: December 19, 2009, 03:10:36 PM by Lee Mac »

qjchen

  • Bull Frog
  • Posts: 285
  • Best wishes to all
Re: Dynamic Offset
« Reply #65 on: February 20, 2010, 12:22:59 AM »
Hi, lee mac, very cool function.

and now, I am thinking about the following gif picture, I am not sure how to realize this function

could you help me to solve it :) thank you

I search , and get some info

1. in geotools, there is this function
http://www.4d-technologies.com/geotools/manual/polyline_tool_set_2.htm

2. gile do the similar work, he get one of the segment to offset
http://www.theswamp.org/index.php?topic=21933.0

I think maybe the line segment can be solved, but as for relate about arc segment, it will be more difficult.
http://qjchen.mjtd.com
My blog http://chenqj.blogspot.com (Chinese, can be translate into English)

Lee Mac

  • Seagull
  • Posts: 12752
  • London, England
Re: Dynamic Offset
« Reply #66 on: February 20, 2010, 07:34:47 AM »
Hi Chen,

Thanks for your compliments  :-)

I believe what you are requesting could be created, but yes, it may be difficult in some cases - I shall have a stab at it when I get a minute  :-)

Lee

ElpanovEvgeniy

  • Water Moccasin
  • Posts: 1569
  • Moscow (Russia)
Re: Dynamic Offset
« Reply #67 on: February 26, 2010, 10:06:03 AM »
My version:

Code: [Select]
(defun c:ofss (/ E G O P1 P2 V1 V2 V3)
 (progn (setq e  (entsel)
              p1 (cadr e)
              e  (car e)
              p1 (fix (vlax-curve-getParamAtPoint e (vlax-curve-getClosestPointTo e p1)))
              o  (vlax-ename->vla-object e)
        ) ;_  setq
        (if (= 1 (cdr (assoc 70 (entget e))))
         (cond ((zerop p1)
                (setq p2 (1+ p1)
                      v1 (list (vlax-curve-getPointAtParam e (vlax-curve-getEndParam e))
                               (vlax-curve-getFirstDeriv e (vlax-curve-getEndParam e))
                         ) ;_  list
                      v2 (list (vlax-curve-getPointAtParam e p1) (vlax-curve-getFirstDeriv e 0.5))
                      v3 (list (vlax-curve-getPointAtParam e p2) (vlax-curve-getFirstDeriv e 1.5))
                ) ;_  setq
               )
               ((= p1 (1- (vlax-curve-getEndParam e)))
                (setq p2 0
                      v1 (list (vlax-curve-getPointAtParam e (1- p1))
                               (vlax-curve-getFirstDeriv e (+ (1- p1) 0.5))
                         ) ;_  list
                      v2 (list (vlax-curve-getPointAtParam e p1) (vlax-curve-getFirstDeriv e (+ p1 0.5)))
                      v3 (list (vlax-curve-getPointAtParam e p2) (vlax-curve-getFirstDeriv e (+ p2 0.5)))
                ) ;_  setq
               )
               ((setq p2 (1+ p1)
                      v1 (list (vlax-curve-getPointAtParam e (1- p1))
                               (vlax-curve-getFirstDeriv e (+ (1- p1) 0.5))
                         ) ;_  list
                      v2 (list (vlax-curve-getPointAtParam e p1) (vlax-curve-getFirstDeriv e (+ p1 0.5)))
                      v3 (list (vlax-curve-getPointAtParam e p2) (vlax-curve-getFirstDeriv e (+ p2 0.5)))
                ) ;_  setq
               )
         ) ;_  cond
         (cond ((zerop p1)
                (setq p2 (1+ p1)
                      v2 (list (vlax-curve-getPointAtParam e 0) (vlax-curve-getFirstDeriv e 0))
                      v1 (list (car v2) (list (cadadr v2) (- (caadr v2)) 0.))
                      v3 (list (vlax-curve-getPointAtParam e p2) (vlax-curve-getFirstDeriv e 1.5))
                ) ;_  setq
               )
               ((= p1 (1- (vlax-curve-getEndParam e)))
                (setq p2 (vlax-curve-getEndParam e)
                      v1 (list (vlax-curve-getPointAtParam e (1- p1))
                               (vlax-curve-getFirstDeriv e (+ (1- p1) 0.5))
                         ) ;_  list
                      v2 (list (vlax-curve-getPointAtParam e p1) (vlax-curve-getFirstDeriv e (+ p1 0.5)))
                      v3 (list (vlax-curve-getPointAtParam e p2) (list (cadadr v2) (- (caadr v2)) 0.))
                ) ;_  setq
               )
               ((setq p2 (1+ p1)
                      v1 (list (vlax-curve-getPointAtParam e (1- p1))
                               (vlax-curve-getFirstDeriv e (+ (1- p1) 0.5))
                         ) ;_  list
                      v3 (list (vlax-curve-getPointAtParam e p2) (vlax-curve-getFirstDeriv e (+ p2 0.5)))
                      v2 (list (vlax-curve-getPointAtParam e p1) (vlax-curve-getFirstDeriv e (+ p1 0.5)))
                ) ;_  setq
               )
         ) ;_  cond
        ) ;_  if
 ) ;_  progn
 (while (= (car (setq g (grread nil 5 0))) 5)
  (vla-put-coordinate
   o
   p1
   (vlax-make-variant
    (vlax-safearray-fill (vlax-make-safearray 5 '(0 . 1))
                         (reverse (cdr (reverse (inters (car v1)
                                                        (mapcar '+ (car v1) (cadr v1))
                                                        (cadr g)
                                                        (mapcar '+ (cadr g) (cadr v2))
                                                        nil
                                                ) ;_  inters
                                       ) ;_  reverse
                                  ) ;_  cdr
                         ) ;_  reverse
    ) ;_  vlax-safearray-fill
   ) ;_  vlax-make-variant
  ) ;_  vla-put-coordinate
  (vla-put-coordinate
   o
   p2
   (vlax-make-variant
    (vlax-safearray-fill (vlax-make-safearray 5 '(0 . 1))
                         (reverse (cdr (reverse (inters (car v3)
                                                        (mapcar '+ (car v3) (cadr v3))
                                                        (cadr g)
                                                        (mapcar '+ (cadr g) (cadr v2))
                                                        nil
                                                ) ;_  inters
                                       ) ;_  reverse
                                  ) ;_  cdr
                         ) ;_  reverse
    ) ;_  vlax-safearray-fill
   ) ;_  vlax-make-variant
  ) ;_  vla-put-coordinate
 ) ;_  while
 (princ)
)

qjchen

  • Bull Frog
  • Posts: 285
  • Best wishes to all
Re: Dynamic Offset
« Reply #68 on: February 26, 2010, 10:16:13 AM »
Evgeniy, that is very cool
I will try to learn it

But I find that, when for a closed figure, the first segment always get error when offset

Because => at the first segment

(vlax-curve-getFirstDeriv e (vlax-curve-getEndParam e))=>nil

then the following get error.
« Last Edit: February 26, 2010, 10:22:12 AM by yuanqiu »
http://qjchen.mjtd.com
My blog http://chenqj.blogspot.com (Chinese, can be translate into English)

ElpanovEvgeniy

  • Water Moccasin
  • Posts: 1569
  • Moscow (Russia)
Re: Dynamic Offset
« Reply #69 on: February 26, 2010, 10:28:18 AM »
I can not get an error on your description ...
autocad 2008 en (sp 1)

Lee Mac

  • Seagull
  • Posts: 12752
  • London, England
Re: Dynamic Offset
« Reply #70 on: February 26, 2010, 10:39:31 AM »
All seems to work fine for me  :-)

Absolutely fantastic Evgeniy - much better than the code I attempted to create... I shall study your code.  :-)

LE3

  • Guest
Re: Dynamic Offset
« Reply #71 on: February 26, 2010, 10:48:15 AM »
nice tools !

anyone had tried them with heavy polylines? - (just tested the one Eugenio posted)

Lee Mac

  • Seagull
  • Posts: 12752
  • London, England
Re: Dynamic Offset
« Reply #72 on: February 26, 2010, 10:48:22 AM »
Evgeniy, I have a question,

why the use of 'progn' at the very start of the code? What is its purpose in this case?

LE3

  • Guest
Re: Dynamic Offset
« Reply #73 on: February 26, 2010, 10:58:08 AM »
nice tools !

anyone had tried them with heavy polylines? - (just tested the one Eugenio posted)

dynoff works - remainds me one of the commands from intergraph microstation 4.0

Lee Mac

  • Seagull
  • Posts: 12752
  • London, England
Re: Dynamic Offset
« Reply #74 on: February 26, 2010, 10:59:05 AM »
nice tools !

anyone had tried them with heavy polylines? - (just tested the one Eugenio posted)

dynoff works - remainds me one of the commands from intergraph microstation 4.0

Excellent, thanks Luis  8-)