TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started 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)
;;;¤º°`°º¤ø,¸¸,ø¤º°`°º¤ø,¸¸,ø¤º°`°º¤ø,¸¸,ø¤º°`°º¤ø,¸¸,ø¤º°`°º¤ø,¸¸,ø¤º°`°º¤ø,¸¸,;;;
;;;ø,¸¸,ø¤º°`°º¤ø,¸¸,ø¤º°`°º¤ø,¸¸,ø¤º°`°º¤ø,¸¸,ø¤º°`°º¤ø,¸¸,ø¤º°`°º¤ø,¸¸,¤º°`°º¤;;;
;; ;;
;; --=={ 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).
-
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.
-
I was thinking the same thing. Offsetting is such a specific task.
-
:)
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
-
:)
I will also wish Autodesk can directly support grread with osnap.
Wouldn't that be nice. :)
-
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
-
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)
-
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:
-
I have updated the code in the first post to include Version 1.1, hopefully incorporating the all-important Object Snap! :angel:
-
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 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.
-
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:
-
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 :-)
-
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
-
Lee, was the method for entering/backspacing a number value one of your ideas? That is freaking brilliant. I'm totally stealing that.
-
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:
-
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
-
Oops! Minor bug, code updated :oops:
-
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. :)
-
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?
-
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.
-
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.
-
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
-
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:
-
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.
-
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...
-
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. :)
-
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)
-
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
-
Hallo Lee
Sollte so ein Schemata werden
Hello Lee
<br>
<br> If any such schemes are
-
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
-
Hallo Lee
Danke funktioniert jetzt super :-) :-) :-)
-
Excellent Hugo :-)
-
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
-
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
-
This is great Lee...can use it on P&ID and electrical schematics. Thanks for all the work on it...works a treat!
-
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 :-)
-
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.
-
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
-
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
-
Wow, that was fast.
So the source button and image button are for changing color to other than by layer...shame on you. :pissed:
-
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
-
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
-
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
-
(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
-
Here is 2 versions to play with for offset to center between 2 lines...
;;; 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)
)
-
Thanks Gary :-)
-
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
-
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!
-
Thanks t-Bear 8-)
-
Just so you know, if you select both lines, then execute centerline offset, you will get 2 lines in the center.
-
Nice routine- I like
thanks! :love: :love:
-
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 :-)
-
Nice routine- I like
thanks! :love: :love:
Thanks xianaihua 8-)
-
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?
-
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...
-
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.
-
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.
-
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.
-
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
-
Lee
Love your routine.
I would add to your routine, temporarly color changing for all offset entities upon selection.
-
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
-
Lee,
That's one nice routine there, buddy. :mrgreen:
Only minor tick that I found... check out the screenshot
-
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)
-
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
-
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.
-
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
-
My version:
(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)
)
-
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.
-
I can not get an error on your description ...
autocad 2008 en (sp 1)
-
All seems to work fine for me :-)
Absolutely fantastic Evgeniy - much better than the code I attempted to create... I shall study your code. :-)
-
nice tools !
anyone had tried them with heavy polylines? - (just tested the one Eugenio posted)
-
Evgeniy, I have a question,
why the use of 'progn' at the very start of the code? What is its purpose in this case?
-
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
-
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-)
-
Evgeniy - fantastic idea to use inters, makes the problem much simpler 8-)
-
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 :)
-
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.
-
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 ...
-
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 :-)
-
Good clean solution Elpanov, but having minor bug if first segment is an arc.
-
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.
-
Its a shame that LISP does not have a 'remove_last' function, all those reverse's can't do much for performance... :-(
Ее жаль, что Лисп не имеет функции "remove_last ', все эти обратное не может многое сделать для выполнения ...
-
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~~
-
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.
-
(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)
)
-
Outstanding Sir, thanks for Sharing your solution.
-
Many thanks! :-)
-
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
-
Thanks Evgeniy.
Now it works very good in Autocad 2004, and also good for the first segment arc situation~
-
Function is great but it would be great if osnap function was working during stretching.
Zhenja dobavj pozhalujsta osnap :-)
-
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.
-
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
-
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.
-
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
-
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
-
Thanks, Lee.
-
You're welcome :-)
-
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.