Bulk conversion of arcs to circles then alter diameter

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
2CV375
Newbie Member
Posts: 9
Joined: Tue Sep 05, 2017 11:36 am

Bulk conversion of arcs to circles then alter diameter

Post by 2CV375 » Tue Sep 05, 2017 11:46 am

Hello,

I have several hundred dxf files. They are mostly rectangles with holes however some drawings have curved contours.

The holes in the parts have been developed as two arcs that touch.

Is there a command that could be scripted to bulk convert the two arcs into a single circle?

Further to this problem once the arcs are converted to holes, I need to increase the diameter of the circle by 1mm.

It could be possible to not convert the arcs and just increase the radius by 0.5mm as long as I am able to determine if the arc is inside the contour and not part of the contour.

Any suggestions as to where to start (or if this is something that can be achieved) would be appreciated.

Thank you.

Daniel.
demo1.png
Example File
demo1.png (8.37 KiB) Viewed 6128 times

User avatar
Husky
Moderator/Drawing Help/Testing
Posts: 4939
Joined: Wed May 11, 2011 9:25 am
Location: USA

Re: Bulk conversion of arcs to circles then alter diameter

Post by Husky » Tue Sep 05, 2017 4:53 pm

Hi Daniel - welcome to the forum.
2CV375 wrote:Is there a command that could be scripted to bulk convert the two arcs into a single circle?
Not that I know of.
2CV375 wrote:It could be possible to not convert the arcs and just increase the radius by 0.5mm as long as I am able to determine if the arc is inside the contour and not part of the contour.
Regarding to your screenshot: Select the arcs and use the Property Editor to increase the radius or diameter with "+0.5" etc.
Husky-2017.09.05-01.png
Husky-2017.09.05-01.png (26.91 KiB) Viewed 6122 times
Husky-2017.09.05-02.png
Husky-2017.09.05-02.png (45.99 KiB) Viewed 6122 times
Work smart, not hard: QCad Pro
Win10/64, QcadPro, QcadCam version: Current.
If a thread is considered as "solved" please change the title of the first post to "[solved] Title..."

2CV375
Newbie Member
Posts: 9
Joined: Tue Sep 05, 2017 11:36 am

Re: Bulk conversion of arcs to circles then alter diameter

Post by 2CV375 » Wed Sep 06, 2017 2:50 am

Thank you for your welcome and detailed reply Husky. It is appreciated.

What you propose is a solution when I have only a few drawings. I appreciate the suggestion as I was unaware of this functionality. Manually selecting the internal holes is possible. The problem I have is the number of drawings. The largest number of parts, thus far, has been 750 and typically 150 to 300. I have been lucky in the last job in that I was able to develop a gawk script to modify the radius in the DXF file as all the holes are proper circles that only appear inside the part.

Would anyone know if your technique can be scripted within QCAD? Is it possible in the QCAD scripting language to detect entities inside a boundary? The boundary could be LINES and ARCS or it could be a LWPOLYLINE.

While writing this reply I had an idea:
  1. Use QCAD to export to SVG,
  2. GAWK to change the radius,
  3. and QCAD to convert back to DXF.


A sample part is below. The only problem is when the "holes" are two arcs and not a full circle. The AutoCAD overkill command has this so I may be able to ask the supplier to run their parts through overkill (if they use AutoCAD).

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<!-- 2017-09-06 11:36:20 Generated by QCAD SVG Exporter -->
<svg width="126" height="180" viewBox="-63 -90 126 180" version="1.1" xmlns="http://www.w3.org/2000/svg" style="stroke-linecap:round;stroke-linejoin:round;fill:none">
    <g transform="scale(1,-1)">
        <!-- Polyline -->
        <path d="M-63,-90 L63,-90 L63,90 L-63,90 Z" style="stroke:#000000;stroke-width:0.25;"/>
        <!-- Circle -->
        <circle cx="28" cy="55" r="9.5" style="stroke:#000000;stroke-width:0;"/>
        <!-- Circle -->
        <circle cx="28" cy="-55" r="9.5" style="stroke:#000000;stroke-width:0;"/>
    </g>
