TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: Lee Mac on October 18, 2009, 07:58:14 AM

Title: Dynamic Offset
Post by: Lee Mac on October 18, 2009, 07:58:14 AM
Was experimenting with this idea..., perhaps it might be useful to some of you, (possibly those doing piping?) - let me know what you think  :wink:

(http://www.theswamp.org/screens/leemac/DynOff.gif)

(http://www.theswamp.org/screens/leemac/DynOff%202.0.gif)

Settings Dialog:

(http://www.theswamp.org/screens/leemac/DynOff%20Settings%20V1.6.png)

Code: [Select]
;;;`,,`,,`,,`,,`,,`,,;;;
;;;,,`,,`,,`,,`,,`,,`;;;
;;                                                                               ;;
;;                        --=={  Dynamic Offset  }==--                           ;;
;;                                                                               ;;
;;  Allows the user to dynamically offset multiple objects simultaneously, by    ;;
;;  either specifying the offset distance via mouse-click, or at the             ;;
;;  command-line. The command-line default will remember the last offset entered ;;
;;  by the user.                                                                 ;;
;;                                                                               ;;
;;  Object Snap functionality is retained, and the on-screen offset distance is  ;;
;;  determined by the nearest object in the offset selection set.                ;;
;;                                                                               ;;
;;  The user can use the +/- keys to change the number of offsets, or,           ;;
;;  alternatively, the user can press 'N' and specify the number of offsets      ;;
;;  directly.                                                                    ;;
;;                                                                               ;;
;;  The user can also press 'S' during object offset to change the layer,        ;;
;;  linetype, lineweight, and colour of the resultant offset objects.            ;;
;;                                                                               ;;
;;  By pressing TAB the user can switch modes between offsetting both sides or   ;;
;;  just one side of an object.                                                  ;;
;;                                                                               ;;
;;  The toggle for retaining or deleting the original Objects can be altered by  ;;
;;  pressing 'D'. The user can hold SHIFT to highlight the offset entities.      ;;
;;                                                                               ;;
;;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=;;
;;                                                                               ;;
;;  FUNCTION SYNTAX:  DYNOFF                                                     ;;
;;                                                                               ;;
;;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=;;
;;                                                                               ;;
;;  AUTHOR:                                                                      ;;
;;                                                                               ;;
;;  Copyright Lee McDonnell, October 2009. All Rights Reserved.                ;;
;;                                                                               ;;
;;      { Contact: Lee Mac @ TheSwamp.org, CADTutor.net }                        ;;
;;                                                                               ;;
;;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=;;
;;                                                                               ;;
;;  WITH THANKS TO:                                                              ;;
;;                                                                               ;;
;;         Elpanov Evgeniy           ~~   Code for GrRead OSnap Symbols.     ;;
;;...............................................................................;;
;;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=;;
;;                                                                               ;;
;;  VERSION:                                                                     ;;
;;                                                                               ;;
;;     1.0   ~~   17th October 2009   ~~   First Release                    ;;
;;...............................................................................;;
;;     1.1   ~~   19th October 2009   ~~   Added Object Snap functionality  ;;
;;...............................................................................;;
;;     1.2   ~~   20th October 2009   ~~   Added Multiple Offset Option     ;;
;;...............................................................................;;
;;     1.3   ~~   21st October 2009   ~~   Updated Object Snap Coding       ;;
;;...............................................................................;;
;;     1.4   ~~   23rd October 2009   ~~   Updated Offset Number Options    ;;
;;                                             Added option to specify Offset   ;;
;;                                              factor.                          ;;
;;...............................................................................;;
;;     1.5   ~~   29th October 2009   ~~   Added Settings Dialog.           ;;
;;...............................................................................;;
;;     1.6   ~~   8th December 2009   ~~   Added option to only offset      ;;
;;                                              object on one side.              ;;
;;...............................................................................;;
;;     1.7   ~~  10th December 2009   ~~   Added option to delete original  ;;
;;                                              objects.                         ;;
;;...............................................................................;;
;;     1.8   ~~  14th December 2009   ~~   Added ability to offset to the   ;;
;;                                              center of two objects.           ;;
;;...............................................................................;;
;;     1.9   ~~  16th December 2009   ~~   Modified method for spacing      ;;
;;                                              multiple offsets.                ;;
;;                                             Improved OSnap Coding.           ;;
;;...............................................................................;;
;;     2.0   ~~  18th December 2009   ~~   Added colour change for offset   ;;
;;                                              entities.                        ;;
;;                                             Fixed Bug when using Offset      ;;
;;                                              Factor.                          ;;
;;...............................................................................;;
;;                                                                               ;;
;;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=;;
;;                                                                               ;;
;;;`,,`,,`,,`,,`,,`,,;;;
;;;,,`,,`,,`,,`,,`,,`;;;

[ Code updated to Version 2.0 ]

Code available here (http://lee-mac.com/dynamicoffset.html).
Title: Re: Dynamic Offset
Post by: Crank on October 18, 2009, 12:19:41 PM
Lee,

I like how it's working, but as it is this is almost useless to me. In the dynamic part only a through point is possible, but osnaps are not working.
I think it would also a good idea to have a list with fixed distances. Pressing the CTRL-key would use a picked distance (like relaxed constrains) and if not pressed it would use the fixed distances of the list.
Title: Re: Dynamic Offset
Post by: alanjt on October 18, 2009, 12:49:07 PM
I was thinking the same thing. Offsetting is such a specific task.
Title: Re: Dynamic Offset
Post by: qjchen on October 19, 2009, 01:00:47 AM
:)

I will also wish Autodesk can directly support grread with osnap.

Here, Evgeniy also write the similar function :)

http://www.theswamp.org/index.php?topic=12692.0
Title: Re: Dynamic Offset
Post by: alanjt on October 19, 2009, 01:13:24 AM
:)

I will also wish Autodesk can directly support grread with osnap.

Wouldn't that be nice. :)
Title: Re: Dynamic Offset
Post by: Lee Mac on October 19, 2009, 07:07:51 AM
Thanks for the feedback guys, I realise that with most GrRead programs, OSnap is needed, and I will consider incorporating it into this example in the near future.

You can specify an offset at the command line, and it will also remember the last entry as default. I wanted to make it as generic as possible, but I shall consider your list idea.  :wink:

Thanks

Lee
Title: Re: Dynamic Offset
Post by: Andrea on October 19, 2009, 01:29:32 PM
Hi Lee...

another nice one ! congrat !

Idea:
It will be nice to have the possibility to have choice between offset 1 or 2 sides of the object.

Also,..there's more from my head.. :roll:
(see pic)

Title: Re: Dynamic Offset
Post by: Lee Mac on October 20, 2009, 07:17:01 AM
Thanks Andrea - some nice ideas there indeed... I shall see what I can add to it when time permits  :wink:

Thanks for the suggestions, I also have a few more ideas of my own for this one  :wink:
Title: Re: Dynamic Offset
Post by: Lee Mac on October 20, 2009, 07:28:16 AM
I have updated the code in the first post to include Version 1.1, hopefully incorporating the all-important Object Snap!  :angel:
Title: Re: Dynamic Offset
Post by: VovKa on October 20, 2009, 01:11:53 PM
Lee, the following link to EvgeniyElpanov's code may be helpful
http://www.caduser.ru/forum/index.php?PAGE_NAME=message&FID=44&TID=36237&MID=205806#message205806
Title: Re: Dynamic Offset
Post by: alanjt on October 20, 2009, 01:19:43 PM
I have updated the code in the first post to include Version 1.1, hopefully incorporating the all-important Object Snap!  :angel:
The osnap marker is displaying a million miles (km, since your british  :wink:) away.
Title: Re: Dynamic Offset
Post by: alanjt on October 20, 2009, 01:25:01 PM
Lee, the following link to EvgeniyElpanov's code may be helpful
http://www.caduser.ru/forum/index.php?PAGE_NAME=message&FID=44&TID=36237&MID=205806#message205806
Now that is impressive.  :lol:
Title: Re: Dynamic Offset
Post by: Lee Mac on October 21, 2009, 05:16:35 AM
I have updated the code in the first post to include Version 1.1, hopefully incorporating the all-important Object Snap!  :angel:
The osnap marker is displaying a million miles (km, since your british  :wink:) away.

miles... since I'm british...  :-P

It does work fine for me, but I shall look into it all the same  :-)
Title: Re: Dynamic Offset
Post by: Lee Mac on October 21, 2009, 05:29:45 AM
I have updated the code to Version 1.2, this will not yet correct the oSnap difficulties you are having, but there is a new option to offset multiple times (by pressing +/-).  ;-)

