reversing arcs
Posted: Wed Nov 06, 2013 1:18 pm
Hello, I have recently looked into qcad a little, and although I feel not yet very comfortable with it (I'm relying on BricsCAD for 2d), I must say I'm quite impressed by the maturity it has reached. I just found a little problem with svg-import (all arcs were drawn in wrong direction) and reported this (processing of the bug report was nearly instantaneous, wow) that I had to fix in BricsCAD since I did not look into qcad scripting yet (I must admit that C-syntax is putting me off a little...).
So this is what I did in plain old AutoLISP to prompt the user for selecting arcs and then reversing their direction:
would this be an easy one in ECMA-script?
So this is what I did in plain old AutoLISP to prompt the user for selecting arcs and then reversing their direction:
Code: Select all
(prompt "
reverse_arc.lsp
11/2013 knut hohenberg, no rights reserved.
"
)
(defun reverse_arc ( / selset n object objdat ang1 ang1)
(prompt "Select arcs to be reversed: ")
(setq selset (ssget '((0 . "ARC"))))
(if selset
(progn
(setq n 0.0)
(command "._undo" "_g")
(while (setq object (ssname selset n))
(setq objdat (entget object)
ang1 (cdr (assoc 50 objdat))
ang2 (cdr (assoc 51 objdat))
objdat (subst (cons 51 ang1) (assoc 51 objdat) objdat)
objdat (subst (cons 50 ang2) (assoc 50 objdat) objdat)
n (1+ n)
)
(entmod objdat)
)
(command "_.undo" "_end")
)
(prompt "No arcs selected ")
)
(princ)
)
(prompt "
...loaded. Type (reverse_arc) to invoke.
"
)
(princ)