What type of object is a Circle?
Moderator: andrew
Forum rules
Always indicate your operating system and QCAD version.
Attach drawing files and screenshots.
Post one question per topic.
Always indicate your operating system and QCAD version.
Attach drawing files and screenshots.
Post one question per topic.
What type of object is a Circle?
When I explode a circle a couple of times - I see that the circle is made from two arcs. I drew the circle using the "circle2p" command - draw a circle with two points.
Is the circle a type of block?
Thanks for any information.
I'm using QCAD version 3.24.3.0 on a Windows 11 Pro machine.
Is the circle a type of block?
Thanks for any information.
I'm using QCAD version 3.24.3.0 on a Windows 11 Pro machine.
Re: What type of object is a Circle?
No, not at all, an arc and a circle are two distinct basic CAD entities.
In normal conditions a circle would not explode at all.
Test it, draw a circle with CI for example, select and explode (XP) it.
The circle entity remains a circle.
What probably happened is that you made a polyline of the circle and exploded that.
Polylines are strings of line/arc segments or better, strings of connected segments with a bulge factor.
Bulge = zero or not bulging for a straight segment and bulge = tan(sweep/4) for segments that resemble an arc.
The bulge factor of a full circular arc would be tan(360°/4) what is an error, tan(90°) is defined as y=1 divided by x=0.
To avoid this, circles are stored as two semi circular arc segments with bulge = tan(180°/4) = 1.
If you exploded such a polyline you get indeed two semi circular arc entities.
Now, full circular arcs are another problem.
The normalized (0° <= angle < 360°) start and end angle would be identical and the difference would be sweep = zero.
QCAD will detect that in some (normal) cases and revert to sweep = 360° ...
https://www.qcad.org/rsforum/viewtopic.php?f=33&t=10259
In other words: Something to avoid.
Regards,
CVH
Re: What type of object is a Circle?
As I indicated in my first post using the "circle2p" command and exploded that - twice - resulting in two arcs.
The same is true using the CI keyboard shortcuts - the resultant circle created with the command CI can then be exploded two times to get two arcs.
I'm actually troubleshooting a DXF import issue (not troubleshooting QCAD) - and it turns out that I need to understand what this circle is exactly.
Re: What type of object is a Circle?
My bad this is by preference.
See Application Preferences .. Modify .. Explode.
First it is converted to a polyline.
After that you explode the polyline.
For me that preference is cleared for over 3 years, keeping circles what they are.
https://www.qcad.org/rsforum/viewtopic.php?f=31&t=7914
Regards,
CVH
Re: What type of object is a Circle?
After a circle has been exploded - how to you turn the objects back to being a circle?
Is the circle object from QCAD identical to what AutoCAD generates?
Is the circle object from QCAD identical to what AutoCAD generates?
Re: What type of object is a Circle?
I've attached a DXF file with two polyline "circles." Aside from differences in radius and physical xy locations - what are the differences between these two objects?
The reason why I ask is that they do not import the same (I'm importing into a completely different CAD program).
I'd like to get a better idea why the two objects, the two circles, in the attached DXF are not treated the same when importing into another CAD software program.
The reason why I ask is that they do not import the same (I'm importing into a completely different CAD program).
I'd like to get a better idea why the two objects, the two circles, in the attached DXF are not treated the same when importing into another CAD software program.
- Attachments
-
- two_circles.dxf
- (103.48 KiB) Downloaded 10 times
Re: What type of object is a Circle?
The answer is partially given in the linked topic:
So, Undo (OO) all steps in the current QCAD session until you have the original circles back.Something we can 'Undo' immediately if we notice it soon enough.
When 'Undo' is out of the question there is no easy way back but redrawing.
But if that is out of the question, when not exploded in this QCAD session, when part of a stored file ....
... Then you must replace them by new circles.
I once posted a little remedying script but I can't locate it at the moment, I can't search PM's either.
Not problematic to rewrite on the fly ...
Apart from the apparent radius they are practically the same.
Both are a closed CCW polyline made up of 2 semi circle segments.
The main differences are: Left starts at 0°, R0.6 ; Right starts at 180°, R0.58737627
A very subtle difference is that the left one has bulges factors of 0.9999999999999999 instead of 1.
When exploded to Arcs we can recombine them by creating polylines from a selection (OC).
One can filter on all arcs and select them, see menu: View .. Selection Filter.
To display the Selection Filter you can also type GF
Once all 'circular' polylines are formed we can replace all of them with circles using the script below.
It diversifies between looking for them in an existent selection or among all document entities.
Code: Select all
var di = EAction.getDocumentInterface();
var doc = di.getDocument();
var ids = [];
if (doc.hasSelection()) {
ids = doc.querySelectedEntities();
}
if (!doc.hasSelection()) {
ids = doc.queryAllEntities();
}
var op = new RAddObjectsOperation();
op.setText("CircularPolys > Circles");
for (var i=0; i<ids.length; i++) {
var id = ids[i];
var entity = doc.queryEntity(id);
if (!isEntity(entity) || !isPolylineEntity(entity)) {
continue;
}
if (entity.countSegments() !== 2) {
continue;
}
if (!RMath.fuzzyCompare(entity.getBulgeAt(0), 1.0)) {
continue;
}
if (!RMath.fuzzyCompare(entity.getBulgeAt(1), 1.0)) {
continue;
}
var arc = entity.getSegmentAt(0);
var circle = new RCircle(arc.getCenter(), arc.getRadius());
var newEntity = new RCircleEntity(doc, new RCircleData(circle));
newEntity.copyAttributesFrom(entity.data());
op.deleteObject(entity);
op.addObject(newEntity, false);
}
di.applyOperation(op);
In QCAD start the Misc .. Development .. Script Shell (GE) and acknowledge to the dialog.
Paste the copied script to the bottom line of the Shell (R-click .. Paste).
Regards,
CVH
Re: What type of object is a Circle?
How do I convert the left to be the similar to the right (change it from 0°, R0.6 to 180°, R0.6)?
Also, the Properties panel isn't showing this information - where can I find it?
Re: What type of object is a Circle?
When selected the red reference marker is the start point.
The rest of the info is gathered from the vertices listed in the Property Editor.
What about Modify .. Flip Horizontal (FH)
Remind that this are polylines and not circles, they only look exactly the same.
The right one has an apparent radius of 0.58737627
There is no radius associated with polylines that represent a circular contour.
Most probably yes, Arc and Circles are common CAD drawing entities.
Regards,
CVH
Re: What type of object is a Circle?
Curious on how they are handled differently ... It should not be different at all ...
Could you share a screen caption of the file with polylines in that application?
Regards,
CVH
Re: What type of object is a Circle?
There's clearly a difference when imported. My interest in this is to reproduce the issue. An effective radius shouldn't make any difference (otherwise the $12k CAD tool I'm using would be useless). Interestingly, when I compare the two objects - their bulge parameter are both listed as exactly one in the property window.
Looks like bulge factor triggers the other CAD program.
How were you able to tell the difference between the bulge factors? Both show up as exact 1 in the Property window.
Re: What type of object is a Circle?
Values in the Property Editor are always rounded values, displayed with 0 to 8 digits depending preferences.
One can change the the bulge factor of each segment in direct, even in full precision.
Remind that subtle changes to values may not be performed.
First changing the bulge factor to 0.9 and then set the value to 1 should work here.
Discovered it while debugging the script as it failed to convert the left example to a circle.
Initially it tested for entity.getBulgeAt(0) === 1.0 and entity.getBulgeAt(1) === 1.0
Replaced that with a fuzzy compare what uses a default tolerance of +/-1e-9.
The default point tolerance used in QCAD.
It should not make any difference at all ...
... These segments represent an arc with a sweep angle of 179.99999999999998854084409738354 degrees. (sweep = 4 * atan(bulge))
Even two segments of 170, 190 or 90 degrees should be valid but the resemblance with a circle disappears.
Remember that a single segment with a sweep of 360° is a catastrophic error, tan(90°) = undefined.
Applications using Floating Point notation should expect some inaccuracies and handle that properly.
The specific origin is twofold:
- Arcs have no endpoints, they have end angles, polyline segments do have endpoints, they are called vertices or nodes.
The conversion from polar (angle based) to Cartesian (point based) or back can't be exact.
- Trigonometry is used to convert Arc sweep to bulge factor or back and that can't be exact.
Aside from:
- Floating Point notation doubles are limited to 52 bits for storing the mantissa of values, what is pretty precise BTW.
- 180° may look like a nice integer value but angles are handled in radians and 180°= Pi rads.
- Conversions between degrees and radians can't be exact there PI is an endless number what can not be stored.
As presented the conversion script already preform well for common usage.
Slightly better would be to average out the centers and radii of the 2 segments converted to arcs:
Code: Select all
var arc0 = entity.getSegmentAt(0);
var arc1 = entity.getSegmentAt(1);
var circle = new RCircle(RVector.getAverage(arc0.getCenter(), arc1.getCenter()), (arc0.getRadius() + arc1.getRadius()) / 2 );
What doesn't exclude that the result would be almost perfect but it can be a few bits off with the same effort.
Number uncertainty also means that you will never know it for certain and that you can not test for it unless knowing what to expect.
Regards,
CVH
Re: What type of object is a Circle?
Well, apparently, this makes a difference when importing into another CAD program. My question for you is this:
I see a bulge factor of 1 for both of the circles in the DXF that I posted. You mentioned that one of the circles has a bulge fact of something similar to this 0.999999999999999. Why is it you were able see this difference and I am not able to see the difference? I'm using the Properties box/panel the view the numerical value of the bulge factor - and, both are exactly 1.
Where can I see the high resolution of the bulge factor?
Re: What type of object is a Circle?
Additionally in testing for it, I stored the actual value in a variable.
var bulge0 = entity.getBulgeAt(0);
var bulge1 = entity.getBulgeAt(1);
And then paused the script there.
Then it was also obvious that some basic tolerance was required.
Your application would have more issues with a segment representing a 90° degree arc.
A value of give or take sqrt(3-2*sqrt(2)) can't be stored exactly.
Regards,
CVH