Just out of interest, are you all experiencing the problems that Alan reported?

Lee
Title: Re: Dynamic Offset
Post by: alanjt on October 21, 2009, 10:27:07 AM
Lee, was the method for entering/backspacing a number value one of your ideas? That is freaking brilliant. I'm totally stealing that.
Title: Re: Dynamic Offset
Post by: Lee Mac on October 21, 2009, 01:09:57 PM
Lee, was the method for entering/backspacing a number value one of your ideas? That is freaking brilliant. I'm totally stealing that.

Thanks Alan  :-)

The number entry was mine - the backspace was..sort of...  I picked up a few bits from CAB  :roll:

Title: Re: Dynamic Offset
Post by: Lee Mac on October 21, 2009, 01:14:42 PM
I have updated the code in the first post to Version 1.3  -- hopefully the Object Snap now functions correctly!

My thanks go to ElpanovEvgeniy for his OSnap GrVecs lists.   ;-)

Lee
Title: Re: Dynamic Offset
Post by: Lee Mac on October 21, 2009, 01:21:54 PM
Oops! Minor bug, code updated  :oops:
Title: Re: Dynamic Offset
Post by: alanjt on October 21, 2009, 01:47:46 PM
Lee, was the method for entering/backspacing a number value one of your ideas? That is freaking brilliant. I'm totally stealing that.

