LineWeight Scripting

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
pmbrull
Junior Member
Posts: 14
Joined: Thu Aug 23, 2018 4:07 pm

LineWeight Scripting

Post by pmbrull » Thu Aug 23, 2018 4:14 pm

Hello and thank you for your time.

First of all, just let me say that the product you made is amazing and has been really helpful in the project I am working on.

I am wrecking my head around scripting some processes. In one of those, I need to export from DXF to PDF by tunning some PaperSpace parameters on the fly, so I wrote my own script from scratch. Everything runs fast and smoothly, although when printing the resulting file, lines are way too thin. In order to fix that, I added the following chunk of code changing LineWeight for the only existing layer:

var op = new RModifyObjectsOperation();
var layer = document.queryLayer("0");
qDebug("LW", layer.getLineweight()) // -3
layer.setLineweight(211);
op.addObject(layer);
di.applyOperation(op);
qDebug("LW", layer.getLineweight()) // 211
// Make sure changes are made
var layer = document.queryLayer("0");
qDebug("LW changed", layer.getLineweight()) // 211

While the code gives no errors, the resulting pdf still shows thin lines when printed. I would really appreciate some guidance here :P

Thanks again,

Pere

pmbrull
Junior Member
Posts: 14
Joined: Thu Aug 23, 2018 4:07 pm

Re: LineWeight Scripting

Post by pmbrull » Fri Aug 24, 2018 7:40 am

Must have messed up somewhere, code works perfect now. However, please let me ask one last thing.

In the code above I am manually changing the LW for one specific layer. Is there a way to change the global default value of every layer without needing to iterate over all of them?

Thanks again,

Pere
Last edited by pmbrull on Mon Aug 27, 2018 8:22 am, edited 1 time in total.

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

Re: LineWeight Scripting

Post by andrew » Fri Aug 24, 2018 10:43 am

No, there's no "global" line weight.

Post Reply

Return to “QCAD 'How Do I' Questions”