How to describe multiple selection sets in one script? This one does not work.. how to get the first offset line into second selection set (xxy) to join it with the other one later?
(defun c:offjoin ()
(setq xxx (entsel))
(command "offset" pause (car xxx) "99999999999,99999999999" "e")
(setq xxy (entlast))
(command "offset" "" (car xxx) "-99999999999,-99999999999" "e")
(setvar "peditaccept" 1)
(command "pedit" "m" "l" (car xxy) "" "j" "j" "b" "4" "")
(princ)
)
thank you!
Solved! Go to Solution.
Solved by hmsilva. Go to Solution.
Thanks, but using here 'getdist' user input instead of 'pause' needs probably some additional rewriting of the code, did not work.
Should work
(defun c:offjoin ( / xxx xxy) (setq xxx (entsel)) (command "offset" (getdist) (car xxx) "99999999999,99999999999" "e") (setq xxy (entlast)) (command "offset" "" (car xxx) "-99999999999,-99999999999" "e") (setvar "peditaccept" 1) (command "pedit" "m" "l" xxy "" "j" "j" "b" "4" "") (princ) )
HTH
Henrique
With 'getdist' it did not work, if offset distance is not changed (when enter is pressed to accept current offset distance).
@robert06 wrote:
With 'getdist' it did not work, if offset distance is not changed (when enter is pressed to accept current offset distance).
My bad!
Something like this perhaps. Using your method
(defun c:demo ( / a b d) (if (setq d (getdist (strcat "\nSpecify offset distance, <" (rtos (getvar 'OFFSETDIST) 2 2) ">:"))) (setvar 'OFFSETDIST d) (setq d (getvar 'OFFSETDIST)) );; if (if (setq a (entsel "\nSelect object to offset, <Exit>:")) (progn (command "offset" d (car a) "99999999999,99999999999" "e") (setq b (entlast)) (command "offset" d (car a) "-99999999999,-99999999999" "e") (setvar "peditaccept" 1) (command "pedit" "m" "l" b "" "j" "j" "b" "4" "") );; progn );; if (princ) );; demo
Or
(defun c:demo1 (/ a b d o) (vl-load-com) (if (setq d (getdist (strcat "\nSpecify offset distance, <" (rtos (getvar 'OFFSETDIST) 2 2) ">:"))) (setvar 'OFFSETDIST d) (setq d (getvar 'OFFSETDIST)) );; if (if (setq a (car (entsel "\nSelect object to offset, <Exit>:"))) (progn (setq o (vlax-ename->vla-object a)) (vla-offset o d) (setq b (entlast)) (vla-offset o (- d)) (setvar "peditaccept" 1) (command "pedit" "m" "l" b "" "j" "j" "b" "4" "") );; progn );; if (princ) );; demo1
HTH
Henrique
Better, I think, to not use the plus-or-minus gazillions points for Offset which-side designators -- there are circumstances in which they would both be on the same side of the selected object, e.g. a Line running at 45 degrees [or 225]. Here's something I edited quickly from a routine I have [which Offsets to both sides without the joining part] to add the joining -- OffsetBothSidesJoin.lsp with its OBSJ command.
It uses (vla-offset) with positive and negative values, to guarantee that the thing gets Offset to both sides. And it uses a fuzz factor for PEDIT/Joining that's a multiple of the Offset distance, rather than a fixed value of 4, so you can use any size distance and it will always be able to Join things.
It gets the distance first, not within an Offset command, so you can set that and go around picking a bunch of things [as many as you want in one running of the command] to do it to without needing to answer that prompt for each one. It remembers that distance [separately from regular Offset's] and offers it as the default on subsequent use. It works on any Offsettable entity type, though it could use some control features added, to prevent selection of non-Offsettable entities, and to keep it from trying to PEDIT/Join the entity types that can't be [maybe later]. If you pick a closed object, it will still Offset it to both sides, but won't try to Join the results.
It could also use some further refinements I have used in more recent routines [e.g. Enter/space to end it, rather than requiring Escape]. And it will have trouble with certain peculiar situations, like self-intersecting Polylines, or Arcs if the offset distance is greater than the radius. But if you pick any Offsettable and PEDITable entity using an appropriate distance, it seems to work, in limited testing.
Great Henrique, i like the VL version (demo 1) of your two proposals better, as Kent Kooper also stated, offset side should not be described via absolute coords, like i did.
Thank you!
@Anonymous wrote:
....I wish to tweak some of the codes ... so that it allows me to select multiple entities and offset and join the selection at once. Can someone help me ?
Try replacing this part:
(while T
(if
(setq obj
(vlax-ename->vla-object
(car (entsel "\nSelect object to Offset to Both Sides [Esc to exit]: "))
); end vlax-...
); end setq
(progn
(vla-offset obj *obsjdist)
(setq ent1 (entlast))
(vla-offset obj (- *obsjdist))
(if (not (vlax-curve-isClosed obj)); e.g. Line, Arc, open Polyline
(command "_.pedit" "_m" ent1 (entlast) "" "_j" "_j" "_b" (* *obsjdist 2.5) "")
); if
); end progn
); end if
); end while
with this [untested]:
(if
(setq ss (ssget ":L"))
(repeat (setq n (sslength ss)); then
(setq obj (vlax-ename->vla-object (ssname ss (setq n (1- n)))))
(vla-offset obj *obsjdist)
(setq ent1 (entlast))
(vla-offset obj (- *obsjdist))
(if (not (vlax-curve-isClosed obj)); e.g. Line, Arc, open Polyline
(command "_.pedit" "_m" ent1 (entlast) "" "_j" "_j" "_b" (* *obsjdist 2.5) "")
); if
); end repeat
); end if
It could add filtering for offsettable object types in the selection, as well as some of the other "it could use" things already mentioned.
@Anonymous wrote:
Thanks Kent.
You're welcome, and welcome to these Forums! I guess it actually must have worked [always a risk when untested].... And I'm glad to see people finding things from past threads here that they can use.