reversing arcs

Use this forum to ask questions about how to do things in QCAD.

Moderator: andrew

Forum rules

Always indicate your operating system and QCAD version.

Attach drawing files and screenshots.

Post one question per topic.

Post Reply
khad
Newbie Member
Posts: 9
Joined: Wed Nov 06, 2013 12:28 pm

reversing arcs

Post by khad » 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:

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)
would this be an easy one in ECMA-script?

User avatar
andrew
Site Admin
Posts: 9036
Joined: Fri Mar 30, 2007 6:07 am

Re: reversing arcs

Post by andrew » Wed Nov 06, 2013 1:48 pm

Hello and thanks for your feedback.

Issue 967 has been fixed for the next release:
http://www.qcad.org/bugtracker/index.ph ... ask_id=967

I've attached a simple tool to reverse the direction of all (selected) arcs for your reference.
As far as I can tell, this is more or less what your Lisp script does.
You can simply extract the attached ZIP file into scripts/Misc/Examples/ModifyExamples of your QCAD installation.
This will add the new tool under Misc - Script Examples - Modify - Change Arc Direction
Attachments
ExChangeArcDirection.zip
(1.53 KiB) Downloaded 512 times

khad
Newbie Member
Posts: 9
Joined: Wed Nov 06, 2013 12:28 pm

Re: reversing arcs

Post by khad » Thu Nov 07, 2013 1:18 am

Thanks so much.
I had already noticed the commit on git, and I'm completely stunned.
Less than 2 hours after reporting, the bug has not only been fixed, but there is a new scripting example as well... almost incredible.

Looking at the js code, I immediately understand the main part, but with AutoLisp being my dominant programming background, it doesn't make me fall in love instantaneously. But advanced AutoCAD users are probably not qcad's target audience anyway...

I anticipate quite a steep learning curve there, so I'll open another topic in a more appropriate place to ask some general questions, before deciding whether I should dive in deeper.

Post Reply

Return to “QCAD 'How Do I' Questions”