</svg>
Kind regards,

Daniel.

2CV375
Newbie Member
Posts: 9
Joined: Tue Sep 05, 2017 11:36 am

Re: Bulk conversion of arcs to circles then alter diameter

Post by 2CV375 » Wed Sep 06, 2017 2:59 am

Sorry, one thing I failed to mention was that in some cases, the internal holes are different diameters :(. I am not sure how this changes the problem.

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

Re: Bulk conversion of arcs to circles then alter diameter

Post by andrew » Thu Sep 07, 2017 8:34 am

2CV375 wrote:Would anyone know if your technique can be scripted within QCAD?
You can program pretty much anything with QCAD scripts. The only limits are your time and willingness to learn script programming.
2CV375 wrote:Is it possible in the QCAD scripting language to detect entities inside a boundary? The boundary could be LINES and ARCS or it could be a LWPOLYLINE.
Yes. If you have an algorithm for deducing that boundary, you should be able to do it.
2CV375 wrote:
  1. Use QCAD to export to SVG,
  2. GAWK to change the radius,
  3. and QCAD to convert back to DXF.
Note that you will very likely lose at least some information in that round-trip (layer information, dimensions, hatches, etc.).
2CV375 wrote:A sample part is below. The only problem is when the "holes" are two arcs and not a full circle. The AutoCAD overkill command has this so I may be able to ask the supplier to run their parts through overkill (if they use AutoCAD).
This situation would be relatively easy to detect:
- Find an arc
- Query all arcs within the boundary of the full circle pertaining to the arc
- If radius is the same and angles complement each other, replace both entities with full circle

CVH
Premier Member
Posts: 3470
Joined: Wed Sep 27, 2017 4:17 pm

Re: Bulk conversion of arcs to circles then alter diameter

Post by CVH » Wed Mar 25, 2020 2:58 pm

2CV375 wrote:
Tue Sep 05, 2017 11:46 am
Is there a command that could be scripted to bulk convert the two arcs into a single circle?
A workaround could be:
Select all those semicircles regardless there radius with the Selection Filter.
Isolate (copy) them on a separate working layer, freeze the rest.
Set start at 0°, end at 360°, all reversed or not.
-> Now you have duplicates
Detect Duplicates (MD) and delete those.
Select the full Arcs of a certain radius.
Menu..Misc..Information..Store Positions.
Menu..Draw..Center/Radius (CR); set radius.
Menu..Misc..Information..Use Positions.
Repeat for other radii and delete the full Arcs.

It works good for some radii or some files but not for hundred of files.
And not in a snap-of-a-finger.

Regards,
CVH

CVH
Premier Member
Posts: 3470
Joined: Wed Sep 27, 2017 4:17 pm

Re: Bulk conversion of arcs to circles then alter diameter

Post by CVH » Fri Mar 27, 2020 6:07 am

Regarding this and your other post:
viewtopic.php?f=33&t=7093

Circular Shape Replacement Tool
The tool would take a user selection of circular forms.
The selection is filtered on Arcs and Circles.
Arcs are considered as being full 360°Arcs.

Filtered for every unique combination of centerpoint and radius a new circular form or new shape is constructed.
Comparison is done with a certain angular and linear tolerance.
The new Props are set to rounded values related to the used tolerances.
(this can avoid things as ...99997 and ...0002)

The new circular form can be formulated as:
- 2 semicircle Arcs; @ Cut angle
- 1 full Arc; @ Cut angle; End Angle = Start Angle OR Start Angle + 360°
- 1 circle
- The radius is set regarding the source OR fixed OR scaled OR summed.
- Arcs are CW OR CCW
A new shape could be: A point; A sqaure (& size) ; A cross (& size) ...
Optionally only the centerpoints are stored to be reused with Menu..Misc..Information...
Optionally casting on a sub-Layer.
Optionally deleting the replaced forms & duplicates.

Does that narrow it down to your needs?

Regards,
CVH

Post Reply

Return to “QCAD 'How Do I' Questions”