script question: keep selection + colored aux entity

Use this forum to ask questions about how to do things in QCAD.

Moderator: andrew

Forum rules
Always indicate Operating system, QCAD version
Attach Drawing files, Screenshots
Post one question per topic.
Post Reply
smf
Premier Member
Posts: 172
Joined: Tue Feb 28, 2012 1:05 pm

script question: keep selection + colored aux entity

Post by smf » Sat Dec 13, 2014 9:31 am

Hi there,

I'm working on scripts to support model railroad track planning. Creating tracks, moving and duplicate-moving are working now thanks to Andrew. Two things are missing and I don't have an idea how to implement them:

1. How do I keep a previous selection after execution of a copying Transform-operation? Use case: select track, dup+move several times. Currently the newly inserted objects are selected but I want to keep the originally selected objects selected.

2. I would like to draw a colored and filled auxiliary circle to mark the source track. I succeeded in creating a circle but not in an eye-catching color or with filled area.

Attached you'll find my current work-in-progress-snapshot containing an example file and the created scripts. These have to reside in ...qcad.../scripts/QCTrack. After insertion into the scripts-directory there will be a new main menu "QCTrack" with three items "Create", "Move" and "Duplicate and move".

Thank you for any comment, hint or help
Best regards
Stefan
Attachments
QCTrack_V04_DupMoveOk.zip
scripts
(9.76 KiB) Downloaded 165 times
eibahntest.dxf
example file
(131.33 KiB) Downloaded 171 times

smf
Premier Member
Posts: 172
Joined: Tue Feb 28, 2012 1:05 pm

Re: script question: keep selection + colored aux entity

Post by smf » Sat Dec 13, 2014 1:59 pm

...got the second point somewhat solved with a triangle showing the direction:
ret = new Array();
var mid = getPointOnLine(this.lineSource, 0.5);
ret.push(new RCircle(mid, this.lineSource.getLength() * 1.5));
var top = getPointOnLine(this.lineSource, 2);
var bottom = getPointOnLine(this.lineSource, -1);
var out = getPointOnLine(this.lineSource, 2).rotate(Math.PI / 2, mid);
ret.push(new RLine(top, bottom));
ret.push(new RLine(bottom, out));
ret.push(new RLine(out, top));

smf
Premier Member
Posts: 172
Joined: Tue Feb 28, 2012 1:05 pm

keep selection solved?

Post by smf » Sat Dec 13, 2014 4:25 pm

...now I'm "keeping" the selection by getting all selected entities before operation and resetting selection, because I couldn't find anything better. Attached the current version.
Attachments
QCTrack_V09_MultiDup.zip
(10.59 KiB) Downloaded 162 times

Itzik
Registered Member
Posts: 2
Joined: Wed Jul 29, 2015 2:59 pm

Re: keep selection solved?

Post by Itzik » Wed Jul 29, 2015 3:17 pm

smf wrote:...now I'm "keeping" the selection by getting all selected entities before operation and resetting selection, because I couldn't find anything better. Attached the current version.
Hi !
While looking for Railroad design layout (Marklin HO c-track), found and read your post (nice example) and try to implement it (download your last ver v09 and install it in ...qcad/script/QCTrack), Unfortunately not working - can you help ? is this your last version ?
Thanks.

smf
Premier Member
Posts: 172
Joined: Tue Feb 28, 2012 1:05 pm

Re: script question: keep selection + colored aux entity

Post by smf » Wed Jul 29, 2015 4:09 pm

Hi Itzik,

please try the current version which you find here:
viewtopic.php?f=109&t=3348

Hope this works - you can also get my Maerklin H0-C-track library there!

Itzik
Registered Member
Posts: 2
Joined: Wed Jul 29, 2015 2:59 pm

Re: script question: keep selection + colored aux entity

Post by Itzik » Wed Jul 29, 2015 9:09 pm

smf wrote:Hi Itzik,

please try the current version which you find here:
viewtopic.php?f=109&t=3348

Hope this works - you can also get my Maerklin H0-C-track library there!
Hi again
First, Many thanks for the quick response and for the new ver. & tutorial - will be very helpful
will install & try it !

itzik

Post Reply

Return to “QCAD 'How Do I' Questions”