Reverse function

I noticed that in Bricscad you have to convert lines to polylines to reverse them so to save doing that I added this function to the on_doc_load,lsp

;;function to reverse lines and polylines in Bricscad

(defun c:rev () (breverse))

(defun c:reverse ( / ss)(breverse))

(defun breverse (/ ss cnt tot entname entdetails entype spt ept new_ent)

(prompt "\nSelect Lines or Polylines : ")

(setq ss (ssget '((0 . "*LINE"))))

(if ss
(progn
(setq cnt 0
tot (sslength ss)
)

  (while (< cnt tot)

    (setq entname (ssname ss cnt)
          entdetails (entget entname)
          entype (cdr (assoc 0 entdetails))
          cnt (1+ cnt)
    )

    (if (= entype "LINE")
      (progn
        (setq spt (cdr (assoc 10 entdetails))
              ept (cdr (assoc 11 entdetails))
        ) ;_ end of setq

        (setq new_ent (subst (cons 10 ept)
                             (assoc 10 entdetails)
                             entdetails
                      ) ;_ end of subst
          new_ent (subst (cons 11 spt)
                         (assoc 11 entdetails)
                         new_ent
                  ) ;_ end of subst
        ) ;_ end of setq

        (entmod new_ent)
        (entupd entname)
      )

      (command "pedit" "m" entname "" "y" "r" "")
    )

  ) ;_ end of while
)

)
(princ)
)

;;;-------------------------------------------------------------------------

(DEFUN rev_error_setup ()

   (SETVAR "cmdecho" 0)

   (SETQ olderr *error*
         *error* custom_error
   )

(if (and (not (> (getvar "cmdactive") 0)) ; no command active and
(/= (getvar "undoctl") 13)
) ; not in a group undo already
(command "_.undo" "_begin")
) ;_end if
)

(DEFUN rev_error_restore ()
(SETQ error olderr)
(command-s "_.undo" "end")
(princ)
)

(defun rev_error (errmsg)
(rev_error_restore)
(terpri)
(prompt errmsg)
(princ)
)

Comments

  • Sorry - you'll need to remove the "y" from the line in the above code with the pedit command.

This discussion has been closed.