TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started by: cadd4la on September 05, 2018, 04:35:12 PM
-
Can someone please help me combine this lisp to have multiple distances by the use of a list of distances
For example, if I wanted this lisp to offset 6" I type "OD" and a list of distance comes up and then select 6. instead of having a code for each one of the distances I need.
(defun C:OD (/ ss pt)
;;(prompt "Select object to offset: ")
(setq ss (ssget "+.:E:S" '((0 . "lwpolyline,line,spline,circle,ellipse"))))
(setq pt (getpoint "Specify point on side to offset: "))
(command "offset" "12" ss pt "")
(initget "Yes No")
(setq RO (getkword "\nDelete original? [Yes/No] <N>: "))
(if (= RO "Yes")
(command "erase" ss "")
)
Thanks,
-
A list of distances may help.
However by making a small change, try this
(defun OD (dist / ss pt RO)
;;(prompt "Select object to offset: ")
(setq ss (ssget "+.:E:S" '((0 . "lwpolyline,line,spline,circle,ellipse"))))
(setq pt (getpoint "Specify point on side to offset: "))
(command "offset" dist ss pt "")
(initget "Yes No")
(setq RO (getkword "\nDelete original? [Yes/No] <N>: "))
(if (= RO "Yes")
(command "erase" ss "")
);end_defun
)
It's now changed into a function that has to be typed on the command line like this : (OD 6) The brackets are needed.
Replace the red 6 with the distance you require. If you want something different don't hesitate to ask.
-
More to look at:
------------- Offset -----------------
Advanced Offset to both side by VVA <Vladimir Azarko>
Offset selected object to both side and change (optional) layer of new object to current
http://www.theswamp.org/index.php?topic=23069.0
http://www.theswamp.org/index.php?topic=30650.0 Dynamic Offset by LeeMac
http://www.theswamp.org/index.php?topic=39645.msg449444#msg449444
http://www.theswamp.org/index.php?topic=32743.0 VLA-Offset using Point Selection
http://www.theswamp.org/index.php?topic=24688.0 Staggered Multiple Offset by RonJonp
http://www.theswamp.org/index.php?topic=6209.0 Here is a nice example of Offset by Jürg Menzi
http://www.theswamp.org/index.php?topic=23921.0 Offset direction discussion
http://www.theswamp.org/index.php?topic=21933.msg266096#msg266096 Offset Segments by Gile
http://www.theswamp.org/index.php?topic=27636.0 Array
-
Dlanor, thank you so much for taking a pass at the code, however, I have the following problem when I use the code.
Command: OD
; error: too few arguments
-
I have the following problem when I use the code.
Command: OD
; error: too few arguments
It's now changed into a function that has to be typed on the command line like this : (OD 6) The brackets are needed.
Replace the red 6 with the distance you require.
-
Sorry, stilling have a problem.
I type in (OC6) and it doesn't work. can't have a space between the C and 6.
Thanks,
Cadd4la
-
Sorry, stilling have a problem.
I type in (OC6) and it doesn't work. can't have a space between the C and 6.
Thanks,
Cadd4la
You can have a space between the c and the 6 if you type (OC 6) because it is a function and autocad recognises the opening bracket and waits for a closing bracket ignoring the space. It works for me in 2012
Still waiting for a list of distances.
-
I type in (OC6) and it doesn't work. can't have a space between the C and 6.
It's now changed into a function that has to be typed on the command line like this : (OD 6) The brackets are needed.
-
I type in (OC6) and it doesn't work. can't have a space between the C and 6.
It's now changed into a function that has to be typed on the command line like this : (OD 6) The brackets are needed.
I can't believe I missed that. :uglystupid2:
-
Dlanor,
Here is the list I would like to offset inches from 1" up to 36"
also, I need to offset feet from 1' to 50' along with the inches in-between i.e 1'-1", 1'-2", etc. Not sure if you would have the code be (OD1-2) for feet and have the inches (OOD6) I can fill in the list of distances myself once I get your code.
Thanks, for all your help.
Cadd4la
-
What are your primary drawing units feet or inches? Does this change? The reason I'm asking is that this is will probably require a small dialog as the range is somewhat larger than I anticipated, also an offset of 3' is the same as 36" so why the inches?
-
Dlanor,
No real reason to have both 36" and 3'. My primary drawing units are in inches but I don't what to have to remember if I what to offset 9'-8" I have to enter (OD 116), I would like to enter (OD 9-8) and if I want 4" I use (OOD 4).
The code should be in inches but the dialog list should be 9'-8".
Thanks,
-
Dlanor,
No real reason to have both 36" and 3'. My primary drawing units are in inches but I don't what to have to remember if I what to offset 9'-8" I have to enter (OD 116), I would like to enter (OD 9-8) and if I want 4" I use (OOD 4).
The code should be in inches but the dialog list should be 9'-8".
Thanks,
OK. That will help simplify everything.
-
Attached are a lisp file and a dcl file, I've minimally tested it.
Both routines use dynamic prompt and mode, and this is reset on exit. The option to delete the original uses this, and it will appear at the cursor allowing options to be selected with the mouse.
The lisp contains 2 command options :
ODD Type this to run the dialog version. This uses the dcl file which must be placed somewhere in the AutoCAD "Support File Search Path". The dialog is simple, select the Feet/Inches and choose whethers to select offset side or both sides. This option remembers the last input.
OD Type this to run the command line version. Unfortunately I cannot make your wish of (OD 6-7) come true as the argument is not passed. You are dropped into a prompt for the distance. This requires a string so now you can enter 6-7 or 6-7T (distance 6' 7") the T on the end is optional and controls whether the offset side is by selection (absent) or both sides (T). When entering in feet and inches you must separate using the "-". You can also enter in inches e.g. (28 or 28T) for 28". This is similar to entering in feet where the absence of the "-" denotes distance in inches.
Any feedback or changes welcome.
-
So what is wrong with this?
At the command line enter OD 3'-2"
OD<space>then your number, yes you need ' for feet
(defun c:od
(/ dist ss pt
) (setq ss
(ssget "+.:E:S" '
((0 .
"lwpolyline,line,spline,circle,ellipse")))) (command "offset" dist ss
"_non" pt
"") (if (= "Yes" (getkword "\nDelete original? [Yes/No] <N>: ")) )
)
-
My $0.05 I wrote a lisp that just asks for the offsets includes left and right by using a -ve the input is a simple string either space or a comma input.
eg 12.3,45,-12.3,56 or 123.3 46 52 -12.56 -52.68
It is split into a list of multiple offsets and just do it. The feet part could be added fairly simply by adding a defun that looks for the - and returns the correct string for the offset command.
This is an old one will try to find the newere version its at home.
(defun C:MULOFF ( / obj s off)
(vl-load-com)
(setq obj (entsel "\nSelectObject"))
(setq s (getpoint "\nPick Offset side"))
(while (/= (setq off (getreal "\nEnter offset or Enter to exit")) nil)
(vl-cmdf "_.offset" off obj s "")
(setq obj (entlast))
)
)
(c:muloff)
-
Dlanor,
Thank you so much for the code. I have a problem using the OD option for inches, for example when I type in 9 I get "An Error : bad argument type: numberp: nil occured." but if I type in 0-9 the code will work.
Regards,
-
CAB,
Thank you so much. Your code is great with just one thing that I don't care for, I have to enter the ' and " so 2'-3" and not just 2-3.
Regards,
Cadd4la
-
Well you could omit the "
(setq dist (getdist "\nEnter distance: "))
Enter distance: 3'-2
-
Cab,
Thank you for your reply
Cadd4la
-
BIGAL,
Thank you for your $0.05.
Regards,
Cadd4la