Thanks Alan  :-)

The number entry was mine - the backspace was..sort of...  I picked up a few bits from CAB  :roll:


Well, I like it. :)
Title: Re: Dynamic Offset
Post by: Lee Mac on October 22, 2009, 06:53:11 AM
Lee, was the method for entering/backspacing a number value one of your ideas? That is freaking brilliant. I'm totally stealing that.

Thanks Alan  :-)

The number entry was mine - the backspace was..sort of...  I picked up a few bits from CAB  :roll:


Well, I like it. :)

Thanks Alan,

Does the OSnap now function correctly for you now with this new version?
Title: Re: Dynamic Offset
Post by: alanjt on October 22, 2009, 08:19:18 AM
Lee, was the method for entering/backspacing a number value one of your ideas? That is freaking brilliant. I'm totally stealing that.

Thanks Alan  :-)

The number entry was mine - the backspace was..sort of...  I picked up a few bits from CAB  :roll:


Well, I like it. :)

Thanks Alan,

Does the OSnap now function correctly for you now with this new version?
:)

Yeah, it works properly now.
Title: Re: Dynamic Offset
Post by: mushrat on October 22, 2009, 09:54:30 AM
If I try to offset to a parallel line with any osnap option (say perpendicular) it displays the "center" osnap icon and the offset line doesn't snap to the parallel line. Otherwise pretty neat.
Title: Re: Dynamic Offset
Post by: Lee Mac on October 22, 2009, 10:07:14 AM
If I try to offset to a parallel line with any osnap option (say perpendicular) it displays the "center" osnap icon and the offset line doesn't snap to the parallel line. Otherwise pretty neat.

Thanks Mushrat, will investigate your problem and see what is happening  :wink:

Lee
Title: Re: Dynamic Offset
Post by: Lee Mac on October 22, 2009, 10:08:01 AM
Lee, was the method for entering/backspacing a number value one of your ideas? That is freaking brilliant. I'm totally stealing that.

Thanks Alan  :-)

The number entry was mine - the backspace was..sort of...  I picked up a few bits from CAB  :roll:


Well, I like it. :)

Thanks Alan,

Does the OSnap now function correctly for you now with this new version?
:)

Yeah, it works properly now.

Excellent, always good to hear. The only difference was a use of "trans"  :oops:
Title: Re: Dynamic Offset
Post by: alanjt on October 22, 2009, 10:57:56 AM
Lee, was the method for entering/backspacing a number value one of your ideas? That is freaking brilliant. I'm totally stealing that.

Thanks Alan  :-)

The number entry was mine - the backspace was..sort of...  I picked up a few bits from CAB  :roll:


Well, I like it. :)

Thanks Alan,

Does the OSnap now function correctly for you now with this new version?
:)

Yeah, it works properly now.

Excellent, always good to hear. The only difference was a use of "trans"  :oops:
How bizarre, I was in normal World UCS. Nice routine, wish I had a use for it.
Title: Re: Dynamic Offset
Post by: ElpanovEvgeniy on October 22, 2009, 11:19:21 AM
I have updated the code in the first post to Version 1.3  -- hopefully the Object Snap now functions correctly!

My thanks go to ElpanovEvgeniy for his OSnap GrVecs lists.   ;-)

Lee

Thanks! :)

It is the report on small research of possibilities LISP.
The further development of the program, cannot be published at a forum.
But an initial research part, I have decided to publish.
I hoped, the code will help with the future to followers...
Title: Re: Dynamic Offset
Post by: alanjt on October 22, 2009, 11:22:50 AM
I have updated the code in the first post to Version 1.3  -- hopefully the Object Snap now functions correctly!

My thanks go to ElpanovEvgeniy for his OSnap GrVecs lists.   ;-)

Lee

Thanks! :)

