util qcad functions

Discussion forum for C++ and script developers who are using the QCAD development platform or who are looking to contribute to QCAD (translations, documentation, etc).

Moderator: andrew

Forum rules

Always indicate your operating system and QCAD version.

Attach drawing files, scripts and screenshots.

Post one question per topic.

Post Reply
sarlaa
Active Member
Posts: 47
Joined: Mon Aug 28, 2017 4:39 pm

util qcad functions

Post by sarlaa » Mon Jun 18, 2018 7:33 pm

Hi,

Can you tell me if in qcad exists functions for :

-Get the fusion of 2 lines ?
-check if a point is included in a shape ? (can be on shape lines or inside)
-Check if a line is included in a shape ? (can be on shape lines or inside)

And give me example of use if it exists.

Thanks.

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

Re: util qcad functions

Post by andrew » Tue Jun 19, 2018 11:44 am

sarlaa wrote:
Mon Jun 18, 2018 7:33 pm
-Get the fusion of 2 lines ?
Please elaborate. Do you want to create a polyline? Do you want to combine two line segments into one line? ...?
sarlaa wrote:-check if a point is included in a shape ? (can be on shape lines or inside)
For a polyline, you can use RPolyline::contains:

Code: Select all

polyline.contains(point, true, tolerance);
Second parameter is true to count points on the polyline as being 'inside'.
sarlaa wrote:-Check if a line is included in a shape ? (can be on shape lines or inside)
You can use RPolyline::containsShape:

Code: Select all

polyline.containsShape(shape);
Note that this excludes shapes on the polyline. These cases would have to be handled separately.

sarlaa
Active Member
Posts: 47
Joined: Mon Aug 28, 2017 4:39 pm

Re: util qcad functions

Post by sarlaa » Tue Jun 19, 2018 11:59 am

Thanks it's useful.

For my first point (fusion of 2 lines), in fact I want to combine two line segments into one line.

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

Re: util qcad functions

Post by andrew » Tue Jun 19, 2018 12:04 pm

sarlaa wrote:
Tue Jun 19, 2018 11:59 am
For my first point (fusion of 2 lines), in fact I want to combine two line segments into one line.
OK. There is no special function for this in the QCAD API.

sarlaa
Active Member
Posts: 47
Joined: Mon Aug 28, 2017 4:39 pm

Re: util qcad functions

Post by sarlaa » Tue Jun 19, 2018 12:07 pm

Ok.

for checking if polyline contains point I tried :

Code: Select all

 var plItem = new RPolyline();
  var pointsItem = [new RVector(0,20), new RVector(20,20), new RVector(20,0), new RVector(0,0)] 
  plItem.setVertices(pointsItem);

  var point = new RVector(10,10)
  var check = plItem.contains(point, true); //check is false
I get false, is there something I do wrong ?

sarlaa
Active Member
Posts: 47
Joined: Mon Aug 28, 2017 4:39 pm

Re: util qcad functions

Post by sarlaa » Tue Jun 19, 2018 12:13 pm

I see my error had to do :

Code: Select all

var pointsItem = [new RVector(0,20), new RVector(20,20), new RVector(20,0), new RVector(0,0), new RVector(0,20)] 
It works. Thanks

Post Reply

Return to “QCAD Programming, Script Programming and Contributing”