[[SOLVED]] Looking for scripting help (paid)

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
NickN
Newbie Member
Posts: 3
Joined: Sun Feb 26, 2023 9:21 pm

[[SOLVED]] Looking for scripting help (paid)

Post by NickN » Mon Feb 27, 2023 8:52 pm

Hello All,

I'm looking for some help with what I *think* is a fairly simple script.

I'd like to use QCAD (Windows 10 version) to help lay out an installation plan for a network device using a building floorplan. The devices all need to be within 10m of at least one other device. Once all of the devices are placed I need to generate a CSV file with an ID and (x,y) coordinates for each of them.

From what I've read of the scripting engine, this seems straightforward. My initial thought was to create a new entity that is essentially a circle with a 10m radius and the ability to set a name/ID/label for the entity, and rely on a simple visual check by the user (it'll mostly be me) to ensure that each circle overlaps with at least one other. A more sophisticated approach would be to have the entity or the cursor change color when within the 10m range of a previously placed entity.

So something like the attached image, where the red lines are the floorplan and the blue lines are the new entity (labels not shown).

Then I'll need a menu option that dumps out a CSV that contains all of the entities with their label and the (x,y) of the circle's center point. In a perfect world there would also be a UI setting to change the 10m range to other values.

I don't think it's a huge amount of work, but certainly beyond my lousy JS programming skills.

If you're interested in taking this on and available to start soon, please DM me here.

Thanks!

-Nick
Attachments
example.png
example.png (109.85 KiB) Viewed 12453 times
Last edited by NickN on Mon Apr 17, 2023 5:22 pm, edited 1 time in total.

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

Re: Looking for scripting help (paid)

Post by Husky » Mon Feb 27, 2023 10:41 pm

Hi Nick - welcome to the QCAD forum.

First things first -I'm not a scripting guy! However, I was wondering about this script/ CSV requirement.
NickN wrote:
Mon Feb 27, 2023 8:52 pm
Once all of the devices are placed I need to generate a CSV file with an ID and (x,y) coordinates for each of them.
NickN wrote:
Mon Feb 27, 2023 8:52 pm
Then I'll need a menu option that dumps out a CSV that contains all of the entities with their label and the (x,y) of the circle's center point. In a perfect world there would also be a UI setting to change the 10m range to other values.
What is the reason for this CSV exercise? Is that for export/import reasons? Why you can't stick just to drawings within the already implemented QCAD possibility's?
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..."

NickN
Newbie Member
Posts: 3
Joined: Sun Feb 26, 2023 9:21 pm

Re: Looking for scripting help (paid)

Post by NickN » Mon Feb 27, 2023 11:09 pm

Great question. The CSV output is for the next step in our process. We have a tool that does a fantastic job of optimizing network device settings, but it needs the (x,y) coordinates of the device locations to work its magic.

Due to the many things that second tool has to deal with, there is no feasible way to incorporate it directly with QCAD. It would be the equivalent of adding a sprinkler system to an electric car... you could do it, but you'd probably regret your life choices shortly afterwards :D

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

Re: Looking for scripting help (paid)

Post by CVH » Tue Feb 28, 2023 7:41 am

Nick,

Retrieving entity data from a drawing and exporting things to CSV is not a big deal.
There are already a few CSV script tools on the forum that I wrote.

BTW, I am the developer of DrawFromCSV what does the inverse of what you need.
So when optimized, you are even able to re-draw everything from a new CSV file.
NickN wrote:
Mon Feb 27, 2023 8:52 pm
If you're interested in taking this on and available to start soon, please DM me here.
Presume that you mean PM and you will receive one shortly.

Regards,
CVH

NickN
Newbie Member
Posts: 3
Joined: Sun Feb 26, 2023 9:21 pm

Re: [[SOLVED]] Looking for scripting help (paid)

Post by NickN » Mon Apr 17, 2023 5:37 pm

I'm delighted to say that the talented CVH did an excellent job of solving this problem for me.

You can see a screen capture of his rather nice solution here: https://youtu.be/A1d3s-DXW4g

:D

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

Re: [[SOLVED]] Looking for scripting help (paid)

Post by CVH » Wed Apr 26, 2023 6:12 am

All,

Basically 'Insert Block (BI)' with a major twist and a script to export the Block Reference positions and ID as CSV.
Of the BI method: Rotation, Scales, Flipping and Single or Array of Blocks were not required.

The Block is a cross-hair, a circle and 2 Attribute Definitions: TYPE and ID.
The Attributes are shown side by side in a custom Option Toolbar instead of in a drop-down box with default values.
TYPE and ID are by sequence: Gateway=2; Node=5; Node=6; Node=7; ... and so on, where ID is in hexadecimal notation (2, 5...fff).

The tool creates the Block and the required layers on a virgin drawing with for instance a floor plan.
Or it continues using the available structure on a drawing with existing items.
In that case it also looks up what already exists and continues counting from there.

The attributes of the next item to be inserted are automatically proposed according the required sequencing.
An existing sequence with gaps can be completed or one can add the next one up.

The tool can show none or 1...9 rubber bands to existing items that are the closest to the cursor position with distance labels.
The look of the circle representing the working radius can be changed on the fly as: Normal, Faded or None.

Several test and warnings were implemented.
Block, Block entities, Layers and so on may be manipulated/changed/deleted with standard QCAD tools.
In all these cases the tool doesn't fly blind and reports what can't be handled.


It was a steep learning curve to handle Blocks, Block definitions and Attribute Definitions or related Attributes by script.
Always avoided such Blocks with scripting but now I know a few things more.
We are never to old to learn something new. :lol: :wink:

Regards,
CVH

Post Reply

Return to “QCAD Programming, Script Programming and Contributing”