It is the report on small research of possibilities LISP.
The further development of the program, cannot be published at a forum.
But an initial research part, I have decided to publish.
I hoped, the code will help with the future to followers...
Well, we ALL thank you for it. :)
Title: Re: Dynamic Offset
Post by: ElpanovEvgeniy on October 22, 2009, 11:28:16 AM
Lee, the following link to EvgeniyElpanov's code may be helpful
http://www.caduser.ru/forum/index.php?PAGE_NAME=message&FID=44&TID=36237&MID=205806#message205806

I hasten to add, the program has been published at this forum!
Examples of usage GRREAD - let's share (http://www.theswamp.org/index.php?topic=12813.msg157794#msg157794)
Title: Re: Dynamic Offset
Post by: Hugo on October 22, 2009, 01:06:01 PM
Hello Lee
<br>
<br> For me the osnap not working the way I think.
<br>
<br> (Attachment: See the movie)

Bei mir funktioniert der OFang nicht so wie ich glaube.

Danke

Title: Re: Dynamic Offset
Post by: Hugo on October 22, 2009, 01:12:11 PM
Hallo Lee

Sollte so ein Schemata werden

Hello Lee
<br>
<br> If any such schemes are

Title: Re: Dynamic Offset
Post by: Lee Mac on October 25, 2009, 08:58:14 AM
Thanks for the bug report Hugo -

I have updated the first post to Version 1.4

The user will now be able to specify an Offset factor, and also use 'N' to specify the Offset Number directly.  :-)

Have fun,

Lee
Title: Re: Dynamic Offset
Post by: Hugo on October 26, 2009, 04:42:56 AM
Hallo Lee

Danke funktioniert jetzt super  :-) :-) :-)

Title: Re: Dynamic Offset
Post by: Lee Mac on October 26, 2009, 09:10:12 AM
Excellent Hugo  :-)
Title: Re: Dynamic Offset
Post by: Lee Mac on November 01, 2009, 11:22:36 AM
Major Update!

I have included a Settings Dialog, so that you can change the properties of the objects that are offset   8-)

See the first post for Version 1.5
Title: Re: Dynamic Offset
Post by: Lee Mac on December 08, 2009, 08:04:00 PM
Following a suggestion from one of the guys over at CADTutor, I have updated the code in the first post to Version 1.6, the user may now press TAB to choose to offset either side of the object, or both sides simultaneously.

As always, your comments and suggestions are welcome :-)

Enjoy!

Lee
Title: Re: Dynamic Offset
Post by: t-bear on December 09, 2009, 05:14:05 PM
This is great Lee...can use it on P&ID and electrical schematics.  Thanks for all the work on it...works a treat!
Title: Re: Dynamic Offset
Post by: Lee Mac on December 09, 2009, 05:34:07 PM
This is great Lee...can use it on P&ID and electrical schematics.  Thanks for all the work on it...works a treat!

Thanks T-Bear, your comments are much appreciated - I'm glad you like it :-)
Title: Re: Dynamic Offset
Post by: GDF on December 10, 2009, 10:06:25 AM
Great tool Lee

I would suggest adding the option of deleting the original selected entity.
I have one in my toolbag for a double offset which deletes the original, that I use all of the time.

Thanks again for sharing it.
Title: Re: Dynamic Offset
Post by: Lee Mac on December 10, 2009, 10:23:40 AM
Great tool Lee

I would suggest adding the option of deleting the original selected entity.
I have one in my toolbag for a double offset which deletes the original, that I use all of the time.

Thanks again for sharing it.

Nice idea Gary - I shall look to implement this :-)

Thanks  8-)

Lee
Title: Re: Dynamic Offset
Post by: Lee Mac on December 10, 2009, 11:37:04 AM
I have updated the code in the first post to Version 1.7 to include Gary's Suggestion  ;-)

The toggle for deleting/retaining the original objects can be changed by pressing 'D'.

Enjoy!

Lee
Title: Re: Dynamic Offset
Post by: GDF on December 10, 2009, 02:09:42 PM
Wow, that was fast.

So the source button and image button are for changing color to other than by layer...shame on you. :pissed:
Title: Re: Dynamic Offset
Post by: Lee Mac on December 10, 2009, 06:27:26 PM
Wow, that was fast.

So the source button and image button are for changing color to other than by layer...shame on you. :pissed:

Hehe... gotta provide people with the tools to break the company standards.. makes life much more fun :P
Title: Re: Dynamic Offset
Post by: GDF on December 11, 2009, 10:10:35 AM
Lee, here is another request.
(1)How about adding offset of a segment of a polyline...

;; http://www.theswamp.org/index.php?topic=21933.0;all

