get/copy value of infosum/total length with shortcuts

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
Tailor
Registered Member
Posts: 2
Joined: Sun Oct 04, 2020 8:22 am

get/copy value of infosum/total length with shortcuts

Post by Tailor » Sun Oct 04, 2020 8:46 am

Hello,

first of all, I really enjoy working and trying stuff with qcad, thanks to all responsible.

Here‘s my thing:
I calculate coordinates in excel, use visual basic to open a new qcad document and paste the coordinates to the command line (via sendkeys)…this works fine.

But to finish the drawing I need further coordinates, which depend on the total length of two splines.
Idea: Drawing those two splines at the beginning > select all > infosum… works with shortcuts(so sendkeys).

Problem: The infosum value is printed in the command line history and also in the property editor (total length) but i can‘t focus on those by keys. So until now i had to read the value and type in by hand, so the automatic process is interrupted.

Is there any possibility without using a mouse to get the value of the total length/infosum for pasting in excel or optionally to the command line?

I’d be so grateful for any hint or solution

Greets from Leipzig,
Anja

Versions
QCAD version: 3.24.3.0
Date: Mar 17 2020
Qt version: 5.13.0
Compiler version: MSVC++ 14.0 (2015)
Build Date: Mar 17 2020
Revision: a3bef72c136d511dedc5c302e12acd72ff6cc243

Architecture: x86_64
OS: Windows
OS version: 10

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

Re: get/copy value of infosum/total length with shortcuts

Post by CVH » Sun Oct 04, 2020 4:32 pm

Hi,
Got curious:
A) Your sendkeys manipulate Qcad by sending shortcut commands to the command line ?
> Q: does that work out? What numbers are you parsing and how are they treated (rounded/truncated)?
B) You didn't retrieve data from Qcad in any form yet ?

Scripting in Qcad is in ECMAscript or JavaScript.
The length of a drawing entity in scripts is simply REntity.getLength()
That is when you have the entity at hand otherwise one has to query that from the drawing by id.
Querying a selection works.
Q: How does sendkeys make the selection among others ?
Maybe that is why you noticed:
Tailor wrote:
Sun Oct 04, 2020 8:46 am
Drawing those two splines at the beginning
Then Select All (TA) would work out.

Maybe you can sendkeys to start the ScriptShell and trow in a simple script.
In the Shell javascript returns every line with a result.
Can one read , copy / cut that return?

qDebug() sends it messages to stdout except on win:
https://qcad.org/rsforum/viewtopic.php? ... out#p23495

But a script can easily write to a CSV, a log, ... too:
https://qcad.org/rsforum/viewtopic.php?f=30&t=7497
https://qcad.org/rsforum/viewtopic.php?f=30&t=7544
One doesn't need a full blown GUI script but those can be linked to a custom shortcut ...

I never used anything else as a textfile in both directions.
And far from automated ... :wink:

Maybe Andrew has a solution / resource at hand that both of us aren't aware of ?!

Regards,
CVH
Last edited by CVH on Wed Nov 25, 2020 11:30 am, edited 1 time in total.

Tailor
Registered Member
Posts: 2
Joined: Sun Oct 04, 2020 8:22 am

Re: get/copy value of infosum/total length with shortcuts

Post by Tailor » Mon Oct 05, 2020 5:34 pm

Hey CVH,

thanks for the fast response...

A) Yes, it works. Once qcad has been opened (by shell("C:\users\...")) application.sendkeys ("Space") sets focus on command line and sendkeys ("^v") pastes my copied coordinates, my splines appear and with "TA" both are selected.
The formula in Excel looks like this: =H61&";"&J61 and when pasted like this: -48,2545011523149;-3,81658135789936

The way of construction is always the same, but the basic data can change, so I calculate the coordinates with formulas (so that they are variable) like pythagorean theorem, intersection of linear equations, trigonometric functions, etc.

B) I haven't been working with scripts in qcad yet. I thought about it, but same problem here, no chance to focus with shortcuts. Thanks for your explanation and the links, guess I'll give it try for more possibilities in future.

Yesterday in the evening I found a way to solve this problem: I checked the box "Show Information as dialog" (Application Preferences>Widgets>Command line). So the total length is shown in a dialog box by "IS" and now I'm able to copy the whole text by sendkeys, paste it in excel, extract the part of relevance (a 6 digit number) and turn the point into an comma (=TEIL(N18;36;2)&","&TEIL(N18;39;4)).
Maybe not that elegant, but fine for me.

And now I'll take a look at scripting with qcad :)

Regards,
Anja

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

Re: get/copy value of infosum/total length with shortcuts

Post by CVH » Thu Nov 05, 2020 2:50 pm

Hi Tailor-Anja

Could you share the top of your Excel macro with us?
We migth help others with it.
https://qcad.org/rsforum/viewtopic.php? ... 133#p30133

Regards,
CVH

Post Reply

Return to “QCAD 'How Do I' Questions”