Page 1 of 1

script question: keep selection + colored aux entity

Posted: Sat Dec 13, 2014 9:31 am
by smf
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

Re: script question: keep selection + colored aux entity

Posted: Sat Dec 13, 2014 1:59 pm
by smf
...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));

keep selection solved?

Posted: Sat Dec 13, 2014 4:25 pm
by smf
...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.

Re: keep selection solved?

Posted: Wed Jul 29, 2015 3:17 pm
by Itzik
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.

Re: script question: keep selection + colored aux entity

Posted: Wed Jul 29, 2015 4:09 pm
by smf
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!

Re: script question: keep selection + colored aux entity

Posted: Wed Jul 29, 2015 9:09 pm
by Itzik
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