;; OFSEGS -Gilles Chanteau- 2008/03/26
;; Offsets the selected segments of lwpolyline
;; Joined segments are offseted in a single lwpolyline
;; Keeps arcs and widthes
;; Works whatever the current UCS and the pline OCS and elevation

(2)How about offset to center...the center between two selected lines. Here is an old routine...
;;;OFCTR.LSP  Offset Line to Center (Dean Saadallah)
;;;10/12/97
(defun c:OFC (/ OS CL CD LAYR PT1 PT2 PT3 DST1 DST2)
  (setq OS (getvar "OSMODE"))
  (setq CL (getvar "CLAYER"))
  (setq CD (getvar "CMDECHO"))
  (setvar "CMDECHO" 0)
  (princ "\n* Target Layer? <")
  (prin1 (read CL))
  (setq LAYR (getstring ">:"))
  (if (equal LAYR "")
    (setq LAYR (getvar "CLAYER"))
  )
  (setvar "OSMODE" 512)
  (setq PT1 (getpoint "\n* Pick First Line *"))
  (setq PT2 PT1)
  (setvar "OSMODE" 128)
  (setq PT3 (getpoint PT1 "\n* Pick Second Line *"))
  (setvar "OSMODE" 0)
  (setq DST1 (distance PT1 PT3))
  (setq DST2 (/ DST1 2))
  (command ".offset" DST2 PT1 PT3 "")
  (command "CHPROP" "L" "" "LA" LAYR "LT" "BYLAYER" "C" "BYLAYER" "")
  (setvar "OSMODE" OS)
  (setvar "CMDECHO" CD)
) ;_ end of defun
Title: Re: Dynamic Offset
Post by: Lee Mac on December 11, 2009, 10:20:20 AM
Nice idea Gary, and some fantastic code from Gile (as always) - but it may be difficult to implement this, as my program prompts for a SelectionSet of objects, and then proceeds to offset - I suppose I would have to change this initial prompt and add an option to select segments in addition to the other objects...  Quite a task - I shall think about it...  ;-)

But thanks for the suggestion all the same  :-)

Lee
Title: Re: Dynamic Offset
Post by: Lee Mac on December 11, 2009, 10:22:48 AM
(2)How about offset to center...the center between two selected lines. Here is an old routine...

This may be easier to implement - I shall see what I can do  :-)

Again, thanks for the suggestions - good ideas are hard to come by... :P

Lee
Title: Re: Dynamic Offset
Post by: GDF on December 11, 2009, 10:48:55 AM
Here is 2 versions to play with for offset to center between 2 lines...
Code: [Select]

