Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Verticale Xline with undo

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
Subje
412 Views, 2 Replies

Verticale Xline with undo

hi,

 

So i have now 

 

(defun C:VV (/ *error* inspt done)
  (defun *error* (errmsg); on Escape at insertion-point prompt
    (command); cancel Insert command, then
    (command "_.layerp")
  ); defun -- *error*
  (command "_.LAYER" "_Set" "4031.Niet.Afdrukbaar" "")
  (while (not done)
    (command "_.xline" "V"); leave in command
    (cond ; at insertion-point prompt
      ((setq inspt (getpoint "\nInsertion point or <exit>: ")); point if picked, nil if Enter
        (command inspt "" "" ""); finish Insertion
      ); end picked-a-point condition
      (T ; on Enter/space at insertion-point prompt
        (command); cancel Insert
        (setq done T); stop (while) loop
      ); end exit condition
    ); cond
  ); while
  (command "_.layerp")
); defun

 

But i need a lisp, that put a verticale Xline and also make it possible to undo one of the "loop"xlines. So in normal terms, i would put xline, enter, then copy last object, the xline at the base point and then drag it around. Copy make it possible to undo in the command. The code above was a little try so it could be that there are some bugs in it :).

 

Shout away.

 

Thanks

 

__________________________________________________________________________________
There isn't anything you can't to do if you keep believing.

Met vriendelijk groeten, With best regards,
Sincères salutations,

Dieter Bevernage
2 REPLIES 2
Message 2 of 3
Kent1Cooper
in reply to: Subje


@Subje wrote:

....

But i need a lisp, that put a verticale Xline and also make it possible to undo one of the "loop"xlines. So in normal terms, i would put xline, enter, then copy last object, the xline at the base point and then drag it around. Copy make it possible to undo in the command. The code above was a little try so it could be that there are some bugs in it :).

....


Several things about that code are left-overs from a multiple-Insert routine [which I think I wrote], and are not relevant to copying Xlines around.  I think if you want to be able to Undo individual added Xlines, then each needs to be put there by its own separate Copy command, rather than with one Copy command and the Multiple option.  Borrowing from another routine of mine for the individual-Undo-along-the-way aspect, I patched together the following, which seems to do what you're describing, in limited testing:

 

(defun C:VV (/ *error* pt1 xl n pt done)
  (defun *error* (errmsg); Escape at next-Xline location prompt
    (if (not (wcmatch errmsg "Function cancelled,quit / exit abort,console break"))
      (princ (strcat "\nError: " errmsg))
    ); if

    (command "_.layerp")

    (princ)
  ); defun -- *error*
  (command
    "_.LAYER" "_thaw" "4031.Niet.Afdrukbaar" "_make" "4031.Niet.Afdrukbaar" ""
      ;; [in case it's frozen, or doesn't yet exist]
    "_.xline" "_ver" (setq pt1 (getpoint)) "" ; draw first one
  ); command
  (setq
    xl (entlast); the first one drawn
    n 0 ; for Undo counter below
  ); setq
  (while (not done)
    (if (> n 0) (initget "Undo")); Undo option only if things to undo
    (setq pt
      (getpoint pt1 ; rubber-banded from first one
        (strcat
          "\nNext Xline location, or "
          (if (> n 0) "[Undo] " ""); Undo option only if things to undo
          "<exit>: "
        ); strcat
      ); getpoint
    ); setq
    (cond ; overall point-selection or Undo option
      ((= pt "Undo")
        (setq n (1- n)); increment counter downward
        (command "_u"); remove last-added Xline
      ); Undo condition
      (pt ; picked a point
        (command "_.copy" xl "" pt1 pt)
        (setq n (1+ n)); increment counter upward
      ); picked-a-point condition
      (T ; Enter/space for <exit> default [nil return]
        (setq done T); stop (while) loop
      ); end exit condition
    ); cond
  ); while
  (command "_.layerp")

  (princ)
); defun

 

It could use further enhancements [maybe Unlock the Layer just in case, command-echo suppression for parts of it, etc.].

Kent Cooper, AIA
Message 3 of 3
Subje
in reply to: Kent1Cooper

Works fine for me. and yes it was from that insert command, told myself i could manage to make one on my own, but that reality is far away it seems.

Thanks Kent,flawless as always.

__________________________________________________________________________________
There isn't anything you can't to do if you keep believing.

Met vriendelijk groeten, With best regards,
Sincères salutations,

Dieter Bevernage

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost