[Solved] turn finite or bound geometry to infinite or unbound geometry

Please use this forum to post feedback and suggestions related to QCAD.

Moderator: andrew

Post Reply
Daniel4
Junior Member
Posts: 17
Joined: Sat Jan 30, 2021 5:34 pm
Location: Wisconsin

[Solved] turn finite or bound geometry to infinite or unbound geometry

Post by Daniel4 » Sun Oct 23, 2022 2:38 pm

Hello,
I could use an option to unbind finite geometry. Either you could describe it as making finite geometry infinite, or bound geometry unbound.
See screenshots below.

Thank you.
Attachments
Bound or finite geometry.jpg
Bound or finite geometry.jpg (205.25 KiB) Viewed 18356 times
Unbound or infinite geometry.jpg
Unbound or infinite geometry.jpg (219.32 KiB) Viewed 18356 times
Last edited by Daniel4 on Wed Oct 26, 2022 12:04 am, edited 2 times in total.

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

Re: turn finite or bound geometry to infinite or unbound geometry

Post by Husky » Sun Oct 23, 2022 7:04 pm

Hi,
if it is limited to horizontal/vertical lines and arcs then you can already do that in QCAD.

Husky-2022.10.23-03.png
Husky-2022.10.23-03.png (21.24 KiB) Viewed 18338 times
Husky-2022.10.23-04.png
Husky-2022.10.23-04.png (45.39 KiB) Viewed 18338 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..."

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

Re: turn finite or bound geometry to infinite or unbound geometry

Post by CVH » Sun Oct 23, 2022 7:22 pm

Hi,

May I ask why? Isn't it much easier to use XLines, Circles and so on to start with?

A script could be an answer for Lines, Arcs, Ellipse arcs, single segment Polylines and there it would end.
I don't see a way for an infinite Polyline or Spline.

Should that consider a selection or all displayed or both?
I think that whole the drawing is a bad option. :wink:

A workaround would be to draw over Lines by XLines and Arc's by circles.
That is what a script would do.
And then I don't consider a 360° degree arc to be the equivalent of a circle. :wink:

Regards,
CVH

Daniel4
Junior Member
Posts: 17
Joined: Sat Jan 30, 2021 5:34 pm
Location: Wisconsin

Re: turn finite or bound geometry to infinite or unbound geometry

Post by Daniel4 » Mon Oct 24, 2022 1:51 am

Hi Husky,
if this is possible to do already, awesome! how? I forgot to ask earlier if this is a feature that I just couldn't locate....

Hi CVH,
I'm going to admit, it's pretty rare. The only example I can think of is when you are working on someone else's file, and there are say 50 diameters. I want them to each be one entity for ease of programming, but find out that each one is broken into 10+ entities. Easiest fix is to select all arcs, then unbind all arcs/radii to make them full diameters. Last, delete all duplicates. Yeah, that's pretty rare, but it happens to me!
Yes, lines and arcs only, I really don't think it would work for anything else.

I don't know how scripts work, but I'm interested.
What is the difference between a 360 degree arc and a circle, start and end points?

Thanks for your help guys!

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

Re: turn finite or bound geometry to infinite or unbound geometry

Post by Husky » Mon Oct 24, 2022 9:56 am

Daniel4 wrote:
Mon Oct 24, 2022 1:51 am
if this is possible to do already, awesome! how?
Piece of cake ...

1. Use Selection Filter to find all finite horizontal lines:
Filter = Line, Angle, equal to, 0
click "Replace current Selection,
to find all horizontal direction repeat with similar Filter,
change Comparison to "not equal to" 0,
click "Add to current Selection"

2. Menu/Misc/Information/Store Positions (the position of all selected entities are stored within QCAD!),

3. Launch "Horizontal Linie", Mode Infinitive,

4. Launch "Use Positions" below Misc/Information,

5. press "Delete" to get rid of the still selected finite horizontal lines - done.

For finite vertical lines same procedure ... but with 90° :wink:

Tomorrow I will explain how to do it with arcs ....
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..."

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

Re: turn finite or bound geometry to infinite or unbound geometry

Post by CVH » Mon Oct 24, 2022 11:52 am

Hi,

It would not be that hard to alter this: https://www.qcad.org/rsforum/viewtopic. ... 244#p32244 so it acts on Line segments or on arc's. :wink:

There is even an easy way back from an XLine or a Ray to a Line segment.
For your use the question still remains what Line segment as XLine will be detected by MD.
MD doesn't act on XLines or Rays.

For a circle all start/end data of the original arc is lost.

Resembling infinite shapes for Arcs is rather simple.
Select all Arcs.
For all set Reversed or not.
For all set Start Angle to 0 degree.
For all set End Angle to 360 degrees.
Invoke MD and delete duplicates.

But that are still Arc entities, full circular Arcs to be correct.
Select all full Arcs.
Polyline from selection.
Then run the code in the link above.

How this works: A circular Polyline can not be coded as one circular arc segment there the bulge factor would be infinite.
QCAD will split up the circular arc segment in two semi circles and stored these as one Polyline.
The script is intended for a way back from exploding Circles into Polylines. :wink:

Regards,
CVH
Last edited by CVH on Tue Oct 25, 2022 5:03 am, edited 6 times in total.

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

Re: turn finite or bound geometry to infinite or unbound geometry

Post by CVH » Mon Oct 24, 2022 12:05 pm

Husky wrote:
Mon Oct 24, 2022 9:56 am
to find all horizontal direction repeat with similar Filter,
change Comparison to "not equal to" 0,
click "Add to current Selection"
That would add all Line segments with an angle not zero to my selection. :?
Meaning all from 0 to 360 degrees excluding zero itself but those were already selected in the previous step. :roll:

I think that 'Horizontal' is twofold: Those angled zero degrees and those angled 180 degrees.
'Vertical' is then 90 and 270 degrees.

Regards
CVH

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

Re: turn finite or bound geometry to infinite or unbound geometry

Post by CVH » Mon Oct 24, 2022 1:32 pm

Bitte:
Tick 'SELECT ALL', copy and save it as a *.js script file (eg. Arc2Circ.js)
Run it in QCAD on a selection with Menu Misc .. Development .. Run Script (XC).

Code: Select all

// Arc segments to Circles script by CVH
var doc = getDocument();
var di = getDocumentInterface();
var arcsCollected = [];

// Retrieve the selection:
var ids = doc.querySelectedEntities();

// Terminate without selection:
if (ids.length === 0) {
    EAction.handleUserWarning("Nothing Selected! Script terminated.");
    return;
}

// Filter Arc segments from selection:
for (var i=0; i<ids.length; i++) {    // Cycle selected entities
    // Get entity from the document:
    var entity = doc.queryEntity(ids[i]);

    // Collect when exist and is Arc shape with a radius:
    if (!isNull(entity)){
        if (isArcEntity(entity)) {
            if (!RMath.fuzzyCompare(entity.getRadius(), 0.0)) {
                arcsCollected.push(ids[i]);
            }
        }
    }
} // Loop selected entities

// Terminate without Arc segments in selection:
if (arcsCollected.length === 0) {
    EAction.handleUserWarning("No Arc segments selected! Script terminated.");
    return;
}

// Setup an operation:
var operation = new RModifyObjectsOperation();
operation.setText("Arcs to Circles");

// Process collected Arcs:
for (var i=0; i<arcsCollected.length; i++) {    // Cycle collected Arcs
    // Get Arcs from the document:
    var arcEntity = doc.queryEntity(arcsCollected[i]);
    var centerRv = arcEntity.getCenter();
    var radius = arcEntity.getRadius();

    // Create a new Circle entity:
    var newCircle = new RCircleEntity(
                    doc,
                    new RCircleData(
                        centerRv,
                        radius
                    )
    );

    // Add the new Circle to the operation:
    operation.addObject(newCircle, false, true);    // NOTuseCurrentAttributes, DOforceNew

    // Mark the Arc to delete:
    operation.deleteObject(arcEntity);
} // Loop collected Arcs

// Apply all modifications:
di.applyOperation(operation);