;;; http://www.theswamp.org/index.php?topic=29537.0
;;; Patrick_35, GILE
;;; MsgBox
(defun ARCH:MsgBox2 (title buttons message time / return WshShell)
  (setq WshShell (vlax-create-object "WScript.Shell"))
  (setq return (vlax-invoke
  WshShell
  'Popup
  message
  time
  title
  (itoa buttons)
)
  )
  (vlax-release-object WshShell)
  return
)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Select Function ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun ARCH:SELECT-1  ()
  (while (or (not (setq sel1 (entsel "\n* Select Object *")))
             (and (/= (cdr (assoc 0 (setq ent (entget (car sel1))))) "LINE")
                  (/= (cdr (assoc 0 (setq ent (entget (car sel1))))) "POLYLINE")
                  (/= (cdr (assoc 0 (setq ent (entget (car sel1))))) "LWPOLYLINE")))
    (ARCH:MsgBox2 " Arch Program : Error" 16 "
     Selection Error Message
--------------------------------------------------------------------------------------------
     You did not Select Anything. Please try again." 4))
  (princ))
(defun ARCH:SELECT-2  ()
  (while (or (not (setq sel2 (entsel "\n* Select Object *")))
             (and (/= (cdr (assoc 0 (setq ent (entget (car sel2))))) "LINE")
                  (/= (cdr (assoc 0 (setq ent (entget (car sel2))))) "POLYLINE")
                  (/= (cdr (assoc 0 (setq ent (entget (car sel2))))) "LWPOLYLINE")))
    (ARCH:MsgBox2 " Arch Program : Error" 16 "
     Selection Error Message
--------------------------------------------------------------------------------------------
     You did not Select Anything. Please try again." 4))
  (princ))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;; Center Between Lines Function ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun ARCH:CEN-BETWEEN-LIN  (/ p1 p2 p3 obj1 obj2)
  (ARCH:SELECT-1)
  (setvar "osmode" 0)
  ;;(princ "\n* Single wall fill *") 
  (setq obj1 (car sel1))
  (setq p1 (car (cdr sel1)))
  (ARCH:SELECT-2)
  (setq obj2 (car sel2))
  (setq p2 (car (cdr sel2)))
  (command "dist" "nea" p1 "per" p2)
  (setq dist_1 (getvar "distance"))
  (setq dist_2 (/ dist_1 2.0))
  (setq x (/ (+ (car p1) (car p2)) 2))
  (setq y (/ (+ (cadr p1) (cadr p2)) 2))
  (setq z (/ (+ (caddr p1) (caddr p2)) 2))
  (setq p3 (list x y z))
  (command ".offset" dist_2 obj1 p3 "")
  (princ))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; New Wall Fill Routine ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun ARCH:CEN-BETWEEN-LIN2  (/ a b p1 p2 pt ent1 ent2 ent3)
  ;;(if (not ARCH:GetIntersect)(load (strcat ARCH#UTIF "ARCH_GET_INTERSECT")))
  (defun CEN-BETWEEN-LIN-DOIT  ()
    (command "line" a b "")
    (setq ent1 (entlast))
    (cond (SS1
           (repeat (sslength SS1)
             (setq ent2 (cdr (assoc -1 (entget (ssname SS1 0)))))
             (setq p1 (ARCH:GetIntersect ent1 ent2))
             (setq ent3 (cdr (assoc -1 (entget (ssname SS1 1)))))
             (setq p2 (ARCH:GetIntersect ent1 ent3)))))
    (command "dist" "nea" p1 "per" p2)
    (setq dist_1 (getvar "distance"))
    (setq dist_2 (/ dist_1 2.0))
    (setq x (/ (+ (car p1) (car p2)) 2))
    (setq y (/ (+ (cadr p1) (cadr p2)) 2))
    (setq z (/ (+ (caddr p1) (caddr p2)) 2))
    (setq p3 (list x y z))
    (command ".offset" dist_2 ent2 p3 "")
    (entdel ent1)
    (princ))
  (setvar "orthomode" 0)
  (setvar "osmode" 0)
  ;;(initget 1)
  (setq a (getpoint "\n* Draw Crossing Line *"))
  (initget 33)
  (setq b (getpoint a))
  (setq pt (list a b))
  (setq SS1 (ssget "F" pt '((0 . "LINE"))))
  (cond
    ((or (= SS1 nil) (/= (sslength SS1) 2))
     (ARCH:MsgBox2 " Arch Program : Error" 16 "
     Selection Error Message
--------------------------------------------------------------------------------------------
     Invalid Selection...either you selected nothing, a
     double line <line on top of a line>, or a polyline.
     If a double line, delete one, or if a polyline
     change it to a line. Now you can try again..." 4))
    ((CEN-BETWEEN-LIN-DOIT)))
  (princ))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;; Get the Intersection Function ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;One of the better ways is to use the IntersectWith method:
;;;Written by R. Robert Bell
;;;Takes either ENames or Objects, returns list or nil.
(defun ARCH:GetIntersect (obj1 obj2)
  (foreach
         obj '(obj1 obj2)
    (if (= (type (eval obj)) 'ENAME)
      (set obj
           (vlax-EName->vla-Object
             (eval obj)
           )
      )
    )
  )
  (vlax-Invoke obj1 'IntersectWith obj2 acExtendBoth)
)
Title: Re: Dynamic Offset
Post by: Lee Mac on December 11, 2009, 10:55:45 AM
Thanks Gary  :-)
Title: Re: Dynamic Offset
Post by: Lee Mac on December 14, 2009, 09:45:43 AM
I have updated the code in the first post to Version 1.8. This version incorporates Gary's idea to allow the user to offset to the center of two objects.

Enjoy!

Lee
Title: Re: Dynamic Offset
Post by: t-bear on December 14, 2009, 09:53:00 AM
This routine is getting sweeter all the time!  Thanks all, and thanks Lee for getting the ball rolling.  Nice things happen when you folks put yor heads together....love this place!
Title: Re: Dynamic Offset
Post by: Lee Mac on December 14, 2009, 09:59:20 AM
Thanks t-Bear  8-)
Title: Re: Dynamic Offset
Post by: alanjt on December 14, 2009, 10:09:47 AM
Just so you know, if you select both lines, then execute centerline offset, you will get 2 lines in the center.
Title: Re: Dynamic Offset
Post by: xianaihua on December 14, 2009, 10:11:12 AM
Nice routine- I like
thanks! :love: :love:
Title: Re: Dynamic Offset
Post by: Lee Mac on December 14, 2009, 10:13:19 AM
Just so you know, if you select both lines, then execute centerline offset, you will get 2 lines in the center.

Yes - I thought this would be more consistent with the rest of the program  :-)
Title: Re: Dynamic Offset
Post by: Lee Mac on December 14, 2009, 10:13:35 AM
Nice routine- I like
thanks! :love: :love:

Thanks  xianaihua  8-)
Title: Re: Dynamic Offset
Post by: alanjt on December 14, 2009, 10:17:17 AM
Just so you know, if you select both lines, then execute centerline offset, you will get 2 lines in the center.

Yes - I thought this would be more consistent with the rest of the program  :-)
To have 2 lines on top of one another?
Title: Re: Dynamic Offset
Post by: Lee Mac on December 14, 2009, 10:20:44 AM
Just so you know, if you select both lines, then execute centerline offset, you will get 2 lines in the center.

Yes - I thought this would be more consistent with the rest of the program  :-)
To have 2 lines on top of one another?

Only if you select both lines in the first place - say you want to offset both lines to the outside...
Title: Re: Dynamic Offset
Post by: alanjt on December 14, 2009, 10:26:09 AM
Just so you know, if you select both lines, then execute centerline offset, you will get 2 lines in the center.

Yes - I thought this would be more consistent with the rest of the program  :-)
To have 2 lines on top of one another?

Only if you select both lines in the first place - say you want to offset both lines to the outside...

...but I would still want to avoid ending up with 2 lines atop one another. It's your program, I'm just making a suggestion, based on what I would change.
Title: Re: Dynamic Offset
Post by: Lee Mac on December 14, 2009, 10:37:20 AM
Just so you know, if you select both lines, then execute centerline offset, you will get 2 lines in the center.

Yes - I thought this would be more consistent with the rest of the program  :-)
To have 2 lines on top of one another?

Only if you select both lines in the first place - say you want to offset both lines to the outside...

...but I would still want to avoid ending up with 2 lines atop one another. It's your program, I'm just making a suggestion, based on what I would change.

True - I understand your point - but I think I will keep the program as is - I realise that you wouldn't want two lines above each other, but it just seems more logical that if you select two lines to offset, you will get two offsets.
Title: Re: Dynamic Offset
Post by: alanjt on December 14, 2009, 10:45:15 AM
Just so you know, if you select both lines, then execute centerline offset, you will get 2 lines in the center.

Yes - I thought this would be more consistent with the rest of the program  :-)
To have 2 lines on top of one another?

Only if you select both lines in the first place - say you want to offset both lines to the outside...

...but I would still want to avoid ending up with 2 lines atop one another. It's your program, I'm just making a suggestion, based on what I would change.

True - I understand your point - but I think I will keep the program as is - I realise that you wouldn't want two lines above each other, but it just seems more logical that if you select two lines to offset, you will get two offsets.
Fare enough.
Title: Re: Dynamic Offset
Post by: Lee Mac on December 16, 2009, 07:21:13 AM
Following a suggestion from over at CADTutor, I have updated the code in the first post to Version 1.9.

In this version, I have altered the way that the program deals with multiple offsets, and have made an important bug fix for the OSnap.

Enjoy,

Lee
Title: Re: Dynamic Offset
Post by: GDF 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.
Title: Re: Dynamic Offset
Post by: Lee Mac 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
Title: Re: Dynamic Offset
Post by: nivuahc 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
Title: Re: Dynamic Offset
Post by: Lee Mac 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:

(http://www.theswamp.org/screens/leemac/OffEx.png)
Title: Re: Dynamic Offset
Post by: Lee Mac 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

Title: Re: Dynamic Offset
Post by: qjchen 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.
Title: Re: Dynamic Offset
Post by: Lee Mac 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
Title: Re: Dynamic Offset
Post by: ElpanovEvgeniy 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)
)
Title: Re: Dynamic Offset
Post by: qjchen 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.
Title: Re: Dynamic Offset
Post by: ElpanovEvgeniy on February 26, 2010, 10:28:18 AM
I can not get an error on your description ...
autocad 2008 en (sp 1)
Title: Re: Dynamic Offset
Post by: Lee Mac 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.  :-)
Title: Re: Dynamic Offset
Post by: LE3 on February 26, 2010, 10:48:15 AM
nice tools !

