Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

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
(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")
        (setq spt (cdr (assoc 10 entdetails))
              ept (cdr (assoc 11 entdetails))
        ) ;_ end of setq

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

        (entmod new_ent)
        (entupd entname)

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

  ) ;_ end of while



(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")

(defun rev_error (errmsg)
(prompt errmsg)


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

Sign In or Register to comment.
Origami is the Japanese word for paper folding. ORI means to fold and KAMI means paper and involves the creation of paper forms usually entirely by folding.

Powered by VanillaForums, Designed by Steam