Author Topic: Dynamic Offset  (Read 43080 times)

0 Members and 1 Guest are viewing this topic.

Lee Mac

  • Seagull
  • Posts: 12753
  • London, England
Re: Dynamic Offset
« Reply #75 on: February 26, 2010, 11:12:40 AM »
Evgeniy - fantastic idea to use inters, makes the problem much simpler  8-)

LE3

  • Guest
Re: Dynamic Offset
« Reply #76 on: February 26, 2010, 11:29:48 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-)
I see you started to hide your ideas, great move :)

Lee Mac

  • Seagull
  • Posts: 12753
  • London, England
Re: Dynamic Offset
« Reply #77 on: February 26, 2010, 11:31:51 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-)
I see you started to hide your ideas, great move :)


I just like a have a bit more ownership on some programs - if I have spent a bit more time on them.

ElpanovEvgeniy

  • Water Moccasin
  • Posts: 1569
  • Moscow (Russia)
Re: Dynamic Offset
« Reply #78 on: February 26, 2010, 12:14:51 PM »
Evgeniy, I have a question,

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

This debris was left after the stage of writing ...

Lee Mac

  • Seagull
  • Posts: 12753
  • London, England
Re: Dynamic Offset
« Reply #79 on: February 26, 2010, 12:49:17 PM »
Evgeniy, I have a question,

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

This debris was left after the stage of writing ...

Ok I see  :-)

wizman

  • Bull Frog
  • Posts: 287
Re: Dynamic Offset
« Reply #80 on: February 26, 2010, 02:42:34 PM »
Good clean solution Elpanov, but having minor bug if first segment is an arc.

ElpanovEvgeniy

  • Water Moccasin
  • Posts: 1569
  • Moscow (Russia)
Re: Dynamic Offset
« Reply #81 on: February 26, 2010, 04:37:32 PM »
Good clean solution Elpanov, but having minor bug if first segment is an arc.

My program, only a demonstration of one approach to solving the problem.
I do not have enough time to write the final function.

Lee Mac

  • Seagull
  • Posts: 12753
  • London, England
Re: Dynamic Offset
« Reply #82 on: February 26, 2010, 04:57:51 PM »
Its a shame that LISP does not have a 'remove_last' function, all those reverse's can't do much for performance...  :-(

Ее жаль, что Лисп не имеет функции "remove_last ', все эти обратное не может многое сделать для выполнения ...

qjchen

  • Bull Frog
  • Posts: 285
  • Best wishes to all
Re: Dynamic Offset
« Reply #83 on: February 26, 2010, 06:57:20 PM »
I can not get an error on your description ...
autocad 2008 en (sp 1)

Evgeiny, I am still use Autocad 2004, maybe this cause the error.

It seems that I should upgrade my acad version~~
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 #84 on: February 27, 2010, 12:32:35 AM »
Evgeiny, I am still use Autocad 2004, maybe this cause the error.

It seems that I should upgrade my acad version~~

Hello, Chen!
Today, I will set the program to work in acad 2004.

ElpanovEvgeniy

  • Water Moccasin
  • Posts: 1569
  • Moscow (Russia)
Re: Dynamic Offset
« Reply #85 on: February 27, 2010, 01:04:22 AM »
Code: [Select]
(defun c:ofss (/ E G O P1 P2 V1 V2 V3)
              ;|
*************************************************************************************************
*
* by ElpanovEvgeniy 26.02.2010
*
* ----------------
* 27.02.2010 8:30
* fix bug for acad 2004 (vlax-curve-getFirstDeriv e (vlax-curve-getEndParam e))
* ----------------
* 27.02.2010 8:55
* fix bug for first arc segment
*************************************************************************************************

 |;
 (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 (1- (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.5))
               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
 (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)
)
« Last Edit: February 27, 2010, 01:41:18 AM by ElpanovEvgeniy »

wizman

  • Bull Frog
  • Posts: 287
Re: Dynamic Offset
« Reply #86 on: February 27, 2010, 01:07:58 AM »
Outstanding Sir, thanks for Sharing your solution.

ElpanovEvgeniy

  • Water Moccasin
  • Posts: 1569
  • Moscow (Russia)
Re: Dynamic Offset
« Reply #87 on: February 27, 2010, 01:29:47 AM »
Many thanks!  :-)

Atwist

  • Guest
Re: Dynamic Offset
« Reply #88 on: February 27, 2010, 08:05:46 AM »
Hello ElpanovEvgeniy,

I have load your LISP but I have a problem, what does this mean.
Sorry but my knowledge of lisp is nil.

sceenshot have attached

qjchen

  • Bull Frog
  • Posts: 285
  • Best wishes to all
Re: Dynamic Offset
« Reply #89 on: February 27, 2010, 10:31:38 AM »
Thanks Evgeniy.

Now it works very good in Autocad 2004, and also good for the first segment arc situation~
http://qjchen.mjtd.com
My blog http://chenqj.blogspot.com (Chinese, can be translate into English)