anyone had tried them with heavy polylines? - (just tested the one Eugenio posted)
Title: Re: Dynamic Offset
Post by: Lee Mac 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?
Title: Re: Dynamic Offset
Post by: LE3 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
Title: Re: Dynamic Offset
Post by: Lee Mac 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-)
Title: Re: Dynamic Offset
Post by: Lee Mac on February 26, 2010, 11:12:40 AM
Evgeniy - fantastic idea to use inters, makes the problem much simpler  8-)
Title: Re: Dynamic Offset
Post by: LE3 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 :)
Title: Re: Dynamic Offset
Post by: Lee Mac 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.
Title: Re: Dynamic Offset
Post by: ElpanovEvgeniy 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 ...
Title: Re: Dynamic Offset
Post by: Lee Mac 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  :-)
Title: Re: Dynamic Offset
Post by: wizman on February 26, 2010, 02:42:34 PM
Good clean solution Elpanov, but having minor bug if first segment is an arc.
Title: Re: Dynamic Offset
Post by: ElpanovEvgeniy 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.
Title: Re: Dynamic Offset
Post by: Lee Mac 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 ', все эти обратное не может многое сделать для выполнения ...
Title: Re: Dynamic Offset
Post by: qjchen 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~~
Title: Re: Dynamic Offset
Post by: ElpanovEvgeniy 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.
Title: Re: Dynamic Offset
Post by: ElpanovEvgeniy 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)
)
Title: Re: Dynamic Offset
Post by: wizman on February 27, 2010, 01:07:58 AM
Outstanding Sir, thanks for Sharing your solution.
Title: Re: Dynamic Offset
Post by: ElpanovEvgeniy on February 27, 2010, 01:29:47 AM
Many thanks!  :-)
Title: Re: Dynamic Offset
Post by: Atwist 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
Title: Re: Dynamic Offset
Post by: qjchen 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~
Title: Re: Dynamic Offset
Post by: ozimad on March 09, 2010, 03:30:37 AM
Function is great but it would be great if osnap function was working during stretching.
Zhenja dobavj pozhalujsta osnap  :-)
Title: Re: Dynamic Offset
Post by: Lee Mac on March 09, 2010, 03:33:17 AM
Function is great but it would be great if osnap function was working during stretching.
Zhenja dobavj pozhalujsta osnap  :-)