// Finished:
var msg = "Created " + arcsCollected.length + " Circle entity/ies."
EAction.handleUserInfo(msg);
EAction.handleUserMessage("Script ended.");
return;
MD can then eliminate duplicates. :wink:

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

Re: turn finite or bound geometry to infinite or unbound geometry

Post by Husky » Mon Oct 24, 2022 10:08 pm

The arc procedure ...
Daniel4 wrote:
Mon Oct 24, 2022 1:51 am
I want them to each be one entity for ease of programming, but find out that each one is broken into 10+ entities. Easiest fix is to select all arcs, then unbind all arcs/radii to make them full diameters. Last, delete all duplicates.
Broken into 10+ entities is a not before mentioned fact but luckily QCAD Pro can handle that too ...

Use the Selection Filter to select all arcs,
after all arcs are selected check the Property Editor for "Sweep Angle" - set that to 360. Press Enter.
Note: If arcs are found which contain 10+(?) broken pieces this method will create 10+ 360° arcs (looks like a circle) at the same position = duplicates!
To fix that use the still existing selection on all arcs, launch "Detect Duplicates", Options like screenshot:

Husky-2022.10.24-01.png
Husky-2022.10.24-01.png (8.2 KiB) Viewed 18198 times

Hit "Delete Selected Duplicates" - done. :wink:
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..."

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

Re: turn finite or bound geometry to infinite or unbound geometry

Post by CVH » Tue Oct 25, 2022 5:38 am

The problem in setting the Sweep Angle to 360 degrees is that there will be start/end angles over 360 degrees.
When we reload such files some full circular Arcs may have a Sweep Angle of 0 degrees.
They look OK but when selecting they are not displayed.
Some third-party Apps can not handle these.
fullCircles.dxf
(95.72 KiB) Downloaded 379 times
One of the reasons that I don't consider a 360° degree arc to be the equivalent of a circle.
So far I didn't encounter issues with Arcs going from 0 to 360 degrees. :wink:

Regards,
CVH

Daniel4
Junior Member
Posts: 17
Joined: Sat Jan 30, 2021 5:34 pm
Location: Wisconsin

Re: turn finite or bound geometry to infinite or unbound geometry

Post by Daniel4 » Wed Oct 26, 2022 12:02 am

Wow.
Thank you guys for the amount of work you both put into this. Next time you see me post something, give it a little less priority!
I'm impressed with all of this, the .JS file is crazy! How do you do that?
I like the store/use positions functions, this will come in handy for sure!
Last, I've never used the selection filter before, it looks very exhaustive, which is a good thing! Looks like I get to explore all of these items more in depth...

Thank you!

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

Re: [Solved] turn finite or bound geometry to infinite or unbound geometry

Post by CVH » Wed Oct 26, 2022 5:32 am

Your welcome, glad to be of any assistance.
Daniel4 wrote:
Wed Oct 26, 2022 12:02 am
Next time you see me post something, give it a little less priority!
Upcoming postings are treated with the same interest. :wink:
Daniel4 wrote:
Wed Oct 26, 2022 12:02 am
the .JS file is crazy! How do you do that?
All open source methods of QCAD can be found here: https://github.com/qcad/qcad
More information on classes here: https://qcad.org/doc/qcad/3.0/developer/annotated.html

It would take about a 5 minutes rewrite each for Line2Ray or Line2XLine or back.
But because MD doesn't handle these it will be of no use for this topic. :wink:
Daniel4 wrote:
Wed Oct 26, 2022 12:02 am
I like the store/use positions functions, this will come in handy for sure!
Tutorial: https://www.ribbonsoft.com/en/tutorial- ... -positions
What it stores for Polyline and Spline entities is by preference, see App.Prefs. .. Info .. Store Positions
Omitted is that:
- it stores the center of Arc, Circle, Ellipse and Ellipse Arc entities.
(What is of no use for this topic because the radii are dropped)
- it stores the position of a Block Reference and Text entities, the definition point for Dimensions.
- for Leaders it stores every node.
- and for other things like hatches, images and so on it stores the center of a bounding box.

Regards,
CVH

Post Reply

Return to “QCAD Suggestions and Feedback”