Simple API addPolyline(...)

If you are having problems with QCAD, post here. Please report bugs through our Bug Tracker instead.

Always attach your original DXF or DWG file and mentions your QCAD version and the platform you are on.

Moderator: andrew

Forum rules

Always indicate your operating system and QCAD version.

Attach drawing files and screenshots.

Post one question per topic.

Post Reply
CVH
Premier Member
Posts: 3415
Joined: Wed Sep 27, 2017 4:17 pm

Simple API addPolyline(...)

Post by CVH » Mon Sep 30, 2019 12:24 pm

Al, Andrew,

I am enhancing the Flexpainter to use local and global polyline definitions. :D

Excluding global bulging for the moment: :|
It is globally pritty the same as for splines. :P

Code: Select all

// With a empty collector array created in the parent function
var this.collector = [];

// The orthogonal casting function collects data
// With a global polyline datastring number
var nodStringN = 0;
...
setting nodStringN = 0 ......N
...
// With a castVector from a castPoint and a castAngle
 var castVector = new RVector(castPoint.x - Math.sin(castAngle) * scaleOffset,
                              castPoint.y + Math.cos(castAngle) * scaleOffset);
...
case "Nods":    // Push to global polys
    // # Issue # Again, forgot why not push versus add past end ??? Array thing ...
    if (this.collector.length == nodStringN) {
        // Start a new node-string collector with this as first vertex
        this.collector[this.collector.length] = [castVector];
    }
    else {    // Add vertex to existing node-string collector
        this.collector[nodStringN][this.collector[nodStringN].length] = castVector;
    }
break;
....
Finally the global polys are casted in a parent function

Code: Select all

...
// Cast global polys if any, open/closed on open/closed Forms
// this.collector is an array with 0...N arrays of RVector's
var jpn = this.collector.length;
for (var jp=0; jp<jpn; jp++) {    // Cycle through all global polys
    addPolyline(this.collector[jp], this.isTanCloObj, false);
}
I thought this was the harder part because of the 0...99 substrings. 8)

Code: Select all

// we have our collector again: 
// A function wide array this time:
var collector = [];
// We push an array with a vector, bulge and let relative be default:
collector.push([castVector , bulge]);  >> casting addPolyline(collector)  No go
// Lets push a new array
collector.push(new Array(castVector , bulge));  >> casting addPolyline(collector)  No go
// Lets try adding it as beyond last
collector[collector.length] = [castVector , bulge];  >> casting addPolyline(collector)  No go
collector[collector.length] = new Array(castVector , bulge);  >> casting addPolyline(collector)  No go
// Lets add round brackets
collector[collector.length] = ([castVector , bulge]);  >> casting addPolyline(collector)  No go
// The castVector is composed out two parts
collector[collector.length] = ([castVector.x , castVector.y , bulge]);  >> Correct casting
EUREKA
It seems that only X,Y or [X,Y] variants work. :oops:

I was able to trace this back to: e_geek
simple_create.js:
Line 236 catches RVector by looking at the start of the arguments.
if so it sets v0 to the first element.
Skipping the next 3 if else and ends up at line 278,
appending a vertex (v,b)
What is: ([firts element],0.0)
What is: (Rvector,bulge,0.0)
What are too many arguments.

Besides that the actual bulge is omitted working with RVector's.

My workaround is re-splitting the castVector. :idea:

Regards,
CVH

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

Simple API addPolyline(...) fixed?

Post by CVH » Thu Oct 17, 2019 9:14 am

Andrew,

I see a 'refactor argument detection' committed at Sep 30, 2019 to simple_create.js
Is this in answer to:
viewtopic.php?t=6618

I wasn't finished testing it and I took a new look at it yesterday.
Look at the commits because the line numbering in the topic didn't matched on GitHub.

Seems you fixed it allready. :P

Regards,
CVH

Post Reply

Return to “QCAD Troubleshooting and Problems”