That's one of the major downsides of using the grRead loop - it takes quite a bit of coding to 'imitate' the ObjectSnap (as well as other ACAD functionality), without moving to Arx/.Net for solutions.
Title: Re: Dynamic Offset
Post by: jitupnair on April 29, 2010, 07:35:19 AM
Hi,
Its a very good program. I like it. Could you please make a program that will extend a closed polygon towards any given object. Its some thing like normal extend. But the condition in this case the object will be closed polygon. If you could do this it will be a greate help for me.
Please note that if the end of the polygon is with any arc segment the radius should not be changed.

Thanks & regards

Jithesh P. Nair

Title: Re: Dynamic Offset
Post by: Lee Mac on April 29, 2010, 08:43:45 AM
I see that you have already posted this question here (http://www.theswamp.org/index.php?topic=33179.0).

Please do not double-post, it just confuses matters, and your question is not likely to get anwered any quicker, in fact, it is irritating for most when a question is posted multiple times.

Furthermore, your question is unrelated to the thread in which you have posted it.

Title: Re: Dynamic Offset
Post by: hmspe on April 29, 2010, 09:25:45 AM
That's one of the major downsides of using the grRead loop - it takes quite a bit of coding to 'imitate' the ObjectSnap (as well as other ACAD functionality), without moving to Arx/.Net for solutions.

Lee,  do you know of an ARX or .NET replacement for GRREAD?  Two things I'd like to see in GRREAD are the option to get scan codes/key codes for all keys, and working OSNAPS.  My search hasn't turned up an ARX/.NET equivalent.  I could probably extend working code to handle the scan code issue, but I don't know enough about modern C++ or c# to program from scratch.

Martin
Title: Re: Dynamic Offset
Post by: Lee Mac on April 29, 2010, 01:43:33 PM
Hi Martin,

There is DynDraw.arx on here by Alexander Rivellis - it is pretty much GrRead with OSnap, plus a lot more. I've dabbled with it, but haven't really played with it enough to use it in a program.

Lee
Title: Re: Dynamic Offset
Post by: hmspe on May 01, 2010, 10:43:09 AM
Thanks, Lee.
Title: Re: Dynamic Offset
Post by: Lee Mac on May 01, 2010, 01:07:38 PM
You're welcome :-)
Title: Re: Dynamic Offset
Post by: jitupnair on May 04, 2010, 01:13:13 AM
Sorry Lee,
My sincere appology.

Thanks & regards

Jithesh P. nair
I see that you have already posted this question here (http://www.theswamp.org/index.php?topic=33179.0).

Please do not double-post, it just confuses matters, and your question is not likely to get anwered any quicker, in fact, it is irritating for most when a question is posted multiple times.

Furthermore, your question is unrelated to the thread in which you have posted it.